diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:44:58 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:44:58 +0000 |
commit | 3f00df9a392791d70409df5b217642a1990f52b6 (patch) | |
tree | 753d407c73e9d651094f88d632d901d22a3b77d0 /gpu | |
parent | ce8b05730722ba50d9cb6877adef9f53258dd9ca (diff) | |
download | chromium_src-3f00df9a392791d70409df5b217642a1990f52b6.zip chromium_src-3f00df9a392791d70409df5b217642a1990f52b6.tar.gz chromium_src-3f00df9a392791d70409df5b217642a1990f52b6.tar.bz2 |
Add support for GL_CHROMIUM_consistent_uniform_locations
BUG=132844
TEST=unit tests
Review URL: https://chromiumcodereview.appspot.com/10568003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
21 files changed, 698 insertions, 252 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt new file mode 100644 index 0000000..8a7d163 --- /dev/null +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt @@ -0,0 +1,86 @@ +Name + + CHROMIUM_consistent_uniform_locations + +Name Strings + + GL_CHROMIUM_consistent_uniform_locations + +Version + + Last Modifed Date: June 17, 2012 + +Dependencies + + OpenGL ES 2.0 is required. + +Overview + + This extension guarantees uniforms always have the same locations. + + This allows the client program to know the locations of uniforms + without having to compile the shaders, link the program and query + the locations and therefore have no blocking calls when initializing + programs. + + To be forward compatible the locations are provided through the + function GetUniformLocationsCHROMIUM but they can be provided + even before linking a program and therefore do not have to wait + for compile or link completion to return results. + +Issues + + If a uniform is unused in the actual program it may be optimized out + by the GL driver. In this case the locations will be wrong. You + must provide a list of only the used uniforms. + +New Tokens + + None + +New Procedures and Functions + + void GetUniformLocationsCHROMIUM (const GLUniformDefinitionCHROMIUM* uniforms, + GLsizei count, GLsizei max_locations, + GLint* locations); + + Provides the locations of uniforms assuming the list of uniforms provided + matches the uniforms actually used in the corresponding program. + + <uniforms> is an array of uniforms. <count> is the number of uniforms in the + array. <max_locations> is the maximum number of locations to write to + <locations>. <locations> is an array to receive the uniform locations. + + INVALID_VALUE is generated if <count> is less then or equal to 0. + + INVALID_VALUE is generated if any GLUniformDefinitionHCHROMIUM's size + field is <= 0. + + For each uniform <size> locations are provided. For example: + + static const GLUniformDefinitionCHROMIUM defs[] = { + { GL_FLOAT_VEC2, 3, "someUniform", }, // An array of 3 vec2s + { GL_FLOAT_VEC4, 1, "someOtherUniform", }, // A single vec4 + { GL_SAMPLER_2D, 2, "yetAnotherUniform", }, // An array of 2 sampler2Ds + }; + + Would return an array of locations as follows + + location[0] = location for "someUniform[0]" + location[1] = location for "someUniform[1]" + location[2] = location for "someUniform[2]" + location[3] = location for "someOtherUniform" + location[4] = location for "yetAnotherUniform[0]" + location[5] = location for "yetAnotherUniform[1]" + +Errors + + None. + +New State + + None. + +Revision History + + 7/17/2012 Documented the extension diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 14e0a69..9d14137 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1697,6 +1697,12 @@ _FUNCTION_INFO = { 'gl_test_func': 'glGetQueryObjectuiv', 'pepper_interface': 'Query', }, + 'GetUniformLocationsCHROMIUM': { + 'gen_cmd': False, + 'extension': True, + 'chromium': True, + 'client_test': False, + }, } @@ -3828,8 +3834,8 @@ TEST_F(%(test_name)s, %(name)sValidArgsCountTooLarge) { # defined in GLES2DecoderBase::SetupShaderForUniform gl_arg_strings.append("3") arg_strings.append( - "program_manager()->SwizzleLocation(ProgramManager::" - "ProgramInfo::GetFakeLocation(1, 1))") + "GLES2Util::SwizzleLocation(" + "GLES2Util::MakeFakeLocation(1, 1))") elif count == 1: # the number of elements that gl will be called with. gl_arg_strings.append("3") @@ -4685,14 +4691,14 @@ class UniformLocationArgument(Argument): def WriteGetCode(self, file): """Writes the code to get an argument from a command structure.""" - code = """ %s %s = program_manager()->UnswizzleLocation( + code = """ %s %s = GLES2Util::UnswizzleLocation( static_cast<%s>(c.%s)); """ file.Write(code % (self.type, self.name, self.type, self.name)) def GetValidArg(self, func, offset, index): """Gets a valid value for this argument.""" - return "program_manager()->SwizzleLocation(%d)" % (offset + 1) + return "GLES2Util::SwizzleLocation(%d)" % (offset + 1) class DataSizeArgument(Argument): diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index a9e07fa..22016bd 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -651,6 +651,12 @@ void GLES2ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { void GLES2ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { gles2::GetGLContext()->ConsumeTextureCHROMIUM(target, mailbox); } +void GLES2GetUniformLocationsCHROMIUM( + const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, + GLsizei max_locations, GLint* locations) { + gles2::GetGLContext()->GetUniformLocationsCHROMIUM( + uniforms, count, max_locations, locations); +} #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 5d46196..575d180 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -6,9 +6,10 @@ #include "../client/gles2_implementation.h" +#include <algorithm> #include <map> -#include <set> #include <queue> +#include <set> #include <GLES2/gl2ext.h> #include "../client/mapped_memory.h" #include "../client/program_info_manager.h" @@ -2090,6 +2091,7 @@ const GLubyte* GLES2Implementation::GetStringHelper(GLenum name) { str += std::string(str.empty() ? "" : " ") + "GL_CHROMIUM_map_sub " "GL_CHROMIUM_flipy " + "GL_CHROMIUM_consistent_uniform_locations " "GL_EXT_unpack_subimage"; break; default: @@ -3276,5 +3278,76 @@ void GLES2Implementation::GenMailboxCHROMIUM( std::copy(result.begin(), result.end(), mailbox); } +namespace { + +class GLUniformDefinitionComparer { + public: + explicit GLUniformDefinitionComparer( + const GLUniformDefinitionCHROMIUM* uniforms) + : uniforms_(uniforms) { + } + + bool operator()(const GLint lhs, const GLint rhs) const { + return strcmp(uniforms_[lhs].name, uniforms_[rhs].name) < 0; + } + + private: + const GLUniformDefinitionCHROMIUM* uniforms_; +}; + +} // anonymous namespace. + +void GLES2Implementation::GetUniformLocationsCHROMIUM( + const GLUniformDefinitionCHROMIUM* uniforms, + GLsizei count, + GLsizei max_locations, + GLint* locations) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << this << "] glGenUniformLocationsCHROMIUM(" + << static_cast<const void*>(uniforms) << ", " << count << ", " + << max_locations << ", " << static_cast<const void*>(locations) << ")"); + + if (count <= 0) { + SetGLError(GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "count <= 0"); + return; + } + + for (GLsizei ii = 0; ii < count; ++ii) { + const GLUniformDefinitionCHROMIUM& def = uniforms[ii]; + if (def.size <= 0) { + SetGLError( + GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "size <= 0"); + return; + } + } + + scoped_array<GLint> indices(new GLint[count]); + for (GLint ii = 0; ii < count; ++ii) { + indices[ii] = ii; + } + + std::sort(&indices[0], &indices[count], + GLUniformDefinitionComparer(uniforms)); + + scoped_array<GLint> reverse_map(new GLint[count]); + + for (GLint ii = 0; ii < count; ++ii) { + reverse_map[indices[ii]] = ii; + } + + for (GLsizei ii = 0; ii < count; ++ii) { + const GLUniformDefinitionCHROMIUM& def = uniforms[ii]; + GLint base_location = reverse_map[ii]; + for (GLsizei jj = 0; jj < def.size; ++jj) { + if (max_locations <= 0) { + return; + } + *locations++ = GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation(base_location, jj)); + --max_locations; + } + } +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index b8c3da1..bf68273 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -75,6 +75,8 @@ GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); +struct GLUniformDefinitionCHROMIUM; + namespace gpu { class MappedMemoryManager; diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index c3b7375..d756ea3 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1559,5 +1559,9 @@ void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { helper_->ConsumeTextureCHROMIUMImmediate(target, mailbox); } +void GetUniformLocationsCHROMIUM( + const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, + GLsizei max_locations, GLint* locations); + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index f406c46..38d651b 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -2293,7 +2293,11 @@ TEST_F(GLES2ImplementationTest, GetString) { // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into // GLES2Implementation. const char* expected_str = - "foobar GL_CHROMIUM_map_sub GL_CHROMIUM_flipy GL_EXT_unpack_subimage"; + "foobar " + "GL_CHROMIUM_map_sub " + "GL_CHROMIUM_flipy " + "GL_CHROMIUM_consistent_uniform_locations " + "GL_EXT_unpack_subimage"; const char kBad = 0x12; struct Cmds { cmd::SetBucketSize set_bucket_size1; @@ -2554,6 +2558,64 @@ TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { EXPECT_EQ(0u, available); } +TEST_F(GLES2ImplementationTest, GetUniformLocationsCHROMIUM) { + static const GLUniformDefinitionCHROMIUM good_defs[] = { + { GL_FLOAT_VEC4, 1, "moo", }, + { GL_FLOAT_VEC4, 4, "bar", }, + { GL_FLOAT_VEC4, 3, "foo", }, + }; + + static const GLUniformDefinitionCHROMIUM bad_defs[] = { + { GL_FLOAT_VEC4, 1, "moo", }, + { GL_FLOAT_VEC4, 0, "bar", }, + { GL_FLOAT_VEC4, 3, "foo", }, + }; + + // Test bad count + GLint locations[50] = { -1, }; + gl_->GetUniformLocationsCHROMIUM(bad_defs, 0, 1, locations); + EXPECT_EQ(GL_INVALID_VALUE, CheckError()); + EXPECT_EQ(-1, locations[0]); + + // Test bad size. + gl_->GetUniformLocationsCHROMIUM( + bad_defs, arraysize(bad_defs), 1, locations); + EXPECT_EQ(GL_INVALID_VALUE, CheckError()); + EXPECT_EQ(-1, locations[0]); + + // Test max_locations + gl_->GetUniformLocationsCHROMIUM( + good_defs, arraysize(good_defs), 3, locations); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(2, 0)), + locations[0]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 0)), + locations[1]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 1)), + locations[2]); + EXPECT_EQ(0, locations[3]); + + // Test all. + gl_->GetUniformLocationsCHROMIUM( + good_defs, arraysize(good_defs), arraysize(locations), locations); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(2, 0)), + locations[0]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 0)), + locations[1]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 1)), + locations[2]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 2)), + locations[3]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 3)), + locations[4]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 0)), + locations[5]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 1)), + locations[6]); + EXPECT_EQ(GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 2)), + locations[7]); + EXPECT_EQ(0, locations[8]); +} + #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" } // namespace gles2 diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt index c49b35e..5e36578 100644 --- a/gpu/command_buffer/cmd_buffer_functions.txt +++ b/gpu/command_buffer/cmd_buffer_functions.txt @@ -185,3 +185,5 @@ GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GL GL_APICALL void GL_APIENTRY glGenMailboxCHROMIUM (GLbyte* mailbox); GL_APICALL void GL_APIENTRY glProduceTextureCHROMIUM (GLenumTextureTarget target, const GLbyte* mailbox); GL_APICALL void GL_APIENTRY glConsumeTextureCHROMIUM (GLenumTextureTarget target, const GLbyte* mailbox); +GL_APICALL void GL_APIENTRY glGetUniformLocationsCHROMIUM (const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, GLsizei max_locations, GLint* locations); + diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index ea0bd73..5cecd2e 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -758,6 +758,29 @@ bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) { return true; } +// 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]". +static int32 Swizzle(int32 location) { + return (location & 0xF0000000U) | + ((location & 0x0AAAAAAAU) >> 1) | + ((location & 0x05555555U) << 1); +} + +// Adds uniform_swizzle_ to prevent developers from assuming that locations are +// always the same across GPUs and drivers. +int32 GLES2Util::SwizzleLocation(int32 v) { + return v < 0 ? v : Swizzle(v); +} + +int32 GLES2Util::UnswizzleLocation(int32 v) { + return v < 0 ? v : Swizzle(v); +} + +int32 GLES2Util::MakeFakeLocation(int32 index, int32 element) { + return index + element * 0x10000; +} + #include "../common/gles2_cmd_utils_implementation_autogen.h" } // namespace gles2 diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index c4fe663..859066e 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -146,6 +146,10 @@ class GLES2_UTILS_EXPORT GLES2Util { static std::string GetStringBool(uint32 value); static std::string GetStringError(uint32 value); + static int32 SwizzleLocation(int32 unswizzled_location); + static int32 UnswizzleLocation(int32 swizzled_location); + static int32 MakeFakeLocation(int32 index, int32 element); + #include "../common/gles2_cmd_utils_autogen.h" private: diff --git a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc index 277461a..6fc3b3d 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -181,6 +181,17 @@ TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) { EXPECT_EQ(0u, GLES2Util::RenderbufferBytesPerPixel(-1)); } +TEST_F(GLES2UtilTest, SwizzleLocation) { + GLint power = 1; + for (GLint p = 0; p < 5; ++p, power *= 10) { + GLint limit = power * 20 + 1; + for (GLint ii = -limit; ii < limit; ii += power) { + GLint s = GLES2Util::SwizzleLocation(ii); + EXPECT_EQ(ii, GLES2Util::UnswizzleLocation(s)); + } + } +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 3182df8..091b96b 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -4929,7 +4929,7 @@ void GLES2DecoderImpl::LogMessage(const std::string& msg) { // LOG this unless logging is turned off as any chromium code that // generates these errors probably has a bug. if (log_synthesized_gl_errors()) { - LOG(ERROR) << last_error_; + LOG(ERROR) << msg; } if (!msg_callback_.is_null()) { msg_callback_.Run(0, msg); @@ -6504,7 +6504,7 @@ error::Error GLES2DecoderImpl::GetUniformLocationHelper( if (*location != -1) { return error::kGenericError; } - *location = program_manager()->SwizzleLocation( + *location = GLES2Util::SwizzleLocation( info->GetUniformFakeLocation(name_str)); return error::kNoError; } @@ -7813,7 +7813,7 @@ bool GLES2DecoderImpl::GetUniformSetup( error::Error GLES2DecoderImpl::HandleGetUniformiv( uint32 immediate_data_size, const gles2::GetUniformiv& c) { GLuint program = c.program; - GLint fake_location = program_manager()->UnswizzleLocation(c.location); + GLint fake_location = GLES2Util::UnswizzleLocation(c.location); GLuint service_id; GLenum result_type; GLint real_location = -1; @@ -7832,7 +7832,7 @@ error::Error GLES2DecoderImpl::HandleGetUniformiv( error::Error GLES2DecoderImpl::HandleGetUniformfv( uint32 immediate_data_size, const gles2::GetUniformfv& c) { GLuint program = c.program; - GLint fake_location = program_manager()->UnswizzleLocation(c.location); + GLint fake_location = GLES2Util::UnswizzleLocation(c.location); GLuint service_id; GLint real_location = -1; Error error; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index cf8069b..edddf8a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1757,7 +1757,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterivImmediate( error::Error GLES2DecoderImpl::HandleUniform1f( uint32 immediate_data_size, const gles2::Uniform1f& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLfloat x = static_cast<GLfloat>(c.x); GLfloat temp[1] = { x, }; @@ -1767,7 +1767,7 @@ error::Error GLES2DecoderImpl::HandleUniform1f( error::Error GLES2DecoderImpl::HandleUniform1fv( uint32 immediate_data_size, const gles2::Uniform1fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1785,7 +1785,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fv( error::Error GLES2DecoderImpl::HandleUniform1fvImmediate( uint32 immediate_data_size, const gles2::Uniform1fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1806,7 +1806,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fvImmediate( error::Error GLES2DecoderImpl::HandleUniform1i( uint32 immediate_data_size, const gles2::Uniform1i& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLint x = static_cast<GLint>(c.x); DoUniform1i(location, x); @@ -1815,7 +1815,7 @@ error::Error GLES2DecoderImpl::HandleUniform1i( error::Error GLES2DecoderImpl::HandleUniform1iv( uint32 immediate_data_size, const gles2::Uniform1iv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1833,7 +1833,7 @@ error::Error GLES2DecoderImpl::HandleUniform1iv( error::Error GLES2DecoderImpl::HandleUniform1ivImmediate( uint32 immediate_data_size, const gles2::Uniform1ivImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1854,7 +1854,7 @@ error::Error GLES2DecoderImpl::HandleUniform1ivImmediate( error::Error GLES2DecoderImpl::HandleUniform2f( uint32 immediate_data_size, const gles2::Uniform2f& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); @@ -1865,7 +1865,7 @@ error::Error GLES2DecoderImpl::HandleUniform2f( error::Error GLES2DecoderImpl::HandleUniform2fv( uint32 immediate_data_size, const gles2::Uniform2fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1883,7 +1883,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fv( error::Error GLES2DecoderImpl::HandleUniform2fvImmediate( uint32 immediate_data_size, const gles2::Uniform2fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1904,7 +1904,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fvImmediate( error::Error GLES2DecoderImpl::HandleUniform2i( uint32 immediate_data_size, const gles2::Uniform2i& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); @@ -1915,7 +1915,7 @@ error::Error GLES2DecoderImpl::HandleUniform2i( error::Error GLES2DecoderImpl::HandleUniform2iv( uint32 immediate_data_size, const gles2::Uniform2iv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1933,7 +1933,7 @@ error::Error GLES2DecoderImpl::HandleUniform2iv( error::Error GLES2DecoderImpl::HandleUniform2ivImmediate( uint32 immediate_data_size, const gles2::Uniform2ivImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1954,7 +1954,7 @@ error::Error GLES2DecoderImpl::HandleUniform2ivImmediate( error::Error GLES2DecoderImpl::HandleUniform3f( uint32 immediate_data_size, const gles2::Uniform3f& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); @@ -1966,7 +1966,7 @@ error::Error GLES2DecoderImpl::HandleUniform3f( error::Error GLES2DecoderImpl::HandleUniform3fv( uint32 immediate_data_size, const gles2::Uniform3fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -1984,7 +1984,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fv( error::Error GLES2DecoderImpl::HandleUniform3fvImmediate( uint32 immediate_data_size, const gles2::Uniform3fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2005,7 +2005,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fvImmediate( error::Error GLES2DecoderImpl::HandleUniform3i( uint32 immediate_data_size, const gles2::Uniform3i& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); @@ -2017,7 +2017,7 @@ error::Error GLES2DecoderImpl::HandleUniform3i( error::Error GLES2DecoderImpl::HandleUniform3iv( uint32 immediate_data_size, const gles2::Uniform3iv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2035,7 +2035,7 @@ error::Error GLES2DecoderImpl::HandleUniform3iv( error::Error GLES2DecoderImpl::HandleUniform3ivImmediate( uint32 immediate_data_size, const gles2::Uniform3ivImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2056,7 +2056,7 @@ error::Error GLES2DecoderImpl::HandleUniform3ivImmediate( error::Error GLES2DecoderImpl::HandleUniform4f( uint32 immediate_data_size, const gles2::Uniform4f& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); @@ -2069,7 +2069,7 @@ error::Error GLES2DecoderImpl::HandleUniform4f( error::Error GLES2DecoderImpl::HandleUniform4fv( uint32 immediate_data_size, const gles2::Uniform4fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2087,7 +2087,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fv( error::Error GLES2DecoderImpl::HandleUniform4fvImmediate( uint32 immediate_data_size, const gles2::Uniform4fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2108,7 +2108,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fvImmediate( error::Error GLES2DecoderImpl::HandleUniform4i( uint32 immediate_data_size, const gles2::Uniform4i& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); @@ -2121,7 +2121,7 @@ error::Error GLES2DecoderImpl::HandleUniform4i( error::Error GLES2DecoderImpl::HandleUniform4iv( uint32 immediate_data_size, const gles2::Uniform4iv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2139,7 +2139,7 @@ error::Error GLES2DecoderImpl::HandleUniform4iv( error::Error GLES2DecoderImpl::HandleUniform4ivImmediate( uint32 immediate_data_size, const gles2::Uniform4ivImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; @@ -2160,7 +2160,7 @@ error::Error GLES2DecoderImpl::HandleUniform4ivImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix2fv( uint32 immediate_data_size, const gles2::UniformMatrix2fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); @@ -2184,7 +2184,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fv( error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix2fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); @@ -2211,7 +2211,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix3fv( uint32 immediate_data_size, const gles2::UniformMatrix3fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); @@ -2235,7 +2235,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fv( error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix3fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); @@ -2262,7 +2262,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix4fv( uint32 immediate_data_size, const gles2::UniformMatrix4fv& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); @@ -2286,7 +2286,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fv( error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix4fvImmediate& c) { - GLint location = program_manager()->UnswizzleLocation( + GLint location = GLES2Util::UnswizzleLocation( static_cast<GLint>(c.location)); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 7bda0d4..863a7f9 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1109,7 +1109,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivSucceeds) { result->size = 0; GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _)) .Times(1); @@ -1124,7 +1124,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) { result->size = 0; GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2ElementFakeLocation), + GLES2Util::SwizzleLocation(kUniform2ElementFakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _)) @@ -1141,7 +1141,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { GetUniformiv cmd; // non-existant program cmd.Init(kInvalidClientId, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); @@ -1153,7 +1153,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { #if GLES2_TEST_SHADER_VS_PROGRAM_IDS result->size = kInitialResult; cmd.Init(client_shader_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1169,7 +1169,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); result->size = kInitialResult; cmd.Init(kNewClientId, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1194,7 +1194,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) { GetUniformiv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kInvalidSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); @@ -1210,7 +1210,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) { result->size = 0; GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _)) .Times(1); @@ -1225,7 +1225,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) { result->size = 0; GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2ElementFakeLocation), + GLES2Util::SwizzleLocation(kUniform2ElementFakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _)) @@ -1242,7 +1242,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { GetUniformfv cmd; // non-existant program cmd.Init(kInvalidClientId, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); @@ -1254,7 +1254,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { #if GLES2_TEST_SHADER_VS_PROGRAM_IDS result->size = kInitialResult; cmd.Init(client_shader_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1270,7 +1270,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); result->size = kInitialResult; cmd.Init(kNewClientId, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(0U, result->size); @@ -1295,7 +1295,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) { GetUniformfv cmd; cmd.Init(client_program_id_, - program_manager()->SwizzleLocation(kUniform2FakeLocation), + GLES2Util::SwizzleLocation(kUniform2FakeLocation), kInvalidSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); @@ -1872,7 +1872,7 @@ TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) { EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2)); Uniform1i cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 2); + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 2); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } @@ -1881,7 +1881,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { *gl_, Uniform1iv(kUniform1RealLocation, 1, reinterpret_cast<const GLint*>(shared_memory_address_))); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } @@ -1889,7 +1889,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1897,7 +1897,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1909,7 +1909,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { Uniform1iv(kUniform1RealLocation, 1, reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); GLint temp[1 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); @@ -1918,7 +1918,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); @@ -1927,7 +1927,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { TEST_F(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1iv cmd; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 0, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1937,7 +1937,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1iSamplerIsLmited) { EXPECT_CALL(*gl_, Uniform1i(_, _)).Times(0); Uniform1i cmd; cmd.Init( - program_manager()->SwizzleLocation(kUniform1FakeLocation), + GLES2Util::SwizzleLocation(kUniform1FakeLocation), kNumTextureUnits); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1947,7 +1947,7 @@ TEST_F(GLES2DecoderWithShaderTest, Uniform1ivSamplerIsLimited) { EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); GLint temp[] = { kNumTextureUnits }; - cmd.Init(program_manager()->SwizzleLocation(kUniform1FakeLocation), 1, + cmd.Init(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); @@ -2812,7 +2812,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) { kSharedMemoryId, kSharedMemoryOffset, kNameSize); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2FakeLocation), *result); + EXPECT_EQ(GLES2Util::SwizzleLocation(kUniform2FakeLocation), *result); memcpy(name, kNonExistentName, kNonExistentNameSize); *result = -1; cmd.Init(client_program_id_, @@ -2893,7 +2893,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(kUniform2FakeLocation), *result); + EXPECT_EQ(GLES2Util::SwizzleLocation(kUniform2FakeLocation), *result); *result = -1; cmd.Init(client_program_id_, kNonExistentName, kSharedMemoryId, kSharedMemoryOffset); @@ -2935,7 +2935,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucket) { cmd.Init(client_program_id_, kBucketId, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(program_manager()->SwizzleLocation(kUniform2FakeLocation), *result); + EXPECT_EQ(GLES2Util::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 33bf614..1ed5126 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 @@ -700,7 +700,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fValidArgs) { EXPECT_CALL(*gl_, Uniform1fv(1, 1, _)); SpecializedSetup<Uniform1f, 0>(true); Uniform1f cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2); + cmd.Init(GLES2Util::SwizzleLocation(1), 2); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -712,7 +712,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvValidArgs) { SpecializedSetup<Uniform1fv, 0>(true); Uniform1fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -723,7 +723,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs1_0) { SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -733,8 +733,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -743,7 +742,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_1) { SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -755,8 +754,8 @@ TEST_F(GLES2DecoderTest2, Uniform1fvValidArgsCountTooLarge) { SpecializedSetup<Uniform1fv, 0>(true); Uniform1fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -770,7 +769,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform1fvImmediate, 0>(true); GLfloat temp[1 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -783,7 +782,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fValidArgs) { EXPECT_CALL(*gl_, Uniform2fv(1, 1, _)); SpecializedSetup<Uniform2f, 0>(true); Uniform2f cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -795,7 +794,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvValidArgs) { SpecializedSetup<Uniform2fv, 0>(true); Uniform2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -806,7 +805,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs1_0) { SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -816,8 +815,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -826,7 +824,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_1) { SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -838,8 +836,8 @@ TEST_F(GLES2DecoderTest2, Uniform2fvValidArgsCountTooLarge) { SpecializedSetup<Uniform2fv, 0>(true); Uniform2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -853,7 +851,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform2fvImmediate, 0>(true); GLfloat temp[2 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -863,7 +861,7 @@ TEST_F(GLES2DecoderTest2, Uniform2iValidArgs) { EXPECT_CALL(*gl_, Uniform2iv(1, 1, _)); SpecializedSetup<Uniform2i, 0>(true); Uniform2i cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -875,7 +873,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivValidArgs) { SpecializedSetup<Uniform2iv, 0>(true); Uniform2iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -886,7 +884,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs1_0) { SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -896,8 +894,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -906,7 +903,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_1) { SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -918,8 +915,8 @@ TEST_F(GLES2DecoderTest2, Uniform2ivValidArgsCountTooLarge) { SpecializedSetup<Uniform2iv, 0>(true); Uniform2iv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -933,7 +930,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform2ivImmediate, 0>(true); GLint temp[2 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -943,7 +940,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fValidArgs) { EXPECT_CALL(*gl_, Uniform3fv(1, 1, _)); SpecializedSetup<Uniform3f, 0>(true); Uniform3f cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3, 4); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -955,7 +952,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvValidArgs) { SpecializedSetup<Uniform3fv, 0>(true); Uniform3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -966,7 +963,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs1_0) { SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -976,8 +973,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -986,7 +982,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_1) { SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -998,8 +994,8 @@ TEST_F(GLES2DecoderTest2, Uniform3fvValidArgsCountTooLarge) { SpecializedSetup<Uniform3fv, 0>(true); Uniform3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1013,7 +1009,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform3fvImmediate, 0>(true); GLfloat temp[3 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1023,7 +1019,7 @@ TEST_F(GLES2DecoderTest2, Uniform3iValidArgs) { EXPECT_CALL(*gl_, Uniform3iv(1, 1, _)); SpecializedSetup<Uniform3i, 0>(true); Uniform3i cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3, 4); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1035,7 +1031,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivValidArgs) { SpecializedSetup<Uniform3iv, 0>(true); Uniform3iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1046,7 +1042,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs1_0) { SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1056,8 +1052,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1066,7 +1061,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_1) { SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1078,8 +1073,8 @@ TEST_F(GLES2DecoderTest2, Uniform3ivValidArgsCountTooLarge) { SpecializedSetup<Uniform3iv, 0>(true); Uniform3iv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1093,7 +1088,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform3ivImmediate, 0>(true); GLint temp[3 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1103,7 +1098,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fValidArgs) { EXPECT_CALL(*gl_, Uniform4fv(1, 1, _)); SpecializedSetup<Uniform4f, 0>(true); Uniform4f cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3, 4, 5); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4, 5); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1115,7 +1110,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvValidArgs) { SpecializedSetup<Uniform4fv, 0>(true); Uniform4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1126,7 +1121,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs1_0) { SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1136,8 +1131,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1146,7 +1140,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_1) { SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1158,8 +1152,8 @@ TEST_F(GLES2DecoderTest2, Uniform4fvValidArgsCountTooLarge) { SpecializedSetup<Uniform4fv, 0>(true); Uniform4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1173,7 +1167,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform4fvImmediate, 0>(true); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1183,7 +1177,7 @@ TEST_F(GLES2DecoderTest2, Uniform4iValidArgs) { EXPECT_CALL(*gl_, Uniform4iv(1, 1, _)); SpecializedSetup<Uniform4i, 0>(true); Uniform4i cmd; - cmd.Init(program_manager()->SwizzleLocation(1), 2, 3, 4, 5); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4, 5); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1195,7 +1189,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivValidArgs) { SpecializedSetup<Uniform4iv, 0>(true); Uniform4iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1206,7 +1200,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs1_0) { SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1216,8 +1210,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; - cmd.Init( - program_manager()->SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1226,7 +1219,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_1) { SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1238,8 +1231,8 @@ TEST_F(GLES2DecoderTest2, Uniform4ivValidArgsCountTooLarge) { SpecializedSetup<Uniform4iv, 0>(true); Uniform4iv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1253,7 +1246,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform4ivImmediate, 0>(true); GLint temp[4 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1267,7 +1260,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgs) { SpecializedSetup<UniformMatrix2fv, 0>(true); UniformMatrix2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1278,7 +1271,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs1_0) { SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1289,7 +1282,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs2_0) { SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1299,9 +1292,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; - cmd.Init( - program_manager()->SwizzleLocation( - 1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1310,7 +1301,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_1) { SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1323,8 +1314,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix2fv, 0>(true); UniformMatrix2fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1339,7 +1330,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix2fvImmediate, 0>(true); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1351,7 +1342,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fvImmediate, 0>(false); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1365,7 +1356,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgs) { SpecializedSetup<UniformMatrix3fv, 0>(true); UniformMatrix3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1376,7 +1367,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs1_0) { SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1387,7 +1378,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs2_0) { SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1397,9 +1388,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; - cmd.Init( - program_manager()->SwizzleLocation( - 1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1408,7 +1397,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_1) { SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1421,8 +1410,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix3fv, 0>(true); UniformMatrix3fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1437,7 +1426,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix3fvImmediate, 0>(true); GLfloat temp[9 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1449,7 +1438,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fvImmediate, 0>(false); GLfloat temp[9 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1463,7 +1452,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgs) { SpecializedSetup<UniformMatrix4fv, 0>(true); UniformMatrix4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1474,7 +1463,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs1_0) { SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1485,7 +1474,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs2_0) { SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1495,9 +1484,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; - cmd.Init( - program_manager()->SwizzleLocation( - 1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1506,7 +1493,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_1) { SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( + GLES2Util::SwizzleLocation( 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1519,8 +1506,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix4fv, 0>(true); UniformMatrix4fv cmd; cmd.Init( - program_manager()->SwizzleLocation( - ProgramManager::ProgramInfo::GetFakeLocation( + GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation( 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1535,7 +1522,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix4fvImmediate, 0>(true); GLfloat temp[16 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1547,7 +1534,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fvImmediate, 0>(false); GLfloat temp[16 * 2] = { 0, }; - cmd.Init(program_manager()->SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index 5d504a4..0eb90a3 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <set> +#include <vector> #include "base/basictypes.h" #include "base/command_line.h" @@ -163,6 +164,24 @@ void ProgramManager::ProgramInfo::ClearUniforms( } } +namespace { + +struct UniformData { + std::string queried_name; + std::string corrected_name; + std::string original_name; + GLsizei size; + GLenum type; +}; + +struct UniformDataComparer { + bool operator()(const UniformData& lhs, const UniformData& rhs) const { + return lhs.queried_name < rhs.queried_name; + } +}; + +} // anonymous namespace + void ProgramManager::ProgramInfo::Update() { Reset(); UpdateLogInfo(); @@ -215,31 +234,42 @@ void ProgramManager::ProgramInfo::Update() { 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]); + + // Read all the names first and sort them so we get a consistent list + std::vector<UniformData> uniform_data_; for (GLint ii = 0; ii < num_uniforms; ++ii) { GLsizei length = 0; - GLsizei size = 0; - GLenum type = 0; + UniformData data; glGetActiveUniform( - service_id_, ii, max_len, &length, &size, &type, name_buffer.get()); + service_id_, ii, max_len, &length, + &data.size, &data.type, name_buffer.get()); DCHECK(max_len == 0 || length < max_len); 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()); - std::string name; - std::string original_name; + data.queried_name = std::string(name_buffer.get()); GetCorrectedVariableInfo( - true, name_buffer.get(), &name, &original_name, &size, &type); - const UniformInfo* info = AddUniformInfo( - size, type, location, name, original_name); - if (info->IsSampler()) { - sampler_indices_.push_back(info->fake_location_base); - } - max_uniform_name_length_ = - std::max(max_uniform_name_length_, - static_cast<GLsizei>(info->name.size())); + true, name_buffer.get(), &data.corrected_name, &data.original_name, + &data.size, &data.type); + uniform_data_.push_back(data); } } + + std::sort(uniform_data_.begin(), uniform_data_.end(), UniformDataComparer()); + + for (size_t ii = 0; ii < uniform_data_.size(); ++ii) { + const UniformData& data = uniform_data_[ii]; + GLint location = glGetUniformLocation( + service_id_, data.queried_name.c_str()); + const UniformInfo* info = AddUniformInfo( + data.size, data.type, location, data.corrected_name, + data.original_name); + if (info->IsSampler()) { + sampler_indices_.push_back(info->fake_location_base); + } + max_uniform_name_length_ = + std::max(max_uniform_name_length_, + static_cast<GLsizei>(info->name.size())); + } valid_ = true; } @@ -312,7 +342,7 @@ GLint ProgramManager::ProgramInfo::GetUniformFakeLocation( index = index * 10 + digit; } if (!bad && index >= 0 && index < info.size) { - return GetFakeLocation(info.fake_location_base, index); + return GLES2Util::MakeFakeLocation(info.fake_location_base, index); } } } @@ -658,7 +688,8 @@ 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(ii + jj * 0x10000); + *locations++ = GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation(ii, jj)); } memcpy(strings, info.name.c_str(), info.name.size()); strings += info.name.size(); @@ -678,14 +709,8 @@ ProgramManager::ProgramInfo::~ProgramInfo() { } } -// TODO(gman): make this some kind of random number. Base::RandInt is not -// callable because of the sandbox. What matters is that it's possibly different -// by at least 1 bit each time chrome is run. -static int uniform_random_offset_ = 3; - ProgramManager::ProgramManager() - : uniform_swizzle_(uniform_random_offset_++ % 15), - program_info_count_(0), + : program_info_count_(0), have_context_(true), disable_workarounds_( CommandLine::ForCurrentProcess()->HasSwitch( @@ -798,25 +823,6 @@ void ProgramManager::ClearUniforms(ProgramManager::ProgramInfo* info) { } } -// 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 'n' more than "someuniform[0]". -static GLint Swizzle(GLint location) { - return (location & 0xF0000000U) | - ((location & 0x0AAAAAAAU) >> 1) | - ((location & 0x05555555U) << 1); -} - -// Adds uniform_swizzle_ to prevent developers from assuming that locations are -// always the same across GPUs and drivers. -GLint ProgramManager::SwizzleLocation(GLint v) const { - return v < 0 ? v : (Swizzle(v) + uniform_swizzle_); -} - -GLint ProgramManager::UnswizzleLocation(GLint v) const { - return v < 0 ? v : Swizzle(v - uniform_swizzle_); -} - } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h index 553c313..d2655cc 100644 --- a/gpu/command_buffer/service/program_manager.h +++ b/gpu/command_buffer/service/program_manager.h @@ -173,11 +173,6 @@ class GPU_EXPORT ProgramManager { // We only consider the declared attributes in the program. bool DetectAttribLocationBindingConflicts() const; - 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; @@ -322,9 +317,6 @@ class GPU_EXPORT ProgramManager { // Check if a ProgramInfo is owned by this ProgramManager. bool IsOwned(ProgramInfo* info); - GLint SwizzleLocation(GLint unswizzled_location) const; - GLint UnswizzleLocation(GLint swizzled_location) const; - private: void StartTracking(ProgramInfo* info); void StopTracking(ProgramInfo* info); @@ -334,8 +326,6 @@ class GPU_EXPORT ProgramManager { typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; ProgramInfoMap program_infos_; - int uniform_swizzle_; - // Counts the number of ProgramInfo allocated with 'this' as its manager. // Allows to check no ProgramInfo will outlive this. unsigned int program_info_count_; diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc index c0fad67..c05113f 100644 --- a/gpu/command_buffer/service/program_manager_unittest.cc +++ b/gpu/command_buffer/service/program_manager_unittest.cc @@ -11,6 +11,7 @@ #include "base/string_util.h" #include "gpu/command_buffer/common/gl_mock.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" +#include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/service/common_decoder.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/test_helper.h" @@ -130,17 +131,6 @@ TEST_F(ProgramManagerTest, ProgramInfo) { EXPECT_TRUE(info1->log_info() == NULL); } -TEST_F(ProgramManagerTest, SwizzleLocation) { - GLint power = 1; - for (GLint p = 0; p < 5; ++p, power *= 10) { - GLint limit = power * 20 + 1; - for (GLint ii = -limit; ii < limit; ii += power) { - GLint s = manager_.SwizzleLocation(ii); - EXPECT_EQ(ii, manager_.UnswizzleLocation(s)); - } - } -} - class ProgramManagerWithShaderTest : public testing::Test { public: ProgramManagerWithShaderTest() @@ -493,15 +483,12 @@ TEST_F(ProgramManagerWithShaderTest, GetUniformFakeLocation) { EXPECT_EQ(kUniform3FakeLocation, program_info->GetUniformFakeLocation(kUniform3GoodName)); // Check that we can get the locations of the array elements > 1 - EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( - kUniform2FakeLocation, 1), + EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 1), program_info->GetUniformFakeLocation("uniform2[1]")); - EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( - kUniform2FakeLocation, 2), + EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 2), program_info->GetUniformFakeLocation("uniform2[2]")); EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform2[3]")); - EXPECT_EQ(ProgramManager::ProgramInfo::GetFakeLocation( - kUniform3FakeLocation, 1), + EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform3FakeLocation, 1), program_info->GetUniformFakeLocation("uniform3[1]")); EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform3[2]")); } @@ -848,9 +835,8 @@ 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( - ProgramManager::ProgramInfo::GetFakeLocation( - expected.fake_location, jj)), + EXPECT_EQ(GLES2Util::SwizzleLocation( + GLES2Util::MakeFakeLocation(expected.fake_location, jj)), locations[jj]); } const char* name_buf = bucket.GetDataAs<const char*>( @@ -999,6 +985,75 @@ TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { } } +TEST_F(ProgramManagerWithShaderTest, UniformsAreSorted) { + const GLuint kVShaderClientId = 2001; + const GLuint kFShaderClientId = 2002; + const GLuint kVShaderServiceId = 3001; + const GLuint kFShaderServiceId = 3002; + ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( + kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); + ASSERT_TRUE(vshader != NULL); + vshader->SetStatus(true, "", NULL); + ShaderManager::ShaderInfo* fshader = shader_manager_.CreateShaderInfo( + kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); + ASSERT_TRUE(fshader != NULL); + fshader->SetStatus(true, "", NULL); + static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { + { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, + { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, + { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, + }; + static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { + { kUniform2Name, + kUniform2Size, + kUniform2Type, + kUniform2FakeLocation, + kUniform2RealLocation, + kUniform2Name, + }, + { kUniform3GoodName, + kUniform3Size, + kUniform3Type, + kUniform3FakeLocation, + kUniform3RealLocation, + kUniform3GoodName, + }, + { kUniform1Name, + kUniform1Size, + kUniform1Type, + kUniform1FakeLocation, + kUniform1RealLocation, + kUniform1Name, + }, + }; + const size_t kNumAttribs= arraysize(kAttribs); + const size_t kNumUniforms = arraysize(kUniforms); + static const GLuint kClientProgramId = 1234; + static const GLuint kServiceProgramId = 5679; + SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, + kServiceProgramId); + ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo( + kClientProgramId, kServiceProgramId); + ASSERT_TRUE(program_info != NULL); + EXPECT_TRUE(program_info->AttachShader(&shader_manager_, vshader)); + EXPECT_TRUE(program_info->AttachShader(&shader_manager_, fshader)); + program_info->Link(); + // Check Uniforms + const ProgramManager::ProgramInfo::UniformInfo* uniform_info = + program_info->GetUniformInfo(0); + ASSERT_TRUE(uniform_info != NULL); + EXPECT_STREQ(kUniform1Name, uniform_info->name.c_str()); + EXPECT_EQ(0, uniform_info->fake_location_base); + uniform_info = program_info->GetUniformInfo(1); + ASSERT_TRUE(uniform_info != NULL); + EXPECT_STREQ(kUniform2Name, uniform_info->name.c_str()); + EXPECT_EQ(1, uniform_info->fake_location_base); + uniform_info = program_info->GetUniformInfo(2); + ASSERT_TRUE(uniform_info != NULL); + EXPECT_STREQ(kUniform3GoodName, uniform_info->name.c_str()); + EXPECT_EQ(2, uniform_info->fake_location_base); +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc index 4ea3918..33a1703 100644 --- a/gpu/command_buffer/service/test_helper.cc +++ b/gpu/command_buffer/service/test_helper.cc @@ -12,6 +12,7 @@ #include "gpu/command_buffer/service/program_manager.h" #include "testing/gtest/include/gtest/gtest.h" +#include <algorithm> #include <string.h> using ::testing::_; @@ -368,6 +369,17 @@ void TestHelper::SetupExpectationsForClearingUniforms( } } +namespace { + +struct UniformInfoComparer { + bool operator()(const TestHelper::UniformInfo& lhs, + const TestHelper::UniformInfo& rhs) const { + return strcmp(lhs.name, rhs.name) < 0; + } +}; + +} // anonymous namespace. + void TestHelper::SetupShader( ::gfx::MockGLInterface* gl, AttribInfo* attribs, size_t num_attribs, @@ -400,6 +412,7 @@ void TestHelper::SetupShader( GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _)) .WillOnce(SetArgumentPointee<2>(max_attrib_len)) .RetiresOnSaturation(); + for (size_t ii = 0; ii < num_attribs; ++ii) { const AttribInfo& info = attribs[ii]; EXPECT_CALL(*gl, @@ -422,6 +435,10 @@ void TestHelper::SetupShader( GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _)) .WillOnce(SetArgumentPointee<2>(num_uniforms)) .RetiresOnSaturation(); + + scoped_array<UniformInfo> sorted_uniforms(new UniformInfo[num_uniforms]); + size_t num_valid_uniforms = 0; + size_t max_uniform_len = 0; for (size_t ii = 0; ii < num_uniforms; ++ii) { size_t len = strlen(uniforms[ii].name) + 1; @@ -444,28 +461,36 @@ void TestHelper::SetupShader( info.name + strlen(info.name) + 1))) .RetiresOnSaturation(); if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { - EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name))) - .WillOnce(Return(info.real_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(base_name) + "[" + base::IntToString(jj) + "]"); - EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(element_name))) - .WillOnce(Return(info.real_location + jj * 2)) - .RetiresOnSaturation(); - } + sorted_uniforms[num_valid_uniforms++] = uniforms[ii]; + } + } + + std::sort( + &sorted_uniforms[0], &sorted_uniforms[num_valid_uniforms], + UniformInfoComparer()); + + for (size_t ii = 0; ii < num_valid_uniforms; ++ii) { + const UniformInfo& info = sorted_uniforms[ii]; + EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name))) + .WillOnce(Return(info.real_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(base_name) + "[" + base::IntToString(jj) + "]"); + EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(element_name))) + .WillOnce(Return(info.real_location + jj * 2)) + .RetiresOnSaturation(); } } } } - } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/tests/gl_consistent_uniform_locations_unittest.cc b/gpu/command_buffer/tests/gl_consistent_uniform_locations_unittest.cc new file mode 100644 index 0000000..b831368 --- /dev/null +++ b/gpu/command_buffer/tests/gl_consistent_uniform_locations_unittest.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> + +#include "gpu/command_buffer/tests/gl_manager.h" +#include "gpu/command_buffer/tests/gl_test_utils.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +#define SHADER(Src) #Src + +namespace gpu { + +class ConsistenUniformLocationsTest : public testing::Test { + protected: + static const GLsizei kResolution = 4; + virtual void SetUp() { + gl_.Initialize(gfx::Size(kResolution, kResolution)); + } + + virtual void TearDown() { + gl_.Destroy(); + } + + GLManager gl_; +}; + +namespace { + +struct FormatType { + GLenum format; + GLenum type; +}; + +} // anonymous namespace + +TEST_F(ConsistenUniformLocationsTest, Basic) { + ASSERT_TRUE( + GLTestHelper::HasExtension("GL_CHROMIUM_consistent_uniform_locations")); + + static const char* v_shader_str = SHADER( + attribute vec4 a_position; + void main() + { + gl_Position = a_position; + } + ); + static const char* f_shader_str = SHADER( + precision mediump float; + uniform vec4 u_colorC; + uniform vec4 u_colorB[2]; + uniform vec4 u_colorA; + void main() + { + gl_FragColor = u_colorA + u_colorB[0] + u_colorB[1] + u_colorC; + } + ); + + static const GLUniformDefinitionCHROMIUM defs[] = { + { GL_FLOAT_VEC4, 1, "u_colorC", }, + { GL_FLOAT_VEC4, 2, "u_colorB", }, + { GL_FLOAT_VEC4, 1, "u_colorA", }, + }; + + GLint locations[4]; + + glGetUniformLocationsCHROMIUM( + defs, arraysize(defs), arraysize(locations), locations); + + GLint u_colorCLocation = locations[0]; + GLint u_colorB0Location = locations[1]; + GLint u_colorB1Location = locations[2]; + GLint u_colorALocation = locations[3]; + + GLuint program = GLTestHelper::LoadProgram(v_shader_str, f_shader_str); + + GLint position_loc = glGetAttribLocation(program, "a_position"); + + GLTestHelper::SetupUnitQuad(position_loc); + + glUseProgram(program); + + glUniform4f(u_colorALocation, 0.25f, 0.0f, 0.0f, 0.0f); + glUniform4f(u_colorB0Location, 0.0f, 0.50f, 0.0f, 0.0f); + glUniform4f(u_colorB1Location, 0.0f, 0.0f, 0.75f, 0.0f); + glUniform4f(u_colorCLocation, 0.0f, 0.0f, 0.0f, 1.0f); + + glDrawArrays(GL_TRIANGLES, 0, 6); + + static const uint8 expected[] = { 64, 128, 192, 255 }; + EXPECT_TRUE( + GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 1, expected)); + + GLTestHelper::CheckGLError("no errors", __LINE__); +} + +} // namespace gpu + + + diff --git a/gpu/gpu_common.gypi b/gpu/gpu_common.gypi index 93910b0..2e425f9 100644 --- a/gpu/gpu_common.gypi +++ b/gpu/gpu_common.gypi @@ -234,6 +234,7 @@ 'command_buffer/tests/occlusion_query_unittests.cc', 'command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc', 'command_buffer/tests/gl_depth_texture_unittest.cc', + 'command_buffer/tests/gl_consistent_uniform_locations_unittest.cc', 'command_buffer/tests/gl_manager.cc', 'command_buffer/tests/gl_manager.h', 'command_buffer/tests/gl_tests_main.cc', |