diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 00:51:34 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 00:51:34 +0000 |
commit | f57bb2865fa146140d27e64c68148b79724f2f35 (patch) | |
tree | 03becedc67abf8a12fb1970ccaa7b3bbca06b6b7 /gpu/command_buffer/service/program_manager.cc | |
parent | 339d6dd4d356d062365a9a1a1aaf17f42d5349d3 (diff) | |
download | chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.zip chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.tar.gz chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.tar.bz2 |
Use the shader translator to correct bad type information
returned by OpenGL drivers.
TEST=unit tests, ran OpenGL ES 2.0 conformance tests and ran WebGL conformance test. Things that used to fail now pass.
BUG=none
Review URL: http://codereview.chromium.org/4829001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/program_manager.cc')
-rw-r--r-- | gpu/command_buffer/service/program_manager.cc | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index c94bd9b..596c8c9 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -27,7 +27,6 @@ static int ShaderTypeToIndex(GLenum shader_type) { } } - ProgramManager::ProgramInfo::UniformInfo::UniformInfo(GLsizei _size, GLenum _type, const std::string& _name) @@ -92,13 +91,14 @@ void ProgramManager::ProgramInfo::Update() { DCHECK(max_len == 0 || length < max_len); DCHECK(length == 0 || name_buffer[length] == '\0'); if (!IsInvalidPrefix(name_buffer.get(), length)) { + std::string name; + GetCorrectedVariableInfo(false, name_buffer.get(), &name, &size, &type); // TODO(gman): Should we check for error? GLint location = glGetAttribLocation(service_id_, name_buffer.get()); if (location > max_location) { max_location = location; } - attrib_infos_.push_back( - VertexAttribInfo(size, type, name_buffer.get(), location)); + attrib_infos_.push_back(VertexAttribInfo(size, type, name, location)); max_attrib_name_length_ = std::max(max_attrib_name_length_, length); } } @@ -131,8 +131,9 @@ void ProgramManager::ProgramInfo::Update() { // TODO(gman): Should we check for error? if (!IsInvalidPrefix(name_buffer.get(), length)) { GLint location = glGetUniformLocation(service_id_, name_buffer.get()); - const UniformInfo* info = - AddUniformInfo(size, type, location, name_buffer.get()); + std::string name; + GetCorrectedVariableInfo(true, name_buffer.get(), &name, &size, &type); + const UniformInfo* info = AddUniformInfo(size, type, location, name); for (size_t jj = 0; jj < info->element_locations.size(); ++jj) { if (info->element_locations[jj] > max_location) { max_location = info->element_locations[jj]; @@ -221,6 +222,39 @@ bool ProgramManager::ProgramInfo::GetUniformTypeByLocation( return false; } +// Note: This is only valid to call right after a program has been linked +// successfully. +void ProgramManager::ProgramInfo::GetCorrectedVariableInfo( + bool use_uniforms, + const std::string& name, std::string* corrected_name, + GLsizei* size, GLenum* type) const { + DCHECK(corrected_name); + DCHECK(size); + DCHECK(type); + const char* kArraySpec = "[0]"; + for (int jj = 0; jj < 2; ++jj) { + std::string test_name(name + ((jj == 1) ? kArraySpec : "")); + for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { + ShaderManager::ShaderInfo* shader_info = attached_shaders_[ii].get(); + if (shader_info) { + const ShaderManager::ShaderInfo::VariableInfo* variable_info = + use_uniforms ? shader_info->GetUniformInfo(test_name) : + shader_info->GetAttribInfo(test_name); + // Note: There is an assuption here that if an attrib is defined in more + // than 1 attached shader their types and sizes match. Should we check + // for that case? + if (variable_info) { + *corrected_name = test_name; + *type = variable_info->type; + *size = variable_info->size; + return; + } + } + } + } + *corrected_name = name; +} + const ProgramManager::ProgramInfo::UniformInfo* ProgramManager::ProgramInfo::AddUniformInfo( GLsizei size, GLenum type, GLint location, const std::string& name) { |