Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index 1a7eeaaacd9057931249dd47ced4b7c748793ebb..2897d5f90668663341030ce4227530c763dc79e9 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -7,6 +7,7 @@ |
| #include "../client/gles2_implementation.h" |
| #include <GLES2/gles2_command_buffer.h> |
| #include "../client/mapped_memory.h" |
| +#include "../client/program_info_manager.h" |
| #include "../common/gles2_cmd_utils.h" |
| #include "../common/id_allocator.h" |
| #include "../common/trace_event.h" |
| @@ -511,6 +512,9 @@ GLES2Implementation::GLES2Implementation( |
| texture_units_.reset( |
| new TextureUnit[gl_state_.max_combined_texture_image_units]); |
| +// program_info_manager_.reset(ProgramInfoManager::Create(sharing_resources_)); |
|
apatrick_chromium
2011/07/20 18:28:51
delete?
|
| + program_info_manager_.reset(ProgramInfoManager::Create(true)); |
| + |
| #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| buffer_id_handler_->MakeIds( |
| kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); |
| @@ -947,28 +951,37 @@ void GLES2Implementation::GetVertexAttribPointerv( |
| }); |
| } |
| -GLint GLES2Implementation::GetAttribLocation( |
| +void GLES2Implementation::DeleteProgramOrShaderHelper( |
| + GLuint program_or_shader) { |
| + program_and_shader_id_handler_->FreeIds(1, &program_or_shader); |
| + program_info_manager_->DeleteInfo(program_or_shader); |
| +} |
| + |
| +GLint GLES2Implementation::GetAttribLocationHelper( |
| GLuint program, const char* name) { |
| - GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program |
| - << ", " << name << ")"); |
| - TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); |
| typedef GetAttribLocationBucket::Result Result; |
| Result* result = GetResultAs<Result*>(); |
| *result = -1; |
| SetBucketAsCString(kResultBucketId, name); |
| - helper_->GetAttribLocationBucket(program, kResultBucketId, |
| - result_shm_id(), result_shm_offset()); |
| + helper_->GetAttribLocationBucket( |
| + program, kResultBucketId, result_shm_id(), result_shm_offset()); |
| WaitForCmd(); |
| helper_->SetBucketSize(kResultBucketId, 0); |
| - GPU_CLIENT_LOG("returned " << *result); |
| return *result; |
| } |
| -GLint GLES2Implementation::GetUniformLocation( |
| +GLint GLES2Implementation::GetAttribLocation( |
| GLuint program, const char* name) { |
| - GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program |
| + GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program |
| << ", " << name << ")"); |
| - TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
| + TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); |
| + GLint loc = program_info_manager_->GetAttribLocation(this, program, name); |
| + GPU_CLIENT_LOG("returned " << loc); |
| + return loc; |
| +} |
| + |
| +GLint GLES2Implementation::GetUniformLocationHelper( |
| + GLuint program, const char* name) { |
| typedef GetUniformLocationBucket::Result Result; |
| Result* result = GetResultAs<Result*>(); |
| *result = -1; |
| @@ -977,10 +990,29 @@ GLint GLES2Implementation::GetUniformLocation( |
| result_shm_id(), result_shm_offset()); |
| WaitForCmd(); |
| helper_->SetBucketSize(kResultBucketId, 0); |
| - GPU_CLIENT_LOG("returned " << *result); |
| return *result; |
| } |
| +GLint GLES2Implementation::GetUniformLocation( |
| + GLuint program, const char* name) { |
| + GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program |
| + << ", " << name << ")"); |
| + TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
| + GLint loc = program_info_manager_->GetUniformLocation(this, program, name); |
| + GPU_CLIENT_LOG("returned " << loc); |
| + return loc; |
| +} |
| + |
| +bool GLES2Implementation::GetProgramivHelper( |
| + GLuint program, GLenum pname, GLint* params) { |
| + return program_info_manager_->GetProgramiv(this, program, pname, params); |
| +} |
| + |
| +void GLES2Implementation::LinkProgram(GLuint program) { |
| + GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")"); |
| + helper_->LinkProgram(program); |
| + program_info_manager_->CreateInfo(program); |
| +} |
| void GLES2Implementation::ShaderBinary( |
| GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, |
| @@ -1372,21 +1404,10 @@ void GLES2Implementation::TexSubImage2DImpl( |
| } |
| } |
| -void GLES2Implementation::GetActiveAttrib( |
| +bool GLES2Implementation::GetActiveAttribHelper( |
| GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| GLenum* type, char* name) { |
| - GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" |
| - << program << ", " << index << ", " << bufsize << ", " |
| - << static_cast<const void*>(length) << ", " |
| - << static_cast<const void*>(size) << ", " |
| - << static_cast<const void*>(type) << ", " |
| - << static_cast<const void*>(name) << ", "); |
| - if (bufsize < 0) { |
| - SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); |
| - return; |
| - } |
| - TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); |
| - // Clear the bucket so if we the command fails nothing will be in it. |
| + // Clear the bucket so if the command fails nothing will be in it. |
| helper_->SetBucketSize(kResultBucketId, 0); |
| typedef gles2::GetActiveAttrib::Result Result; |
| Result* result = static_cast<Result*>(result_buffer_); |
| @@ -1398,11 +1419,9 @@ void GLES2Implementation::GetActiveAttrib( |
| if (result->success) { |
| if (size) { |
| *size = result->size; |
| - GPU_CLIENT_LOG(" size: " << *size); |
| } |
| if (type) { |
| *type = result->type; |
| - GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| } |
| if (length || name) { |
| std::vector<int8> str; |
| @@ -1416,27 +1435,45 @@ void GLES2Implementation::GetActiveAttrib( |
| if (name && bufsize > 0) { |
| memcpy(name, &str[0], max_size); |
| name[max_size] = '\0'; |
| - GPU_CLIENT_LOG(" name: " << name); |
| } |
| } |
| } |
| + return result->success != 0; |
| } |
| -void GLES2Implementation::GetActiveUniform( |
| +void GLES2Implementation::GetActiveAttrib( |
| GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| GLenum* type, char* name) { |
| - GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform(" |
| + GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" |
| << program << ", " << index << ", " << bufsize << ", " |
| << static_cast<const void*>(length) << ", " |
| << static_cast<const void*>(size) << ", " |
| << static_cast<const void*>(type) << ", " |
| << static_cast<const void*>(name) << ", "); |
| if (bufsize < 0) { |
| - SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); |
| + SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); |
| return; |
| } |
| - TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); |
| - // Clear the bucket so if we the command fails nothing will be in it. |
| + TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); |
| + bool success = program_info_manager_->GetActiveAttrib( |
| + this, program, index, bufsize, length, size, type, name); |
| + if (success) { |
| + if (size) { |
| + GPU_CLIENT_LOG(" size: " << *size); |
| + } |
| + if (type) { |
| + GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| + } |
| + if (name) { |
| + GPU_CLIENT_LOG(" name: " << name); |
| + } |
| + } |
| +} |
| + |
| +bool GLES2Implementation::GetActiveUniformHelper( |
| + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| + GLenum* type, char* name) { |
| + // Clear the bucket so if the command fails nothing will be in it. |
| helper_->SetBucketSize(kResultBucketId, 0); |
| typedef gles2::GetActiveUniform::Result Result; |
| Result* result = static_cast<Result*>(result_buffer_); |
| @@ -1448,11 +1485,9 @@ void GLES2Implementation::GetActiveUniform( |
| if (result->success) { |
| if (size) { |
| *size = result->size; |
| - GPU_CLIENT_LOG(" size: " << *size); |
| } |
| if (type) { |
| *type = result->type; |
| - GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| } |
| if (length || name) { |
| std::vector<int8> str; |
| @@ -1466,10 +1501,39 @@ void GLES2Implementation::GetActiveUniform( |
| if (name && bufsize > 0) { |
| memcpy(name, &str[0], max_size); |
| name[max_size] = '\0'; |
| - GPU_CLIENT_LOG(" name: " << name); |
| } |
| } |
| } |
| + return result->success != 0; |
| +} |
| + |
| +void GLES2Implementation::GetActiveUniform( |
| + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| + GLenum* type, char* name) { |
| + GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform(" |
| + << program << ", " << index << ", " << bufsize << ", " |
| + << static_cast<const void*>(length) << ", " |
| + << static_cast<const void*>(size) << ", " |
| + << static_cast<const void*>(type) << ", " |
| + << static_cast<const void*>(name) << ", "); |
| + if (bufsize < 0) { |
| + SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); |
| + return; |
| + } |
| + TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); |
| + bool success = program_info_manager_->GetActiveUniform( |
| + this, program, index, bufsize, length, size, type, name); |
| + if (success) { |
| + if (size) { |
| + GPU_CLIENT_LOG(" size: " << *size); |
| + } |
| + if (type) { |
| + GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| + } |
| + if (name) { |
| + GPU_CLIENT_LOG(" name: " << name); |
| + } |
| + } |
| } |
| void GLES2Implementation::GetAttachedShaders( |
| @@ -2255,6 +2319,15 @@ void GLES2Implementation::GetMultipleIntegervCHROMIUM( |
| }); |
| } |
| +void GLES2Implementation::GetProgramInfoCHROMIUMHelper( |
| + GLuint program, std::vector<int8>* result) { |
| + DCHECK(result); |
| + // Clear the bucket so if the command fails nothing will be in it. |
| + helper_->SetBucketSize(kResultBucketId, 0); |
| + helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); |
| + GetBucketContents(kResultBucketId, result); |
| +} |
| + |
| void GLES2Implementation::GetProgramInfoCHROMIUM( |
| GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
| if (bufsize < 0) { |
| @@ -2268,12 +2341,9 @@ void GLES2Implementation::GetProgramInfoCHROMIUM( |
| // Make sure they've set size to 0 else the value will be undefined on |
| // lost context. |
| GPU_DCHECK(*size == 0); |
| - // Clear the bucket so if the command fails nothing will be in it. |
| - helper_->SetBucketSize(kResultBucketId, 0); |
| - helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); |
| std::vector<int8> result; |
| - GetBucketContents(kResultBucketId, &result); |
| - if (result.size() == 0) { |
| + GetProgramInfoCHROMIUMHelper(program, &result); |
| + if (result.empty()) { |
| return; |
| } |
| *size = result.size(); |