OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 GLuint client_id, GLint location, const char* name); | 1163 GLuint client_id, GLint location, const char* name); |
1164 | 1164 |
1165 error::Error GetAttribLocationHelper( | 1165 error::Error GetAttribLocationHelper( |
1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
1167 const std::string& name_str); | 1167 const std::string& name_str); |
1168 | 1168 |
1169 error::Error GetUniformLocationHelper( | 1169 error::Error GetUniformLocationHelper( |
1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
1171 const std::string& name_str); | 1171 const std::string& name_str); |
1172 | 1172 |
1173 // Helper for glShaderSource. | 1173 // Wrapper for glShaderSource. |
1174 error::Error ShaderSourceHelper( | 1174 void DoShaderSource( |
1175 GLuint client_id, const char* data, uint32 data_size); | 1175 GLuint client_id, GLsizei count, const char** data, const GLint* length); |
1176 | 1176 |
1177 // Clear any textures used by the current program. | 1177 // Clear any textures used by the current program. |
1178 bool ClearUnclearedTextures(); | 1178 bool ClearUnclearedTextures(); |
1179 | 1179 |
1180 // Clears any uncleared attachments attached to the given frame buffer. | 1180 // Clears any uncleared attachments attached to the given frame buffer. |
1181 // Returns false if there was a generated GL error. | 1181 // Returns false if there was a generated GL error. |
1182 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); | 1182 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); |
1183 | 1183 |
1184 // overridden from GLES2Decoder | 1184 // overridden from GLES2Decoder |
1185 bool ClearLevel(unsigned service_id, | 1185 bool ClearLevel(unsigned service_id, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 // Gets the service id for any simulated backbuffer fbo. | 1271 // Gets the service id for any simulated backbuffer fbo. |
1272 GLuint GetBackbufferServiceId() const; | 1272 GLuint GetBackbufferServiceId() const; |
1273 | 1273 |
1274 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv | 1274 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv |
1275 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); | 1275 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); |
1276 | 1276 |
1277 // Helper for glGetVertexAttrib | 1277 // Helper for glGetVertexAttrib |
1278 void GetVertexAttribHelper( | 1278 void GetVertexAttribHelper( |
1279 const VertexAttrib* attrib, GLenum pname, GLint* param); | 1279 const VertexAttrib* attrib, GLenum pname, GLint* param); |
1280 | 1280 |
1281 // Wrapper for glCreateProgram | |
1282 bool CreateProgramHelper(GLuint client_id); | |
1283 | |
1284 // Wrapper for glCreateShader | |
1285 bool CreateShaderHelper(GLenum type, GLuint client_id); | |
1286 | |
1287 // Wrapper for glActiveTexture | 1281 // Wrapper for glActiveTexture |
1288 void DoActiveTexture(GLenum texture_unit); | 1282 void DoActiveTexture(GLenum texture_unit); |
1289 | 1283 |
1290 // Wrapper for glAttachShader | 1284 // Wrapper for glAttachShader |
1291 void DoAttachShader(GLuint client_program_id, GLint client_shader_id); | 1285 void DoAttachShader(GLuint client_program_id, GLint client_shader_id); |
1292 | 1286 |
1293 // Wrapper for glBindBuffer since we need to track the current targets. | 1287 // Wrapper for glBindBuffer since we need to track the current targets. |
1294 void DoBindBuffer(GLenum target, GLuint buffer); | 1288 void DoBindBuffer(GLenum target, GLuint buffer); |
1295 | 1289 |
1296 // Wrapper for glBindFramebuffer since we need to track the current targets. | 1290 // Wrapper for glBindFramebuffer since we need to track the current targets. |
(...skipping 2745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4042 } else { | 4036 } else { |
4043 return DoCommandsImpl<false>( | 4037 return DoCommandsImpl<false>( |
4044 num_commands, buffer, num_entries, entries_processed); | 4038 num_commands, buffer, num_entries, entries_processed); |
4045 } | 4039 } |
4046 } | 4040 } |
4047 | 4041 |
4048 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) { | 4042 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) { |
4049 buffer_manager()->RemoveBuffer(client_id); | 4043 buffer_manager()->RemoveBuffer(client_id); |
4050 } | 4044 } |
4051 | 4045 |
4052 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { | |
4053 if (GetProgram(client_id)) { | |
4054 return false; | |
4055 } | |
4056 GLuint service_id = glCreateProgram(); | |
4057 if (service_id != 0) { | |
4058 CreateProgram(client_id, service_id); | |
4059 } | |
4060 return true; | |
4061 } | |
4062 | |
4063 bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) { | |
4064 if (GetShader(client_id)) { | |
4065 return false; | |
4066 } | |
4067 GLuint service_id = glCreateShader(type); | |
4068 if (service_id != 0) { | |
4069 CreateShader(client_id, service_id, type); | |
4070 } | |
4071 return true; | |
4072 } | |
4073 | |
4074 void GLES2DecoderImpl::DoFinish() { | 4046 void GLES2DecoderImpl::DoFinish() { |
4075 glFinish(); | 4047 glFinish(); |
4076 ProcessPendingReadPixels(); | 4048 ProcessPendingReadPixels(); |
4077 ProcessPendingQueries(true); | 4049 ProcessPendingQueries(true); |
4078 } | 4050 } |
4079 | 4051 |
4080 void GLES2DecoderImpl::DoFlush() { | 4052 void GLES2DecoderImpl::DoFlush() { |
4081 glFlush(); | 4053 glFlush(); |
4082 ProcessPendingQueries(false); | 4054 ProcessPendingQueries(false); |
4083 } | 4055 } |
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7059 offset, count, type, &max_vertex_accessed)) { | 7031 offset, count, type, &max_vertex_accessed)) { |
7060 // TODO(gman): Should this be a GL error or a command buffer error? | 7032 // TODO(gman): Should this be a GL error or a command buffer error? |
7061 LOCAL_SET_GL_ERROR( | 7033 LOCAL_SET_GL_ERROR( |
7062 GL_INVALID_OPERATION, | 7034 GL_INVALID_OPERATION, |
7063 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer"); | 7035 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer"); |
7064 } | 7036 } |
7065 } | 7037 } |
7066 return max_vertex_accessed; | 7038 return max_vertex_accessed; |
7067 } | 7039 } |
7068 | 7040 |
7069 // Calls glShaderSource for the various versions of the ShaderSource command. | 7041 void GLES2DecoderImpl::DoShaderSource( |
7070 // Assumes that data / data_size points to a piece of memory that is in range | 7042 GLuint client_id, GLsizei count, const char** data, const GLint* length) { |
7071 // of whatever context it came from (shared memory, immediate memory, bucket | 7043 std::string str; |
7072 // memory.) | 7044 for (GLsizei ii = 0; ii < count; ++ii) { |
7073 error::Error GLES2DecoderImpl::ShaderSourceHelper( | 7045 str.append(data[ii]); |
7074 GLuint client_id, const char* data, uint32 data_size) { | 7046 } |
7075 std::string str(data, data + data_size); | |
7076 Shader* shader = GetShaderInfoNotProgram(client_id, "glShaderSource"); | 7047 Shader* shader = GetShaderInfoNotProgram(client_id, "glShaderSource"); |
7077 if (!shader) { | 7048 if (!shader) { |
7078 return error::kNoError; | 7049 return; |
7079 } | 7050 } |
7080 // Note: We don't actually call glShaderSource here. We wait until | 7051 // Note: We don't actually call glShaderSource here. We wait until |
7081 // the call to glCompileShader. | 7052 // the call to glCompileShader. |
7082 shader->set_source(str); | 7053 shader->set_source(str); |
7083 return error::kNoError; | |
7084 } | |
7085 | |
7086 error::Error GLES2DecoderImpl::HandleShaderSourceBucket( | |
7087 uint32 immediate_data_size, | |
7088 const void* cmd_data) { | |
7089 const gles2::cmds::ShaderSourceBucket& c = | |
7090 *static_cast<const gles2::cmds::ShaderSourceBucket*>(cmd_data); | |
7091 Bucket* bucket = GetBucket(c.data_bucket_id); | |
7092 if (!bucket || bucket->size() == 0) { | |
7093 return error::kInvalidArguments; | |
7094 } | |
7095 return ShaderSourceHelper( | |
7096 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1), | |
7097 bucket->size() - 1); | |
7098 } | 7054 } |
7099 | 7055 |
7100 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 7056 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
7101 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); | 7057 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); |
7102 Shader* shader = GetShaderInfoNotProgram(client_id, "glCompileShader"); | 7058 Shader* shader = GetShaderInfoNotProgram(client_id, "glCompileShader"); |
7103 if (!shader) { | 7059 if (!shader) { |
7104 return; | 7060 return; |
7105 } | 7061 } |
7106 ShaderTranslator* translator = NULL; | 7062 ShaderTranslator* translator = NULL; |
7107 if (use_shader_translator_) { | 7063 if (use_shader_translator_) { |
(...skipping 4542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11650 } | 11606 } |
11651 } | 11607 } |
11652 | 11608 |
11653 // Include the auto-generated part of this file. We split this because it means | 11609 // Include the auto-generated part of this file. We split this because it means |
11654 // we can easily edit the non-auto generated parts right here in this file | 11610 // we can easily edit the non-auto generated parts right here in this file |
11655 // instead of having to edit some template or the code generator. | 11611 // instead of having to edit some template or the code generator. |
11656 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11612 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11657 | 11613 |
11658 } // namespace gles2 | 11614 } // namespace gles2 |
11659 } // namespace gpu | 11615 } // namespace gpu |
OLD | NEW |