diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 21:52:33 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 21:52:33 +0000 |
commit | f6d33f3627cbb380773957fe14fcedc3b4087f53 (patch) | |
tree | d110e42744aeb174f4afd97772f05026c1f8dd50 /gpu | |
parent | 0094fbeef17a8c28e8b5c16fe34598a1ef2c8460 (diff) | |
download | chromium_src-f6d33f3627cbb380773957fe14fcedc3b4087f53.zip chromium_src-f6d33f3627cbb380773957fe14fcedc3b4087f53.tar.gz chromium_src-f6d33f3627cbb380773957fe14fcedc3b4087f53.tar.bz2 |
Fixed bug with the way the command buffer code handled
arrays of uniforms.
TEST=unit tests and WebGL conformance tests
BUG=none
Review URL: http://codereview.chromium.org/2834048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc | 11 | ||||
-rw-r--r-- | gpu/command_buffer/service/program_manager.cc | 20 | ||||
-rw-r--r-- | gpu/command_buffer/service/program_manager_unittest.cc | 8 |
3 files changed, 29 insertions, 10 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc index 97221dc..ea1f056 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" +#include <algorithm> +#include <string> #include "app/gfx/gl/gl_mock.h" #include "base/string_util.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" @@ -509,12 +511,17 @@ void GLES2DecoderTestBase::SetupShader( .WillOnce(Return(info.location)) .RetiresOnSaturation(); if (info.size > 1) { + std::string base_name = info.name; + size_t array_pos = base_name.rfind("[0]"); + if (base_name.size() > 3 && array_pos == base_name.size() - 3) { + base_name = base_name.substr(0, base_name.size() - 3); + } for (GLsizei jj = 1; jj < info.size; ++jj) { std::string element_name( - std::string(info.name) + "[" + IntToString(jj) + "]"); + std::string(base_name) + "[" + IntToString(jj) + "]"); EXPECT_CALL(*gl_, GetUniformLocation(program_service_id, StrEq(element_name))) - .WillOnce(Return(info.location + jj)) + .WillOnce(Return(info.location + jj * 2)) .RetiresOnSaturation(); } } diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index 55d1268..81bab30 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "gpu/command_buffer/service/program_manager.h" +#include <algorithm> #include "base/basictypes.h" #include "base/logging.h" #include "base/scoped_ptr.h" @@ -206,11 +207,6 @@ const ProgramManager::ProgramInfo::UniformInfo* info.texture_units.resize(num_texture_units, 0); if (size > 1) { - for (GLsizei ii = 1; ii < info.size; ++ii) { - std::string element_name(name + "[" + IntToString(ii) + "]"); - info.element_locations[ii] = - glGetUniformLocation(service_id_, element_name.c_str()); - } // Sadly there is no way to tell if this is an array except if the name // has an array string or the size > 1. That means an array of size 1 can // be ambiguous. @@ -222,8 +218,18 @@ const ProgramManager::ProgramInfo::UniformInfo* // We can skip the first element because it's the same as the // the location without the array operators. size_t array_pos = name.rfind(kArraySpec); - if (name.size() > 3 && array_pos != name.size() - 3) { - info.name = name + kArraySpec; + std::string base_name = name; + if (name.size() > 3) { + if (array_pos != name.size() - 3) { + info.name = name + kArraySpec; + } else { + base_name = name.substr(0, name.size() - 3); + } + } + for (GLsizei ii = 1; ii < info.size; ++ii) { + std::string element_name(base_name + "[" + IntToString(ii) + "]"); + info.element_locations[ii] = + glGetUniformLocation(service_id_, element_name.c_str()); } } diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc index 3faf14e..4acb7b1 100644 --- a/gpu/command_buffer/service/program_manager_unittest.cc +++ b/gpu/command_buffer/service/program_manager_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "gpu/command_buffer/service/program_manager.h" +#include <algorithm> #include "app/gfx/gl/gl_mock.h" #include "base/scoped_ptr.h" #include "base/string_util.h" @@ -237,9 +238,14 @@ class ProgramManagerWithShaderTest : public testing::Test { .WillOnce(Return(info.location)) .RetiresOnSaturation(); if (info.size > 1) { + std::string base_name = info.name; + size_t array_pos = base_name.rfind("[0]"); + if (base_name.size() > 3 && array_pos == base_name.size() - 3) { + base_name = base_name.substr(0, base_name.size() - 3); + } for (GLsizei jj = 1; jj < info.size; ++jj) { std::string element_name( - std::string(info.name) + "[" + IntToString(jj) + "]"); + std::string(base_name) + "[" + IntToString(jj) + "]"); EXPECT_CALL(*gl_, GetUniformLocation(service_id, StrEq(element_name))) .WillOnce(Return(info.location + jj * 2)) |