diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 03:44:12 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-22 03:44:12 +0000 |
commit | 1b0a675bff2a40e3ffb8b7d80f37ef305eacdae9 (patch) | |
tree | d59268068108d4ea324f849750461c575d5f71f3 /gpu | |
parent | 3f1201a57fb69c1dda8d161bce704b86573665c2 (diff) | |
download | chromium_src-1b0a675bff2a40e3ffb8b7d80f37ef305eacdae9.zip chromium_src-1b0a675bff2a40e3ffb8b7d80f37ef305eacdae9.tar.gz chromium_src-1b0a675bff2a40e3ffb8b7d80f37ef305eacdae9.tar.bz2 |
Map uniform locations to fake locations.
The issue was there's was a vector of location_info_ that mapped
real locations to intern info about the corresponding uniform.
It assumed locations would be small numbers but it turns out
some drivers use the upper 16 bits of a 32 bit location for
the location of array elements.
We need lookup to be fast so if we make up fake locations
for the client then when the client uses a location we can
quickly index into our uniform info and get the real location.
TEST=unit tests, ran OpenGL ES 2.0 conformance tests and WebGL tests
BUG=112230
R=apatrick@chromium.org
Review URL: http://codereview.chromium.org/9372080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
9 files changed, 368 insertions, 274 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 3c88826..ecbf73e 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -3601,12 +3601,15 @@ TEST_F(%(test_name)s, %(name)sValidArgsCountTooLarge) { for arg in func.GetOriginalArgs(): # hardcoded to match unit tests. if count == 0: - # the location of the second element of the first uniform. - gl_arg_strings.append(arg.GetValidGLArg(func, 2, 2)) - arg_strings.append(arg.GetValidArg(func, 2, 2)) + # the location of the second element of the 2nd uniform. + # defined in GLES2DecoderBase::SetupShaderForUniform + gl_arg_strings.append("3") + arg_strings.append( + "program_manager()->SwizzleLocation(ProgramManager::" + "ProgramInfo::GetFakeLocation(1, 1))") elif count == 1: # the number of elements that gl will be called with. - gl_arg_strings.append("2") + gl_arg_strings.append("3") # the number of elements requested in the command. arg_strings.append("5") else: diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index b437f4c..8539dcd 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -982,7 +982,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, // program is valid and the location exists. Adjusts count so it // does not overflow the uniform. bool PrepForSetUniformByLocation( - GLint location, const char* function_name, GLenum* type, GLsizei* count); + GLint fake_location, const char* function_name, + GLint* real_location, GLenum* type, GLsizei* count); // Gets the service id for any simulated backbuffer fbo. GLuint GetBackbufferServiceId(); @@ -1151,25 +1152,28 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 // spec only these 2 functions can be used to set sampler uniforms. - void DoUniform1i(GLint location, GLint v0); - void DoUniform1iv(GLint location, GLsizei count, const GLint* value); - void DoUniform2iv(GLint location, GLsizei count, const GLint* value); - void DoUniform3iv(GLint location, GLsizei count, const GLint* value); - void DoUniform4iv(GLint location, GLsizei count, const GLint* value); + void DoUniform1i(GLint fake_location, GLint v0); + void DoUniform1iv(GLint fake_location, GLsizei count, const GLint* value); + void DoUniform2iv(GLint fake_location, GLsizei count, const GLint* value); + void DoUniform3iv(GLint fake_location, GLsizei count, const GLint* value); + void DoUniform4iv(GLint fake_location, GLsizei count, const GLint* value); // Wrappers for glUniformfv because some drivers don't correctly accept // bool uniforms. - void DoUniform1fv(GLint location, GLsizei count, const GLfloat* value); - void DoUniform2fv(GLint location, GLsizei count, const GLfloat* value); - void DoUniform3fv(GLint location, GLsizei count, const GLfloat* value); - void DoUniform4fv(GLint location, GLsizei count, const GLfloat* value); + void DoUniform1fv(GLint fake_location, GLsizei count, const GLfloat* value); + void DoUniform2fv(GLint fake_location, GLsizei count, const GLfloat* value); + void DoUniform3fv(GLint fake_location, GLsizei count, const GLfloat* value); + void DoUniform4fv(GLint fake_location, GLsizei count, const GLfloat* value); void DoUniformMatrix2fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value); void DoUniformMatrix3fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value); void DoUniformMatrix4fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value); // Wrappers for glVertexAttrib?? void DoVertexAttrib1f(GLuint index, GLfloat v0); @@ -1329,10 +1333,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, // a SizeResult setup to receive the result. Returns true if glGetUniform // should be called. bool GetUniformSetup( - GLuint program, GLint location, + GLuint program, GLint fake_location, uint32 shm_id, uint32 shm_offset, - error::Error* error, GLuint* service_id, void** result, - GLenum* result_type); + error::Error* error, GLint* real_location, GLuint* service_id, + void** result, GLenum* result_type); // Computes the estimated memory used for the backbuffer and passes it to // the tracing system. @@ -4506,15 +4510,18 @@ bool GLES2DecoderImpl::CheckCurrentProgramForUniform( } bool GLES2DecoderImpl::PrepForSetUniformByLocation( - GLint location, const char* function_name, GLenum* type, GLsizei* count) { + GLint fake_location, const char* function_name, + GLint* real_location, GLenum* type, GLsizei* count) { DCHECK(type); DCHECK(count); - if (!CheckCurrentProgramForUniform(location, function_name)) { + DCHECK(real_location); + if (!CheckCurrentProgramForUniform(fake_location, function_name)) { return false; } GLint array_index = -1; const ProgramManager::ProgramInfo::UniformInfo* info = - current_program_->GetUniformInfoByLocation(location, &array_index); + current_program_->GetUniformInfoByFakeLocation( + fake_location, real_location, &array_index); if (!info) { SetGLError(GL_INVALID_OPERATION, (std::string(function_name) + ": unknown location").c_str()); @@ -4534,34 +4541,39 @@ bool GLES2DecoderImpl::PrepForSetUniformByLocation( return true; } -void GLES2DecoderImpl::DoUniform1i(GLint location, GLint v0) { - if (!CheckCurrentProgramForUniform(location, "glUniform1i")) { +void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { + GLenum type = 0; + GLsizei count = 1; + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform1iv", &real_location, &type, &count)) { return; } - current_program_->SetSamplers(location, 1, &v0); - glUniform1i(location, v0); + current_program_->SetSamplers(fake_location, 1, &v0); + glUniform1i(real_location, v0); } void GLES2DecoderImpl::DoUniform1iv( - GLint location, GLsizei count, const GLint *value) { - if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) { - return; - } + GLint fake_location, GLsizei count, const GLint *value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform1iv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform1iv", &real_location, &type, &count)) { return; } if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { - current_program_->SetSamplers(location, count, value); + current_program_->SetSamplers(fake_location, count, value); } - glUniform1iv(location, count, value); + glUniform1iv(real_location, count, value); } void GLES2DecoderImpl::DoUniform1fv( - GLint location, GLsizei count, const GLfloat* value) { + GLint fake_location, GLsizei count, const GLfloat* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform1fv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform1fv", &real_location, &type, &count)) { return; } if (type == GL_BOOL) { @@ -4569,16 +4581,18 @@ void GLES2DecoderImpl::DoUniform1fv( for (GLsizei ii = 0; ii < count; ++ii) { temp[ii] = static_cast<GLint>(value[ii] != 0.0f); } - DoUniform1iv(location, count, temp.get()); + DoUniform1iv(real_location, count, temp.get()); } else { - glUniform1fv(location, count, value); + glUniform1fv(real_location, count, value); } } void GLES2DecoderImpl::DoUniform2fv( - GLint location, GLsizei count, const GLfloat* value) { + GLint fake_location, GLsizei count, const GLfloat* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform2fv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform2fv", &real_location, &type, &count)) { return; } if (type == GL_BOOL_VEC2) { @@ -4587,16 +4601,18 @@ void GLES2DecoderImpl::DoUniform2fv( for (GLsizei ii = 0; ii < num_values; ++ii) { temp[ii] = static_cast<GLint>(value[ii] != 0.0f); } - glUniform2iv(location, count, temp.get()); + glUniform2iv(real_location, count, temp.get()); } else { - glUniform2fv(location, count, value); + glUniform2fv(real_location, count, value); } } void GLES2DecoderImpl::DoUniform3fv( - GLint location, GLsizei count, const GLfloat* value) { + GLint fake_location, GLsizei count, const GLfloat* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform3fv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform3fv", &real_location, &type, &count)) { return; } if (type == GL_BOOL_VEC3) { @@ -4605,16 +4621,18 @@ void GLES2DecoderImpl::DoUniform3fv( for (GLsizei ii = 0; ii < num_values; ++ii) { temp[ii] = static_cast<GLint>(value[ii] != 0.0f); } - glUniform3iv(location, count, temp.get()); + glUniform3iv(real_location, count, temp.get()); } else { - glUniform3fv(location, count, value); + glUniform3fv(real_location, count, value); } } void GLES2DecoderImpl::DoUniform4fv( - GLint location, GLsizei count, const GLfloat* value) { + GLint fake_location, GLsizei count, const GLfloat* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform4fv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform4fv", &real_location, &type, &count)) { return; } if (type == GL_BOOL_VEC4) { @@ -4623,67 +4641,79 @@ void GLES2DecoderImpl::DoUniform4fv( for (GLsizei ii = 0; ii < num_values; ++ii) { temp[ii] = static_cast<GLint>(value[ii] != 0.0f); } - glUniform4iv(location, count, temp.get()); + glUniform4iv(real_location, count, temp.get()); } else { - glUniform4fv(location, count, value); + glUniform4fv(real_location, count, value); } } void GLES2DecoderImpl::DoUniform2iv( - GLint location, GLsizei count, const GLint* value) { + GLint fake_location, GLsizei count, const GLint* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform2iv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform2iv", &real_location, &type, &count)) { return; } - glUniform2iv(location, count, value); + glUniform2iv(real_location, count, value); } void GLES2DecoderImpl::DoUniform3iv( - GLint location, GLsizei count, const GLint* value) { + GLint fake_location, GLsizei count, const GLint* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform3iv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform3iv", &real_location, &type, &count)) { return; } - glUniform3iv(location, count, value); + glUniform3iv(real_location, count, value); } void GLES2DecoderImpl::DoUniform4iv( - GLint location, GLsizei count, const GLint* value) { + GLint fake_location, GLsizei count, const GLint* value) { GLenum type = 0; - if (!PrepForSetUniformByLocation(location, "glUniform4iv", &type, &count)) { + GLint real_location = -1; + if (!PrepForSetUniformByLocation( + fake_location, "glUniform4iv", &real_location, &type, &count)) { return; } - glUniform4iv(location, count, value); + glUniform4iv(real_location, count, value); } void GLES2DecoderImpl::DoUniformMatrix2fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value) { GLenum type = 0; + GLint real_location = -1; if (!PrepForSetUniformByLocation( - location, "glUniformMatrix2fv", &type, &count)) { + fake_location, "glUniformMatrix2fv", &real_location, &type, &count)) { return; } - glUniformMatrix2fv(location, count, transpose, value); + glUniformMatrix2fv(real_location, count, transpose, value); } void GLES2DecoderImpl::DoUniformMatrix3fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value) { GLenum type = 0; + GLint real_location = -1; if (!PrepForSetUniformByLocation( - location, "glUniformMatrix3fv", &type, &count)) { + fake_location, "glUniformMatrix3fv", &real_location, &type, &count)) { return; } - glUniformMatrix3fv(location, count, transpose, value); + glUniformMatrix3fv(real_location, count, transpose, value); } void GLES2DecoderImpl::DoUniformMatrix4fv( - GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + GLint fake_location, GLsizei count, GLboolean transpose, + const GLfloat* value) { GLenum type = 0; + GLint real_location = -1; if (!PrepForSetUniformByLocation( - location, "glUniformMatrix4fv", &type, &count)) { + fake_location, "glUniformMatrix4fv", &real_location, &type, &count)) { return; } - glUniformMatrix4fv(location, count, transpose, value); + glUniformMatrix4fv(real_location, count, transpose, value); } void GLES2DecoderImpl::DoUseProgram(GLuint program) { @@ -6256,7 +6286,7 @@ error::Error GLES2DecoderImpl::GetUniformLocationHelper( return error::kGenericError; } *location = program_manager()->SwizzleLocation( - info->GetUniformLocation(name_str)); + info->GetUniformFakeLocation(name_str)); return error::kNoError; } @@ -7236,14 +7266,15 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( } bool GLES2DecoderImpl::GetUniformSetup( - GLuint program, GLint location, + GLuint program, GLint fake_location, uint32 shm_id, uint32 shm_offset, - error::Error* error, GLuint* service_id, void** result_pointer, - GLenum* result_type) { + error::Error* error, GLint* real_location, + GLuint* service_id, void** result_pointer, GLenum* result_type) { DCHECK(error); DCHECK(service_id); DCHECK(result_pointer); DCHECK(result_type); + DCHECK(real_location); *error = error::kNoError; // Make sure we have enough room for the result on failure. SizedResult<GLint>* result; @@ -7269,7 +7300,8 @@ bool GLES2DecoderImpl::GetUniformSetup( *service_id = info->service_id(); GLint array_index = -1; const ProgramManager::ProgramInfo::UniformInfo* uniform_info = - info->GetUniformInfoByLocation(location, &array_index); + info->GetUniformInfoByFakeLocation( + fake_location, real_location, &array_index); if (!uniform_info) { // No such location. SetGLError(GL_INVALID_OPERATION, "glGetUniform: unknown location"); @@ -7295,16 +7327,17 @@ bool GLES2DecoderImpl::GetUniformSetup( error::Error GLES2DecoderImpl::HandleGetUniformiv( uint32 immediate_data_size, const gles2::GetUniformiv& c) { GLuint program = c.program; - GLint location = program_manager()->UnswizzleLocation(c.location); + GLint fake_location = program_manager()->UnswizzleLocation(c.location); GLuint service_id; GLenum result_type; + GLint real_location = -1; Error error; void* result; if (GetUniformSetup( - program, location, c.params_shm_id, c.params_shm_offset, - &error, &service_id, &result, &result_type)) { + program, fake_location, c.params_shm_id, c.params_shm_offset, + &error, &real_location, &service_id, &result, &result_type)) { glGetUniformiv( - service_id, location, + service_id, real_location, static_cast<gles2::GetUniformiv::Result*>(result)->GetData()); } return error; @@ -7313,26 +7346,28 @@ error::Error GLES2DecoderImpl::HandleGetUniformiv( error::Error GLES2DecoderImpl::HandleGetUniformfv( uint32 immediate_data_size, const gles2::GetUniformfv& c) { GLuint program = c.program; - GLint location = program_manager()->UnswizzleLocation(c.location); + GLint fake_location = program_manager()->UnswizzleLocation(c.location); GLuint service_id; + GLint real_location = -1; Error error; typedef gles2::GetUniformfv::Result Result; Result* result; GLenum result_type; if (GetUniformSetup( - program, location, c.params_shm_id, c.params_shm_offset, - &error, &service_id, reinterpret_cast<void**>(&result), &result_type)) { + program, fake_location, c.params_shm_id, c.params_shm_offset, + &error, &real_location, &service_id, + reinterpret_cast<void**>(&result), &result_type)) { if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { GLsizei num_values = result->GetNumResults(); scoped_array<GLint> temp(new GLint[num_values]); - glGetUniformiv(service_id, location, temp.get()); + glGetUniformiv(service_id, real_location, temp.get()); GLfloat* dst = result->GetData(); for (GLsizei ii = 0; ii < num_values; ++ii) { dst[ii] = (temp[ii] != 0); } } else { - glGetUniformfv(service_id, location, result->GetData()); + glGetUniformfv(service_id, real_location, result->GetData()); } } return error; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 64869b0..d42c599 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1099,9 +1099,9 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivSucceeds) { result->size = 0; GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); - EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2Location, _)) + EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _)) .Times(1); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), @@ -1114,10 +1114,10 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) { result->size = 0; GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2ElementLocation), + program_manager()->SwizzleLocation(kUniform2ElementFakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, - GetUniformiv(kServiceProgramId, kUniform2ElementLocation, _)) + GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _)) .Times(1); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), @@ -1131,7 +1131,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { GetUniformiv cmd; // non-existant program cmd.Init(kInvalidClientId, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); @@ -1143,7 +1143,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { #if GLES2_TEST_SHADER_VS_PROGRAM_IDS result->size = kInitialResult; cmd.Init(client_shader_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1159,7 +1159,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); result->size = kInitialResult; cmd.Init(kNewClientId, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1184,12 +1184,12 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) { GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kInvalidSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); - cmd.Init(client_program_id_, kUniform2Location, + cmd.Init(client_program_id_, kUniform2FakeLocation, kSharedMemoryId, kInvalidSharedMemoryOffset); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); }; @@ -1200,9 +1200,9 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) { result->size = 0; GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); - EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2Location, _)) + EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _)) .Times(1); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), @@ -1215,10 +1215,10 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) { result->size = 0; GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2ElementLocation), + program_manager()->SwizzleLocation(kUniform2ElementFakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, - GetUniformfv(kServiceProgramId, kUniform2ElementLocation, _)) + GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _)) .Times(1); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), @@ -1232,7 +1232,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { GetUniformfv cmd; // non-existant program cmd.Init(kInvalidClientId, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); @@ -1244,7 +1244,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { #if GLES2_TEST_SHADER_VS_PROGRAM_IDS result->size = kInitialResult; cmd.Init(client_shader_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1259,7 +1259,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { cmd2.Init(kNewClientId); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); result->size = kInitialResult; - cmd.Init(kNewClientId, program_manager()->SwizzleLocation(kUniform2Location), + cmd.Init(kNewClientId, + program_manager()->SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1284,12 +1285,12 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) { GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2Location), + program_manager()->SwizzleLocation(kUniform2FakeLocation), kInvalidSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); - cmd.Init(client_program_id_, kUniform2Location, + cmd.Init(client_program_id_, kUniform2FakeLocation, kSharedMemoryId, kInvalidSharedMemoryOffset); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); }; @@ -1798,18 +1799,18 @@ TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { } TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) { - EXPECT_CALL(*gl_, Uniform1i(kUniform1Location, 2)); + EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2)); Uniform1i cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), 2); + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 2); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { EXPECT_CALL( - *gl_, Uniform1iv(kUniform1Location, 1, + *gl_, Uniform1iv(kUniform1RealLocation, 1, reinterpret_cast<const GLint*>(shared_memory_address_))); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } @@ -1817,7 +1818,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1825,7 +1826,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1834,10 +1835,11 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); EXPECT_CALL( *gl_, - Uniform1iv(kUniform1Location, 1, + Uniform1iv(kUniform1RealLocation, 1, reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); GLint temp[1 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), 1, &temp[0]); + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, + &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); } @@ -1845,7 +1847,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); @@ -1854,7 +1856,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1Location), + cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 0, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -2719,7 +2721,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) { kSharedMemoryId, kSharedMemoryOffset, kNameSize); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2Location), *result); + EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2FakeLocation), *result); memcpy(name, kNonExistentName, kNonExistentNameSize); *result = -1; cmd.Init(client_program_id_, @@ -2800,7 +2802,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationImmediate) { cmd.Init(client_program_id_, kUniform2Name, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kNameSize)); - EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2Location), *result); + EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2FakeLocation), *result); *result = -1; cmd.Init(client_program_id_, kNonExistentName, kSharedMemoryId, kSharedMemoryOffset); @@ -2842,7 +2844,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucket) { cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2Location), *result); + EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2FakeLocation), *result); SetBucketAsCString(kBucketId, kNonExistentName); *result = -1; cmd.Init(client_program_id_, kBucketId, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index 6d0b1b7..8f40d0a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -751,12 +751,13 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform1fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform1fv( - 3, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform1fv, 0>(true); Uniform1fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -833,12 +834,13 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform2fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform2fv( - 3, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform2fv, 0>(true); Uniform2fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -912,12 +914,13 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform2ivValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform2iv( - 3, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform2iv, 0>(true); Uniform2iv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -991,12 +994,13 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform3fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform3fv( - 3, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform3fv, 0>(true); Uniform3fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1070,12 +1074,13 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform3ivValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform3iv( - 3, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform3iv, 0>(true); Uniform3iv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1149,12 +1154,13 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform4fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform4fv( - 3, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform4fv, 0>(true); Uniform4fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1228,12 +1234,13 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_1) { TEST_F(GLES2DecoderTest2, Uniform4ivValidArgsCountTooLarge) { EXPECT_CALL( *gl_, Uniform4iv( - 3, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + 3, 3, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform4iv, 0>(true); Uniform4iv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1311,13 +1318,14 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_1) { TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, UniformMatrix2fv( - 3, 2, false, reinterpret_cast<const GLfloat*>( + 3, 3, false, reinterpret_cast<const GLfloat*>( shared_memory_address_))); SpecializedSetup<UniformMatrix2fv, 0>(true); UniformMatrix2fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1408,13 +1416,14 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_1) { TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, UniformMatrix3fv( - 3, 2, false, reinterpret_cast<const GLfloat*>( + 3, 3, false, reinterpret_cast<const GLfloat*>( shared_memory_address_))); SpecializedSetup<UniformMatrix3fv, 0>(true); UniformMatrix3fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1505,13 +1514,14 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_1) { TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgsCountTooLarge) { EXPECT_CALL( *gl_, UniformMatrix4fv( - 3, 2, false, reinterpret_cast<const GLfloat*>( + 3, 3, false, reinterpret_cast<const GLfloat*>( shared_memory_address_))); SpecializedSetup<UniformMatrix4fv, 0>(true); UniformMatrix4fv cmd; cmd.Init( program_manager()->SwizzleLocation( - 3), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::ProgramInfo::GetFakeLocation( + 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } 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 7f1f6e7..ec5f1dd 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -450,9 +450,11 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearingMulti( void GLES2DecoderTestBase::SetupShaderForUniform() { static AttribInfo attribs[] = { { "foo", 1, GL_FLOAT, 1, }, + { "goo", 1, GL_FLOAT, 2, }, }; static UniformInfo uniforms[] = { - { "bar", 3, GL_INT, 1, }, + { "bar", 1, GL_INT, 0, 2, }, + { "car", 4, GL_INT, 1, 1, }, }; const GLuint kClientVertexShaderId = 5001; const GLuint kServiceVertexShaderId = 6001; @@ -841,10 +843,14 @@ const GLint GLES2DecoderTestBase::kMaxUniformLength; const GLint GLES2DecoderTestBase::kUniform1Size; const GLint GLES2DecoderTestBase::kUniform2Size; const GLint GLES2DecoderTestBase::kUniform3Size; -const GLint GLES2DecoderTestBase::kUniform1Location; -const GLint GLES2DecoderTestBase::kUniform2Location; -const GLint GLES2DecoderTestBase::kUniform2ElementLocation; -const GLint GLES2DecoderTestBase::kUniform3Location; +const GLint GLES2DecoderTestBase::kUniform1RealLocation; +const GLint GLES2DecoderTestBase::kUniform2RealLocation; +const GLint GLES2DecoderTestBase::kUniform2ElementRealLocation; +const GLint GLES2DecoderTestBase::kUniform3RealLocation; +const GLint GLES2DecoderTestBase::kUniform1FakeLocation; +const GLint GLES2DecoderTestBase::kUniform2FakeLocation; +const GLint GLES2DecoderTestBase::kUniform2ElementFakeLocation; +const GLint GLES2DecoderTestBase::kUniform3FakeLocation; const GLenum GLES2DecoderTestBase::kUniform1Type; const GLenum GLES2DecoderTestBase::kUniform2Type; const GLenum GLES2DecoderTestBase::kUniform3Type; @@ -869,9 +875,12 @@ void GLES2DecoderTestBase::SetupDefaultProgram() { { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; static UniformInfo uniforms[] = { - { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1Location, }, - { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2Location, }, - { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3Location, }, + { kUniform1Name, kUniform1Size, kUniform1Type, + kUniform1FakeLocation, kUniform1RealLocation }, + { kUniform2Name, kUniform2Size, kUniform2Type, + kUniform2FakeLocation, kUniform2RealLocation }, + { kUniform3Name, kUniform3Size, kUniform3Type, + kUniform3FakeLocation, kUniform3RealLocation }, }; SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms), client_program_id_, kServiceProgramId, @@ -897,9 +906,12 @@ void GLES2DecoderTestBase::SetupCubemapProgram() { { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; static UniformInfo uniforms[] = { - { kUniform1Name, kUniform1Size, kUniformCubemapType, kUniform1Location, }, - { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2Location, }, - { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3Location, }, + { kUniform1Name, kUniform1Size, kUniformCubemapType, + kUniform1FakeLocation, kUniform1RealLocation, }, + { kUniform2Name, kUniform2Size, kUniform2Type, + kUniform2FakeLocation, kUniform2RealLocation, }, + { kUniform3Name, kUniform3Size, kUniform3Type, + kUniform3FakeLocation, kUniform3RealLocation, }, }; SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms), client_program_id_, kServiceProgramId, @@ -1006,7 +1018,7 @@ void GLES2DecoderTestBase::SetupShader( if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { EXPECT_CALL(*gl_, GetUniformLocation(program_service_id, StrEq(info.name))) - .WillOnce(Return(info.location)) + .WillOnce(Return(info.real_location)) .RetiresOnSaturation(); if (info.size > 1) { std::string base_name = info.name; @@ -1019,7 +1031,7 @@ void GLES2DecoderTestBase::SetupShader( std::string(base_name) + "[" + base::IntToString(jj) + "]"); EXPECT_CALL(*gl_, GetUniformLocation(program_service_id, StrEq(element_name))) - .WillOnce(Return(info.location + jj * 2)) + .WillOnce(Return(info.real_location + jj * 2)) .RetiresOnSaturation(); } } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h index e0c8b46..7217a58 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -101,10 +101,14 @@ class GLES2DecoderTestBase : public testing::Test { static const GLint kUniform1Size = 1; static const GLint kUniform2Size = 3; static const GLint kUniform3Size = 2; - static const GLint kUniform1Location = 3; - static const GLint kUniform2Location = 10; - static const GLint kUniform2ElementLocation = 12; - static const GLint kUniform3Location = 20; + static const GLint kUniform1RealLocation = 3; + static const GLint kUniform2RealLocation = 10; + static const GLint kUniform2ElementRealLocation = 12; + static const GLint kUniform3RealLocation = 20; + static const GLint kUniform1FakeLocation = 0; // These are + static const GLint kUniform2FakeLocation = 1; // hardcoded + static const GLint kUniform2ElementFakeLocation = 0x10001; // to match + static const GLint kUniform3FakeLocation = 2; // ProgramManager. static const GLenum kUniform1Type = GL_SAMPLER_2D; static const GLenum kUniform2Type = GL_INT_VEC2; static const GLenum kUniform3Type = GL_FLOAT_VEC3; @@ -235,7 +239,8 @@ class GLES2DecoderTestBase : public testing::Test { const char* name; GLint size; GLenum type; - GLint location; + GLint fake_location; + GLint real_location; }; void SetupShader( diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index bd56ada..e601aed 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -31,9 +31,11 @@ static int ShaderTypeToIndex(GLenum shader_type) { ProgramManager::ProgramInfo::UniformInfo::UniformInfo( GLsizei _size, GLenum _type, + int _fake_location_base, const std::string& _name) : size(_size), type(_type), + fake_location_base(_fake_location_base), is_array(false), name(_name) { } @@ -64,7 +66,6 @@ void ProgramManager::ProgramInfo::Reset() { uniform_infos_.clear(); sampler_indices_.clear(); attrib_location_to_index_map_.clear(); - location_infos_.clear(); } void ProgramManager::ProgramInfo::UpdateLogInfo() { @@ -128,13 +129,11 @@ void ProgramManager::ProgramInfo::Update() { attrib_location_to_index_map_[info.location] = ii; } - GLint num_uniforms = 0; max_len = 0; + GLint num_uniforms = 0; glGetProgramiv(service_id_, GL_ACTIVE_UNIFORMS, &num_uniforms); glGetProgramiv(service_id_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_len); name_buffer.reset(new char[max_len]); - max_location = -1; - int index = 0; // this index tracks valid uniforms. for (GLint ii = 0; ii < num_uniforms; ++ii) { GLsizei length = 0; GLsizei size = 0; @@ -145,36 +144,19 @@ void ProgramManager::ProgramInfo::Update() { DCHECK(length == 0 || name_buffer[length] == '\0'); // TODO(gman): Should we check for error? if (!IsInvalidPrefix(name_buffer.get(), length)) { - GLint location = glGetUniformLocation(service_id_, name_buffer.get()); + GLint location = glGetUniformLocation(service_id_, name_buffer.get()); std::string name; std::string original_name; GetCorrectedVariableInfo( true, name_buffer.get(), &name, &original_name, &size, &type); - const UniformInfo* info = - AddUniformInfo(size, type, location, name, original_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]; - } - } + const UniformInfo* info = AddUniformInfo( + size, type, location, name, original_name); if (info->IsSampler()) { - sampler_indices_.push_back(index); + sampler_indices_.push_back(info->fake_location_base); } max_uniform_name_length_ = std::max(max_uniform_name_length_, static_cast<GLsizei>(info->name.size())); - ++index; - } - } - // Create uniform location to index map. - location_infos_.resize(max_location + 1); - for (GLint ii = 0; ii <= max_location; ++ii) { - location_infos_[ii] = LocationInfo(-1, -1); - } - for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { - const UniformInfo& info = uniform_infos_[ii]; - for (size_t jj = 0; jj < info.element_locations.size(); ++jj) { - location_infos_[info.element_locations[jj]] = LocationInfo(ii, jj); } } valid_ = true; @@ -206,14 +188,14 @@ void ProgramManager::ProgramInfo::Validate() { UpdateLogInfo(); } -GLint ProgramManager::ProgramInfo::GetUniformLocation( +GLint ProgramManager::ProgramInfo::GetUniformFakeLocation( const std::string& name) const { for (GLuint ii = 0; ii < uniform_infos_.size(); ++ii) { const UniformInfo& info = uniform_infos_[ii]; if (info.name == name || (info.is_array && info.name.compare(0, info.name.size() - 3, name) == 0)) { - return info.element_locations[0]; + return info.fake_location_base; } else if (info.is_array && name.size() >= 3 && name[name.size() - 1] == ']') { // Look for an array specification. @@ -234,7 +216,7 @@ GLint ProgramManager::ProgramInfo::GetUniformLocation( index = index * 10 + digit; } if (!bad && index >= 0 && index < info.size) { - return info.element_locations[index]; + return GetFakeLocation(info.fake_location_base, index); } } } @@ -254,14 +236,23 @@ GLint ProgramManager::ProgramInfo::GetAttribLocation( } const ProgramManager::ProgramInfo::UniformInfo* - ProgramManager::ProgramInfo::GetUniformInfoByLocation( - GLint location, GLint* array_index) const { + ProgramManager::ProgramInfo::GetUniformInfoByFakeLocation( + GLint fake_location, GLint* real_location, GLint* array_index) const { + DCHECK(real_location); DCHECK(array_index); - if (location >= 0 && static_cast<size_t>(location) < location_infos_.size()) { - const LocationInfo& info = location_infos_[location]; - if (info.uniform_index >= 0) { - *array_index = info.array_index; - return &uniform_infos_[info.uniform_index]; + if (fake_location < 0) { + return NULL; + } + + GLint uniform_index = GetUniformInfoIndexFromFakeLocation(fake_location); + if (uniform_index >= 0 && + static_cast<size_t>(uniform_index) < uniform_infos_.size()) { + const UniformInfo& uniform_info = uniform_infos_[uniform_index]; + GLint element_index = GetArrayElementIndexFromFakeLocation(fake_location); + if (element_index < uniform_info.size) { + *real_location = uniform_info.element_locations[element_index]; + *array_index = element_index; + return &uniform_info; } } return NULL; @@ -306,10 +297,12 @@ void ProgramManager::ProgramInfo::GetCorrectedVariableInfo( const ProgramManager::ProgramInfo::UniformInfo* ProgramManager::ProgramInfo::AddUniformInfo( - GLsizei size, GLenum type, GLint location, const std::string& name, - const std::string& original_name) { + GLsizei size, GLenum type, GLint location, + const std::string& name, const std::string& original_name) { const char* kArraySpec = "[0]"; - uniform_infos_.push_back(UniformInfo(size, type, original_name)); + int uniform_index = uniform_infos_.size(); + uniform_infos_.push_back( + UniformInfo(size, type, uniform_index, original_name)); UniformInfo& info = uniform_infos_.back(); info.element_locations.resize(size); info.element_locations[0] = location; @@ -347,15 +340,20 @@ const ProgramManager::ProgramInfo::UniformInfo* } bool ProgramManager::ProgramInfo::SetSamplers( - GLint location, GLsizei count, const GLint* value) { - if (location >= 0 && static_cast<size_t>(location) < location_infos_.size()) { - const LocationInfo& location_info = location_infos_[location]; - if (location_info.uniform_index >= 0) { - UniformInfo& info = uniform_infos_[location_info.uniform_index]; - count = std::min(info.size - location_info.array_index, count); + GLint fake_location, GLsizei count, const GLint* value) { + if (fake_location < 0) { + return false; + } + GLint uniform_index = GetUniformInfoIndexFromFakeLocation(fake_location); + if (uniform_index >= 0 && + static_cast<size_t>(uniform_index) < uniform_infos_.size()) { + UniformInfo& info = uniform_infos_[uniform_index]; + GLint element_index = GetArrayElementIndexFromFakeLocation(fake_location); + if (element_index < info.size) { + count = std::min(info.size - element_index, count); if (info.IsSampler() && count > 0) { std::copy(value, value + count, - info.texture_units.begin() + location_info.array_index); + info.texture_units.begin() + element_index); return true; } } @@ -516,7 +514,7 @@ void ProgramManager::ProgramInfo::GetProgramInfo( inputs->name_length = info.name.size(); DCHECK(static_cast<size_t>(info.size) == info.element_locations.size()); for (size_t jj = 0; jj < info.element_locations.size(); ++jj) { - *locations++ = manager->SwizzleLocation(info.element_locations[jj]); + *locations++ = manager->SwizzleLocation(ii + jj * 0x10000); } memcpy(strings, info.name.c_str(), info.name.size()); strings += info.name.size(); @@ -637,11 +635,11 @@ void ProgramManager::UnuseProgram( // Swizzles the locations to prevent developers from assuming they // can do math on uniforms. According to the OpenGL ES 2.0 spec -// the location of "someuniform[1]" is not 1 more than "someuniform[0]". +// the location of "someuniform[1]" is not 'n' more than "someuniform[0]". static GLint Swizzle(GLint location) { - return (location & 0xFFFF0000U) | - ((location & 0x0000AAAAU) >> 1) | - ((location & 0x00005555U) << 1); + return (location & 0xF0000000U) | + ((location & 0x0AAAAAAAU) >> 1) | + ((location & 0x05555555U) << 1); } // Adds uniform_swizzle_ to prevent developers from assuming that locations are diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h index e53e00c..77b9065 100644 --- a/gpu/command_buffer/service/program_manager.h +++ b/gpu/command_buffer/service/program_manager.h @@ -35,7 +35,9 @@ class ProgramManager { static const int kMaxAttachedShaders = 2; struct UniformInfo { - UniformInfo(GLsizei _size, GLenum _type, const std::string& _name); + UniformInfo( + GLsizei _size, GLenum _type, GLint _fake_location_base, + const std::string& _name); ~UniformInfo(); bool IsSampler() const { @@ -45,6 +47,7 @@ class ProgramManager { GLsizei size; GLenum type; + GLint fake_location_base; bool is_array; std::string name; std::vector<GLint> element_locations; @@ -104,12 +107,12 @@ class ProgramManager { &uniform_infos_[index] : NULL; } - // Gets the location of a uniform by name. - GLint GetUniformLocation(const std::string& name) const; + // Gets the fake location of a uniform by name. + GLint GetUniformFakeLocation(const std::string& name) const; // Gets the UniformInfo of a uniform by location. - const UniformInfo* GetUniformInfoByLocation( - GLint location, GLint* array_index) const; + const UniformInfo* GetUniformInfoByFakeLocation( + GLint fake_location, GLint* real_location, GLint* array_index) const; // Gets all the program info. void GetProgramInfo( @@ -118,7 +121,7 @@ class ProgramManager { // Sets the sampler values for a uniform. // This is safe to call for any location. If the location is not // a sampler uniform nothing will happen. - bool SetSamplers(GLint location, GLsizei count, const GLint* value); + bool SetSamplers(GLint fake_location, GLsizei count, const GLint* value); bool IsDeleted() const { return service_id_ == 0; @@ -150,24 +153,15 @@ class ProgramManager { return use_count_ != 0; } + static inline GLint GetFakeLocation( + GLint fake_base_location, GLint element_index) { + return fake_base_location | element_index << 16; + } + private: friend class base::RefCounted<ProgramInfo>; friend class ProgramManager; - // Info for each location - struct LocationInfo { - LocationInfo() - : uniform_index(-1), - array_index(-1) { - } - LocationInfo(GLint _uniform_index, GLint _array_index) - : uniform_index(_uniform_index), - array_index(_array_index) { - } - GLint uniform_index; // index of UniformInfo in uniform_infos_. - GLint array_index; // index of location when used in array. - }; - ~ProgramInfo(); void set_log_info(const char* str) { @@ -202,8 +196,8 @@ class ProgramManager { void UpdateLogInfo(); const UniformInfo* AddUniformInfo( - GLsizei size, GLenum type, GLint location, const std::string& name, - const std::string& original_name); + GLsizei size, GLenum type, GLint location, + const std::string& name, const std::string& original_name); void GetCorrectedVariableInfo( bool use_uniforms, const std::string& name, std::string* corrected_name, @@ -211,6 +205,16 @@ class ProgramManager { void DetachShaders(ShaderManager* manager); + static inline GLint GetUniformInfoIndexFromFakeLocation( + GLint fake_location) { + return fake_location & 0xFFFF; + } + + static inline GLint GetArrayElementIndexFromFakeLocation( + GLint fake_location) { + return (fake_location >> 16) & 0xFFFF; + } + int use_count_; GLsizei max_attrib_name_length_; @@ -226,9 +230,6 @@ class ProgramManager { // Uniform info by index. UniformInfoVector uniform_infos_; - // Info for each location. - std::vector<LocationInfo> location_infos_; - // The indices of the uniforms that are samplers. SamplerIndices sampler_indices_; diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc index c72bc93..9ac98fd 100644 --- a/gpu/command_buffer/service/program_manager_unittest.cc +++ b/gpu/command_buffer/service/program_manager_unittest.cc @@ -178,9 +178,12 @@ class ProgramManagerWithShaderTest : public testing::Test { static const GLint kUniform1Size = 1; static const GLint kUniform2Size = 3; static const GLint kUniform3Size = 2; - static const GLint kUniform1Location = 3; - static const GLint kUniform2Location = 10; - static const GLint kUniform3Location = 20; + static const GLint kUniform1FakeLocation = 0; // These are hard coded + static const GLint kUniform2FakeLocation = 1; // to match + static const GLint kUniform3FakeLocation = 2; // ProgramManager. + static const GLint kUniform1RealLocation = 11; + static const GLint kUniform2RealLocation = 22; + static const GLint kUniform3RealLocation = 33; static const GLenum kUniform1Type = GL_FLOAT_VEC4; static const GLenum kUniform2Type = GL_INT_VEC2; static const GLenum kUniform3Type = GL_FLOAT_VEC3; @@ -203,7 +206,8 @@ class ProgramManagerWithShaderTest : public testing::Test { const char* good_name; GLint size; GLenum type; - GLint location; + GLint fake_location; + GLint real_location; }; virtual void SetUp() { @@ -309,7 +313,7 @@ class ProgramManagerWithShaderTest : public testing::Test { if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { EXPECT_CALL(*gl_, GetUniformLocation(service_id, StrEq(info.name))) - .WillOnce(Return(info.location)) + .WillOnce(Return(info.real_location)) .RetiresOnSaturation(); if (info.size > 1) { std::string base_name = info.name; @@ -322,7 +326,7 @@ class ProgramManagerWithShaderTest : public testing::Test { std::string(base_name) + "[" + base::IntToString(jj) + "]"); EXPECT_CALL(*gl_, GetUniformLocation(service_id, StrEq(element_name))) - .WillOnce(Return(info.location + jj * 2)) + .WillOnce(Return(info.real_location + jj * 2)) .RetiresOnSaturation(); } } @@ -380,9 +384,12 @@ const GLint ProgramManagerWithShaderTest::kBadAttribIndex; const GLint ProgramManagerWithShaderTest::kUniform1Size; const GLint ProgramManagerWithShaderTest::kUniform2Size; const GLint ProgramManagerWithShaderTest::kUniform3Size; -const GLint ProgramManagerWithShaderTest::kUniform1Location; -const GLint ProgramManagerWithShaderTest::kUniform2Location; -const GLint ProgramManagerWithShaderTest::kUniform3Location; +const GLint ProgramManagerWithShaderTest::kUniform1FakeLocation; +const GLint ProgramManagerWithShaderTest::kUniform2FakeLocation; +const GLint ProgramManagerWithShaderTest::kUniform3FakeLocation; +const GLint ProgramManagerWithShaderTest::kUniform1RealLocation; +const GLint ProgramManagerWithShaderTest::kUniform2RealLocation; +const GLint ProgramManagerWithShaderTest::kUniform3RealLocation; const GLenum ProgramManagerWithShaderTest::kUniform1Type; const GLenum ProgramManagerWithShaderTest::kUniform2Type; const GLenum ProgramManagerWithShaderTest::kUniform3Type; @@ -399,19 +406,22 @@ ProgramManagerWithShaderTest::UniformInfo kUniform1Name, kUniform1Size, kUniform1Type, - kUniform1Location, + kUniform1FakeLocation, + kUniform1RealLocation, }, { kUniform2Name, kUniform2Name, kUniform2Size, kUniform2Type, - kUniform2Location, + kUniform2FakeLocation, + kUniform2RealLocation, }, { kUniform3BadName, kUniform3GoodName, kUniform3Size, kUniform3Type, - kUniform3Location, + kUniform3FakeLocation, + kUniform3RealLocation, }, }; @@ -480,13 +490,13 @@ TEST_F(ProgramManagerWithShaderTest, GetUniformInfo) { ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform1Size, info->size); EXPECT_EQ(kUniform1Type, info->type); - EXPECT_EQ(kUniform1Location, info->element_locations[0]); + EXPECT_EQ(kUniform1RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform1Name, info->name.c_str()); info = program_info->GetUniformInfo(1); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform2Size, info->size); EXPECT_EQ(kUniform2Type, info->type); - EXPECT_EQ(kUniform2Location, info->element_locations[0]); + EXPECT_EQ(kUniform2RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform2Name, info->name.c_str()); info = program_info->GetUniformInfo(2); // We emulate certain OpenGL drivers by supplying the name without @@ -494,7 +504,7 @@ TEST_F(ProgramManagerWithShaderTest, GetUniformInfo) { ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform3Size, info->size); EXPECT_EQ(kUniform3Type, info->type); - EXPECT_EQ(kUniform3Location, info->element_locations[0]); + EXPECT_EQ(kUniform3RealLocation, info->element_locations[0]); EXPECT_STREQ(kUniform3GoodName, info->name.c_str()); EXPECT_TRUE(program_info->GetUniformInfo(kInvalidIndex) == NULL); } @@ -544,54 +554,64 @@ TEST_F(ProgramManagerWithShaderTest, AttachDetachShader) { EXPECT_FALSE(program_info->DetachShader(&shader_manager_, fshader)); } -TEST_F(ProgramManagerWithShaderTest, GetUniformLocation) { +TEST_F(ProgramManagerWithShaderTest, GetUniformFakeLocation) { const ProgramManager::ProgramInfo* program_info = manager_.GetProgramInfo(kClientProgramId); ASSERT_TRUE(program_info != NULL); - EXPECT_EQ(kUniform1Location, program_info->GetUniformLocation(kUniform1Name)); - EXPECT_EQ(kUniform2Location, program_info->GetUniformLocation(kUniform2Name)); - EXPECT_EQ(kUniform3Location, program_info->GetUniformLocation( - kUniform3BadName)); + EXPECT_EQ(kUniform1FakeLocation, + program_info->GetUniformFakeLocation(kUniform1Name)); + EXPECT_EQ(kUniform2FakeLocation, + program_info->GetUniformFakeLocation(kUniform2Name)); + EXPECT_EQ(kUniform3FakeLocation, + program_info->GetUniformFakeLocation(kUniform3BadName)); // Check we can get uniform2 as "uniform2" even though the name is // "uniform2[0]" - EXPECT_EQ(kUniform2Location, program_info->GetUniformLocation("uniform2")); + EXPECT_EQ(kUniform2FakeLocation, + program_info->GetUniformFakeLocation("uniform2")); // Check we can get uniform3 as "uniform3[0]" even though we simulated GL // returning "uniform3" - EXPECT_EQ(kUniform3Location, program_info->GetUniformLocation( - kUniform3GoodName)); + EXPECT_EQ(kUniform3FakeLocation, + program_info->GetUniformFakeLocation(kUniform3GoodName)); // Check that we can get the locations of the array elements > 1 - EXPECT_EQ(kUniform2Location + 2, - program_info->GetUniformLocation("uniform2[1]")); - EXPECT_EQ(kUniform2Location + 4, - program_info->GetUniformLocation("uniform2[2]")); - EXPECT_EQ(-1, - program_info->GetUniformLocation("uniform2[3]")); - EXPECT_EQ(kUniform3Location + 2, - program_info->GetUniformLocation("uniform3[1]")); - EXPECT_EQ(-1, - program_info->GetUniformLocation("uniform3[2]")); + EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( + kUniform2FakeLocation, 1), + program_info->GetUniformFakeLocation("uniform2[1]")); + EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( + kUniform2FakeLocation, 2), + program_info->GetUniformFakeLocation("uniform2[2]")); + EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform2[3]")); + EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( + kUniform3FakeLocation, 1), + program_info->GetUniformFakeLocation("uniform3[1]")); + EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform3[2]")); } -TEST_F(ProgramManagerWithShaderTest, GetUniformInfoByLocation) { +TEST_F(ProgramManagerWithShaderTest, GetUniformInfoByFakeLocation) { const GLint kInvalidLocation = 1234; const ProgramManager::ProgramInfo::UniformInfo* info; const ProgramManager::ProgramInfo* program_info = manager_.GetProgramInfo(kClientProgramId); + GLint real_location = -1; GLint array_index = -1; ASSERT_TRUE(program_info != NULL); - info = program_info->GetUniformInfoByLocation( - kUniform2Location, &array_index); + info = program_info->GetUniformInfoByFakeLocation( + kUniform2FakeLocation, &real_location, &array_index); + EXPECT_EQ(kUniform2RealLocation, real_location); EXPECT_EQ(0, array_index); ASSERT_TRUE(info != NULL); EXPECT_EQ(kUniform2Type, info->type); + real_location = -1; array_index = -1; - info = program_info->GetUniformInfoByLocation( - kInvalidLocation, &array_index); + info = program_info->GetUniformInfoByFakeLocation( + kInvalidLocation, &real_location, &array_index); EXPECT_TRUE(info == NULL); + EXPECT_EQ(-1, real_location); EXPECT_EQ(-1, array_index); - GLint loc = program_info->GetUniformLocation("uniform2[2]"); - info = program_info->GetUniformInfoByLocation(loc, &array_index); + GLint loc = program_info->GetUniformFakeLocation("uniform2[2]"); + info = program_info->GetUniformInfoByFakeLocation( + loc, &real_location, &array_index); ASSERT_TRUE(info != NULL); + EXPECT_EQ(kUniform2RealLocation + 2 * 2, real_location); EXPECT_EQ(2, array_index); } @@ -605,19 +625,22 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { kUniform1Name, kUniform1Size, kUniform1Type, - kUniform1Location, + kUniform1FakeLocation, + kUniform1RealLocation, }, { kUniform2Name, kUniform2Name, kUniform2Size, kUniform2Type, - kUniform2Location, + kUniform2FakeLocation, + kUniform2RealLocation, }, { kUniform3BadName, kUniform3GoodName, kUniform3Size, kUniform3Type, - kUniform3Location, + kUniform3FakeLocation, + kUniform3RealLocation, }, }; const size_t kNumUniforms = arraysize(kUniforms); @@ -704,19 +727,22 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { kUniform1Name, kUniform1Size, kUniform1Type, - kUniform1Location, + kUniform1FakeLocation, + kUniform1RealLocation, }, { kUniform2Name, kUniform2Name, kUniform2Size, kUniform2BadType, - kUniform2Location, + kUniform2FakeLocation, + kUniform2RealLocation, }, { kUniform3BadName, kUniform3GoodName, kUniform3Size, kUniform3Type, - kUniform3Location, + kUniform3FakeLocation, + kUniform3RealLocation, }, }; const size_t kNumAttribs= arraysize(kAttribs); @@ -896,8 +922,10 @@ TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetProgramInfo) { input->location_offset, sizeof(int32) * input->size); ASSERT_TRUE(locations != NULL); for (int32 jj = 0; jj < input->size; ++jj) { - EXPECT_EQ(manager_.SwizzleLocation(expected.location + jj * 2), - locations[jj]); + EXPECT_EQ(manager_.SwizzleLocation( + ProgramManager::ProgramInfo::GetFakeLocation( + expected.fake_location, jj)), + locations[jj]); } const char* name_buf = bucket.GetDataAs<const char*>( input->name_offset, input->name_length); |