diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:33 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:33 +0000 |
commit | 2be6abf3a4fb590a1b59586858d1e49ea61f0708 (patch) | |
tree | b20ee87dd632d5a21b40948cd5b430239fcdde0e /gpu | |
parent | 2c3eaaf90eb2cb35c60272307540b2c2ea335f82 (diff) | |
download | chromium_src-2be6abf3a4fb590a1b59586858d1e49ea61f0708.zip chromium_src-2be6abf3a4fb590a1b59586858d1e49ea61f0708.tar.gz chromium_src-2be6abf3a4fb590a1b59586858d1e49ea61f0708.tar.bz2 |
Add glBindUniformLocationCHROMIUM
TEST=unit tests
BUG=132844
Review URL: https://chromiumcodereview.appspot.com/10635011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
31 files changed, 1038 insertions, 782 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_bind_uniform_location.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_bind_uniform_location.txt new file mode 100644 index 0000000..c6619bb --- /dev/null +++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_bind_uniform_location.txt @@ -0,0 +1,131 @@ +Name + + CHROMIUM_bind_uniform_location + +Name Strings + + GL_CHROMIUM_bind_uniform_location + +Version + + Last Modifed Date: June 20, 2012 + +Dependencies + + OpenGL ES 2.0 is required. + +Overview + + This extension is simlar to glBindAttribLocation but instead + lets you choose a location for a uniform. This allows you + to not have to query the locations of uniforms. + + This allows the client program to know the locations of uniforms + without having to wait for shaders to compile or GLSL programs to + link to query the locations and therefore have no blocking calls + when initializing programs. + +Issues + + If a uniform is an array you can only call glBindUniformLocation + for the location of the first element. Other elements' locations + must be queried if you need them. Often this is not an issue + because you can set all the elements with a single gl call from + the first location. + + Good Example: + + --shader-- + uniform float u_someArray[4]; + + --C-- + GLint location = 123; + glBindUniformLocation(program, location, "u_someArray"); + glLinkProgram(program); + glUseProgram(program); + + // set all 4 floats in u_someArray + float values[] = { 0.1f, 0.2f, 0.3f, 0.4f, }; + glUniform1fv(location, 4, values); + + Bad example 1: + + GLint location = 123; + glBindUniformLocation(program, location, "u_someArray"); + glLinkProgram(program); + glUseProgram(program); + + // set floats in u_someArray one at a time + glUniform1f(location, 0.1f); + glUniform1f(location + 1, 0.2f); // ERROR! math not allowed on locations + + Bad example 2: + + GLint location0 = 123; + GLint location1 = 124; + glBindUniformLocation(program, location0, "u_someArray[0]"); + glBindUniformLocation(program, location1, "u_someArray[1]"); // ERROR! + // not allowed to assign locations to array elements + + If you need to set individual elements of a uniform array you must query the + location of the each element you wish to set. + +New Tokens + + None + +New Procedures and Functions + + void BindUniformLocationCHROMIUM (GLuint program, GLint location, + const GLhchar* name); + + specifes that the uniform variable named <name> in program <program> + should be bound to uniform location <location> when the program is next + linked. If <name> was bound previously, its assigned binding is replaced + with <location>. <name> must be a null terminated string. The error + INVALID_VALUE is generated if <location> is equal or greater than + + (MAX_VERTEX_UNIFORM_VECTORS + MAX_FRAGMENT_UNIFORM_VECTORS) * 4 + + or less than 0. BindUniformLocation has no effect until the program is + linked. In particular, it doesn't modify the bindings of active uniforms + variables in a program that has already been linked. + + The error INVALID_OPERATION is generated if name starts with the reserved + "gl_" prefix. The error INVALID_VALUE is generated if name ends with + an array element expression other than "[0]". + + When a program is linked, any active uniforms without a binding specified + through BindUniformLocation will be automatically be bound to locations by + the GL. Such bindings can be queried using the command + GetUniformLocation. + + BindUniformLocation may be issued before any shader objects are attached + to a program object. Hence it is allowed to bind any name (except a name + starting with "gl_") to an index, including a name that is never used as a + uniform in any shader object. Assigned bindings for uniform variables + that do not exist or are not active are ignored. + + It is possible for an application to bind more than one uniform name to + the same location. This is referred to as aliasing. This will only work + if only one of the aliased uniforms is active in the executable program, + or if no path through the shader consumes more than one uniform of a set + of uniforms aliased to the same location. A link error can occur if the + linker determines that every path through the shader consumes multiple + aliased uniforms, but implementations are not required to generate an + error in this case. The compiler and linker are allowed to assume that no + aliasing is done, and may employ optimizations that work only in the + absence of aliasing. + +Errors + + None. + +New State + + None. + +Revision History + + 7/20/2012 Documented the extension + diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt deleted file mode 100644 index e7e8907..0000000 --- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_consistent_uniform_locations.txt +++ /dev/null @@ -1,88 +0,0 @@ -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 wait for shaders to compile or GLSL programs to - link to query the locations and therefore have no blocking calls - when initializing programs. - - To be forward compatible the locations are provided through the - function GetUniformLocationsCHROMIUM. LinkProgram must be called - before calling GetUniformLocationsCHROMIUM. - -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 (GLuint program, - 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 - 7/19/2012 Added <program> argument. - diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index aec1984..d3417d8 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1701,11 +1701,11 @@ _FUNCTION_INFO = { 'gl_test_func': 'glGetQueryObjectuiv', 'pepper_interface': 'Query', }, - 'GetUniformLocationsCHROMIUM': { - 'gen_cmd': False, - 'extension': True, - 'chromium': True, - 'client_test': False, + 'BindUniformLocationCHROMIUM': { + 'type': 'GLchar', + 'bucket': True, + 'needs_size': True, + 'gl_test_func': 'DoBindUniformLocationCHROMIUM', }, } @@ -3837,9 +3837,7 @@ TEST_F(%(test_name)s, %(name)sValidArgsCountTooLarge) { # the location of the second element of the 2nd uniform. # defined in GLES2DecoderBase::SetupShaderForUniform gl_arg_strings.append("3") - arg_strings.append( - "GLES2Util::SwizzleLocation(" - "GLES2Util::MakeFakeLocation(1, 1))") + arg_strings.append("ProgramManager::MakeFakeLocation(1, 1)") elif count == 1: # the number of elements that gl will be called with. gl_arg_strings.append("3") @@ -4695,14 +4693,13 @@ class UniformLocationArgument(Argument): def WriteGetCode(self, file): """Writes the code to get an argument from a command structure.""" - code = """ %s %s = GLES2Util::UnswizzleLocation( - static_cast<%s>(c.%s)); + code = """ %s %s = 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 "GLES2Util::SwizzleLocation(%d)" % (offset + 1) + return "%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 5a36c8b..760c850 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -651,11 +651,9 @@ void GLES2ProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { void GLES2ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { gles2::GetGLContext()->ConsumeTextureCHROMIUM(target, mailbox); } -void GLES2GetUniformLocationsCHROMIUM( - GLuint program, const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, - GLsizei max_locations, GLint* locations) { - gles2::GetGLContext()->GetUniformLocationsCHROMIUM( - program, uniforms, count, max_locations, locations); +void GLES2BindUniformLocationCHROMIUM( + GLuint program, GLint location, const char* name) { + gles2::GetGLContext()->BindUniformLocationCHROMIUM(program, location, name); } #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 4a515e9..098674d 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1798,5 +1798,35 @@ } } + void BindUniformLocationCHROMIUM( + GLuint program, GLint location, uint32 name_shm_id, + uint32 name_shm_offset, uint32 data_size) { + gles2::BindUniformLocationCHROMIUM* c = + GetCmdSpace<gles2::BindUniformLocationCHROMIUM>(); + if (c) { + c->Init(program, location, name_shm_id, name_shm_offset, data_size); + } + } + + void BindUniformLocationCHROMIUMImmediate( + GLuint program, GLint location, const char* name) { + const uint32 data_size = strlen(name); + gles2::BindUniformLocationCHROMIUMImmediate* c = + GetImmediateCmdSpace<gles2::BindUniformLocationCHROMIUMImmediate>( + data_size); + if (c) { + c->Init(program, location, name, data_size); + } + } + + void BindUniformLocationCHROMIUMBucket( + GLuint program, GLint location, uint32 name_bucket_id) { + gles2::BindUniformLocationCHROMIUMBucket* c = + GetCmdSpace<gles2::BindUniformLocationCHROMIUMBucket>(); + if (c) { + c->Init(program, location, name_bucket_id); + } + } + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 892d565..953f87f 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -1162,6 +1162,17 @@ void GLES2Implementation::BindAttribLocation( helper_->SetBucketSize(kResultBucketId, 0); } +void GLES2Implementation::BindUniformLocationCHROMIUM( + GLuint program, GLint location, const char* name) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << this << "] glBindUniformLocationCHROMIUM(" + << program << ", " << location << ", " << name << ")"); + SetBucketAsString(kResultBucketId, name); + helper_->BindUniformLocationCHROMIUMBucket( + program, location, kResultBucketId); + helper_->SetBucketSize(kResultBucketId, 0); +} + void GLES2Implementation::GetVertexAttribPointerv( GLuint index, GLenum pname, void** ptr) { GPU_CLIENT_SINGLE_THREAD_CHECK(); @@ -2091,7 +2102,6 @@ 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: @@ -3278,95 +3288,5 @@ 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( - GLuint program, - const GLUniformDefinitionCHROMIUM* uniforms, - GLsizei count, - GLsizei max_locations, - GLint* locations) { - (void)program; // To keep the compiler happy as it's unused in release. - - 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; - } - GLint location = GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation(base_location, jj)); - *locations++ = location; - #if defined(GPU_CLIENT_DEBUG) - std::string name(def.name); - if (jj > 0) { - char buf[20]; - sprintf(buf, "%d", jj); - name = name + "[" + buf + "]"; - } - GPU_DCHECK_EQ( - location, - share_group_->program_info_manager()->GetUniformLocation( - this, program, name.c_str())); - #endif - --max_locations; - - } - } -} - } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index f4b18ae..ee673ce 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1559,9 +1559,8 @@ void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { helper_->ConsumeTextureCHROMIUMImmediate(target, mailbox); } -void GetUniformLocationsCHROMIUM( - GLuint program, const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, - GLsizei max_locations, GLint* locations); +void BindUniformLocationCHROMIUM( + GLuint program, GLint location, const char* name); #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 9d40493..b7f599b4 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -2303,7 +2303,6 @@ TEST_F(GLES2ImplementationTest, GetString) { "foobar " "GL_CHROMIUM_map_sub " "GL_CHROMIUM_flipy " - "GL_CHROMIUM_consistent_uniform_locations " "GL_EXT_unpack_subimage"; const char kBad = 0x12; struct Cmds { @@ -2565,133 +2564,6 @@ TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { EXPECT_EQ(0u, available); } -namespace { - -class MockProgramInfoManager : public ProgramInfoManager { - public: - virtual ~MockProgramInfoManager() {}; - - MOCK_METHOD1(CreateInfo, void(GLuint program)); - - MOCK_METHOD1(DeleteInfo, void(GLuint program)); - - MOCK_METHOD4(GetProgramiv, bool( - GLES2Implementation* gl, GLuint program, GLenum pname, GLint* params)); - - MOCK_METHOD3(GetAttribLocation, GLint( - GLES2Implementation* gl, GLuint program, const char* name)); - - MOCK_METHOD3(GetUniformLocation, GLint( - GLES2Implementation* gl, GLuint program, const char* name)); - - MOCK_METHOD8(GetActiveAttrib, bool( - GLES2Implementation* gl, - GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, - GLint* size, GLenum* type, char* name)); - - MOCK_METHOD8(GetActiveUniform, bool( - GLES2Implementation* gl, - GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, - GLint* size, GLenum* type, char* name)); -}; - -} // anonymous namespace - -TEST_F(GLES2ImplementationTest, GetUniformLocationsCHROMIUM) { - MockProgramInfoManager* manager = new MockProgramInfoManager(); - SetProgramInfoManager(manager); - - const GLuint kProgramId = 123; - 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(kProgramId, bad_defs, 0, 1, locations); - EXPECT_EQ(GL_INVALID_VALUE, CheckError()); - EXPECT_EQ(-1, locations[0]); - - // Test bad size. - gl_->GetUniformLocationsCHROMIUM( - kProgramId, bad_defs, arraysize(bad_defs), 1, locations); - EXPECT_EQ(GL_INVALID_VALUE, CheckError()); - EXPECT_EQ(-1, locations[0]); - - #if defined(GPU_CLIENT_DEBUG) - EXPECT_CALL(*manager, GetUniformLocation(_, kProgramId, _)) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(2, 0)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 0)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 1)))) - .RetiresOnSaturation(); - #endif - - // Test max_locations - gl_->GetUniformLocationsCHROMIUM( - kProgramId, 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]); - - #if defined(GPU_CLIENT_DEBUG) - EXPECT_CALL(*manager, GetUniformLocation(_, kProgramId, _)) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(2, 0)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 0)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 1)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 2)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(0, 3)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 0)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 1)))) - .WillOnce(Return( - GLES2Util::SwizzleLocation(GLES2Util::MakeFakeLocation(1, 2)))) - .RetiresOnSaturation(); - #endif - - // Test all. - gl_->GetUniformLocationsCHROMIUM( - kProgramId, 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/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h index 6a1c15d..8e977e7 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h @@ -1696,5 +1696,6 @@ TEST_F(GLES2ImplementationTest, ConsumeTextureCHROMIUM) { gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, &expected.data[0]); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } +// TODO: Implement unit test for BindUniformLocationCHROMIUM #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt index 5fdb18a..342f4eb 100644 --- a/gpu/command_buffer/cmd_buffer_functions.txt +++ b/gpu/command_buffer/cmd_buffer_functions.txt @@ -185,5 +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 (GLidProgram program, const GLUniformDefinitionCHROMIUM* uniforms, GLsizei count, GLsizei max_locations, GLint* locations); +GL_APICALL void GL_APIENTRY glBindUniformLocationCHROMIUM (GLidProgram program, GLint location, const char* name); diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 5b2e605..b45640b 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -9934,6 +9934,153 @@ COMPILE_ASSERT(offsetof(ConsumeTextureCHROMIUMImmediate, header) == 0, COMPILE_ASSERT(offsetof(ConsumeTextureCHROMIUMImmediate, target) == 4, OffsetOf_ConsumeTextureCHROMIUMImmediate_target_not_4); +struct BindUniformLocationCHROMIUM { + typedef BindUniformLocationCHROMIUM ValueType; + static const CommandId kCmdId = kBindUniformLocationCHROMIUM; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init( + GLuint _program, GLint _location, uint32 _name_shm_id, + uint32 _name_shm_offset, uint32 _data_size) { + SetHeader(); + program = _program; + location = _location; + name_shm_id = _name_shm_id; + name_shm_offset = _name_shm_offset; + data_size = _data_size; + } + + void* Set( + void* cmd, GLuint _program, GLint _location, uint32 _name_shm_id, + uint32 _name_shm_offset, uint32 _data_size) { + static_cast<ValueType*>( + cmd)->Init( + _program, _location, _name_shm_id, _name_shm_offset, _data_size); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + uint32 program; + int32 location; + uint32 name_shm_id; + uint32 name_shm_offset; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(BindUniformLocationCHROMIUM) == 24, + Sizeof_BindUniformLocationCHROMIUM_is_not_24); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, header) == 0, + OffsetOf_BindUniformLocationCHROMIUM_header_not_0); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, program) == 4, + OffsetOf_BindUniformLocationCHROMIUM_program_not_4); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, location) == 8, + OffsetOf_BindUniformLocationCHROMIUM_location_not_8); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, name_shm_id) == 12, + OffsetOf_BindUniformLocationCHROMIUM_name_shm_id_not_12); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, name_shm_offset) == 16, + OffsetOf_BindUniformLocationCHROMIUM_name_shm_offset_not_16); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUM, data_size) == 20, + OffsetOf_BindUniformLocationCHROMIUM_data_size_not_20); + +struct BindUniformLocationCHROMIUMImmediate { + typedef BindUniformLocationCHROMIUMImmediate ValueType; + static const CommandId kCmdId = kBindUniformLocationCHROMIUMImmediate; + static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; + + static uint32 ComputeSize(uint32 data_size) { + return static_cast<uint32>( + sizeof(ValueType) + data_size); // NOLINT + } + + void SetHeader(uint32 data_size) { + header.SetCmdBySize<ValueType>(data_size); + } + + void Init( + GLuint _program, GLint _location, const char* _name, uint32 _data_size) { + SetHeader(_data_size); + program = _program; + location = _location; + data_size = _data_size; + memcpy(ImmediateDataAddress(this), _name, _data_size); + } + + void* Set( + void* cmd, GLuint _program, GLint _location, const char* _name, + uint32 _data_size) { + static_cast<ValueType*>(cmd)->Init(_program, _location, _name, _data_size); + return NextImmediateCmdAddress<ValueType>(cmd, _data_size); + } + + gpu::CommandHeader header; + uint32 program; + int32 location; + uint32 data_size; +}; + +COMPILE_ASSERT(sizeof(BindUniformLocationCHROMIUMImmediate) == 16, + Sizeof_BindUniformLocationCHROMIUMImmediate_is_not_16); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMImmediate, header) == 0, + OffsetOf_BindUniformLocationCHROMIUMImmediate_header_not_0); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMImmediate, program) == 4, + OffsetOf_BindUniformLocationCHROMIUMImmediate_program_not_4); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMImmediate, location) == 8, + OffsetOf_BindUniformLocationCHROMIUMImmediate_location_not_8); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMImmediate, data_size) == 12, + OffsetOf_BindUniformLocationCHROMIUMImmediate_data_size_not_12); + +struct BindUniformLocationCHROMIUMBucket { + typedef BindUniformLocationCHROMIUMBucket ValueType; + static const CommandId kCmdId = kBindUniformLocationCHROMIUMBucket; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program, GLint _location, uint32 _name_bucket_id) { + SetHeader(); + program = _program; + location = _location; + name_bucket_id = _name_bucket_id; + } + + void* Set( + void* cmd, GLuint _program, GLint _location, uint32 _name_bucket_id) { + static_cast<ValueType*>(cmd)->Init(_program, _location, _name_bucket_id); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + uint32 program; + int32 location; + uint32 name_bucket_id; +}; + +COMPILE_ASSERT(sizeof(BindUniformLocationCHROMIUMBucket) == 16, + Sizeof_BindUniformLocationCHROMIUMBucket_is_not_16); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMBucket, header) == 0, + OffsetOf_BindUniformLocationCHROMIUMBucket_header_not_0); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMBucket, program) == 4, + OffsetOf_BindUniformLocationCHROMIUMBucket_program_not_4); +COMPILE_ASSERT(offsetof(BindUniformLocationCHROMIUMBucket, location) == 8, + OffsetOf_BindUniformLocationCHROMIUMBucket_location_not_8); +COMPILE_ASSERT( + offsetof(BindUniformLocationCHROMIUMBucket, name_bucket_id) == 12, + OffsetOf_BindUniformLocationCHROMIUMBucket_name_bucket_id_not_12); // NOLINT + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index bc1485a..7c95789 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3996,5 +3996,74 @@ TEST_F(GLES2FormatTest, ConsumeTextureCHROMIUMImmediate) { // TODO(gman): Check that data was inserted; } +TEST_F(GLES2FormatTest, BindUniformLocationCHROMIUM) { + BindUniformLocationCHROMIUM& cmd = + *GetBufferAs<BindUniformLocationCHROMIUM>(); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + static_cast<uint32>(13), + static_cast<uint32>(14), + static_cast<uint32>(15)); + EXPECT_EQ(static_cast<uint32>(BindUniformLocationCHROMIUM::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLint>(12), cmd.location); + EXPECT_EQ(static_cast<uint32>(13), cmd.name_shm_id); + EXPECT_EQ(static_cast<uint32>(14), cmd.name_shm_offset); + EXPECT_EQ(static_cast<uint32>(15), cmd.data_size); + CheckBytesWrittenMatchesExpectedSize( + next_cmd, sizeof(cmd)); +} + + +TEST_F(GLES2FormatTest, BindUniformLocationCHROMIUMImmediate) { + BindUniformLocationCHROMIUMImmediate& cmd = + *GetBufferAs<BindUniformLocationCHROMIUMImmediate>(); + static const char* const test_str = "test string"; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + test_str, + strlen(test_str)); + EXPECT_EQ(static_cast<uint32>(BindUniformLocationCHROMIUMImmediate::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(strlen(test_str)), + cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd) + + RoundSizeToMultipleOfEntries(strlen(test_str))); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLint>(12), cmd.location); + EXPECT_EQ(static_cast<uint32>(strlen(test_str)), cmd.data_size); + EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str))); + CheckBytesWritten( + next_cmd, + sizeof(cmd) + RoundSizeToMultipleOfEntries(strlen(test_str)), + sizeof(cmd) + strlen(test_str)); +} + +TEST_F(GLES2FormatTest, BindUniformLocationCHROMIUMBucket) { + BindUniformLocationCHROMIUMBucket& cmd = + *GetBufferAs<BindUniformLocationCHROMIUMBucket>(); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLint>(12), + static_cast<uint32>(13)); + EXPECT_EQ(static_cast<uint32>(BindUniformLocationCHROMIUMBucket::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<GLint>(12), cmd.location); + EXPECT_EQ(static_cast<uint32>(13), cmd.name_bucket_id); + CheckBytesWrittenMatchesExpectedSize( + next_cmd, sizeof(cmd)); +} + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index 5102903..decd48b 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -227,6 +227,9 @@ OP(ProduceTextureCHROMIUMImmediate) /* 470 */ \ OP(ConsumeTextureCHROMIUM) /* 471 */ \ OP(ConsumeTextureCHROMIUMImmediate) /* 472 */ \ + OP(BindUniformLocationCHROMIUM) /* 473 */ \ + OP(BindUniformLocationCHROMIUMImmediate) /* 474 */ \ + OP(BindUniformLocationCHROMIUMBucket) /* 475 */ \ enum CommandId { kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index 5cecd2e..ea0bd73 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -758,29 +758,6 @@ 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 859066e..c4fe663 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -146,10 +146,6 @@ 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 6fc3b3d..97b5dba 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc @@ -181,17 +181,6 @@ 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/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index bbb0997..85d044d 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -175,6 +175,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) { bool npot_ok = false; + AddExtensionString("GL_CHROMIUM_bind_uniform_location"); AddExtensionString("GL_CHROMIUM_resource_safe"); AddExtensionString("GL_CHROMIUM_resize"); AddExtensionString("GL_CHROMIUM_strict_attribs"); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 1322fcf..35941ea 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -875,6 +875,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, } void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); + void DoBindUniformLocationCHROMIUM( + GLuint client_id, GLint location, const char* name); error::Error GetAttribLocationHelper( GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, @@ -4023,6 +4025,84 @@ error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( return error::kNoError; } +void GLES2DecoderImpl::DoBindUniformLocationCHROMIUM( + GLuint program, GLint location, const char* name) { + if (!StringIsValidForGLES(name)) { + SetGLError(GL_INVALID_VALUE, + "glBindUniformLocationCHROMIUM", "Invalid character"); + return; + } + if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { + SetGLError(GL_INVALID_OPERATION, + "glBindUniformLocationCHROMIUM", "reserved prefix"); + return; + } + if (location < 0 || static_cast<uint32>(location) >= + (group_->max_fragment_uniform_vectors() + + group_->max_vertex_uniform_vectors()) * 4) { + SetGLError(GL_INVALID_VALUE, + "glBindUniformLocationCHROMIUM", "location out of range"); + return; + } + ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( + program, "glBindUniformLocationCHROMIUM"); + if (!info) { + return; + } + if (!info->SetUniformLocationBinding(name, location)) { + SetGLError(GL_INVALID_VALUE, + "glBindUniformLocationCHROMIUM", "location out of range"); + } +} + +error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUM( + uint32 immediate_data_size, const gles2::BindUniformLocationCHROMIUM& c) { + GLuint program = static_cast<GLuint>(c.program); + GLint location = static_cast<GLint>(c.location); + uint32 name_size = c.data_size; + const char* name = GetSharedMemoryAs<const char*>( + c.name_shm_id, c.name_shm_offset, name_size); + if (name == NULL) { + return error::kOutOfBounds; + } + String name_str(name, name_size); + DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); + return error::kNoError; +} + +error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMImmediate( + uint32 immediate_data_size, + const gles2::BindUniformLocationCHROMIUMImmediate& c) { + GLuint program = static_cast<GLuint>(c.program); + GLint location = static_cast<GLint>(c.location); + uint32 name_size = c.data_size; + const char* name = GetImmediateDataAs<const char*>( + c, name_size, immediate_data_size); + if (name == NULL) { + return error::kOutOfBounds; + } + String name_str(name, name_size); + DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); + return error::kNoError; +} + +error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket( + uint32 immediate_data_size, + const gles2::BindUniformLocationCHROMIUMBucket& c) { + GLuint program = static_cast<GLuint>(c.program); + GLint location = static_cast<GLint>(c.location); + Bucket* bucket = GetBucket(c.name_bucket_id); + if (!bucket || bucket->size() == 0) { + return error::kInvalidArguments; + } + std::string name_str; + if (!bucket->GetAsString(&name_str)) { + return error::kInvalidArguments; + } + DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); + return error::kNoError; +} + error::Error GLES2DecoderImpl::HandleDeleteShader( uint32 immediate_data_size, const gles2::DeleteShader& c) { GLuint client_id = c.shader; @@ -6566,8 +6646,7 @@ error::Error GLES2DecoderImpl::GetUniformLocationHelper( if (*location != -1) { return error::kGenericError; } - *location = GLES2Util::SwizzleLocation( - info->GetUniformFakeLocation(name_str)); + *location = info->GetUniformFakeLocation(name_str); return error::kNoError; } @@ -7875,7 +7954,7 @@ bool GLES2DecoderImpl::GetUniformSetup( error::Error GLES2DecoderImpl::HandleGetUniformiv( uint32 immediate_data_size, const gles2::GetUniformiv& c) { GLuint program = c.program; - GLint fake_location = GLES2Util::UnswizzleLocation(c.location); + GLint fake_location = c.location; GLuint service_id; GLenum result_type; GLint real_location = -1; @@ -7894,7 +7973,7 @@ error::Error GLES2DecoderImpl::HandleGetUniformiv( error::Error GLES2DecoderImpl::HandleGetUniformfv( uint32 immediate_data_size, const gles2::GetUniformfv& c) { GLuint program = c.program; - GLint fake_location = GLES2Util::UnswizzleLocation(c.location); + GLint fake_location = 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 edddf8a..ab06503 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1757,8 +1757,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterivImmediate( error::Error GLES2DecoderImpl::HandleUniform1f( uint32 immediate_data_size, const gles2::Uniform1f& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLfloat x = static_cast<GLfloat>(c.x); GLfloat temp[1] = { x, }; DoUniform1fv(location, 1, &temp[0]); @@ -1767,8 +1766,7 @@ error::Error GLES2DecoderImpl::HandleUniform1f( error::Error GLES2DecoderImpl::HandleUniform1fv( uint32 immediate_data_size, const gles2::Uniform1fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) { @@ -1785,8 +1783,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fv( error::Error GLES2DecoderImpl::HandleUniform1fvImmediate( uint32 immediate_data_size, const gles2::Uniform1fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 1, &data_size)) { @@ -1806,8 +1803,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fvImmediate( error::Error GLES2DecoderImpl::HandleUniform1i( uint32 immediate_data_size, const gles2::Uniform1i& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLint x = static_cast<GLint>(c.x); DoUniform1i(location, x); return error::kNoError; @@ -1815,8 +1811,7 @@ error::Error GLES2DecoderImpl::HandleUniform1i( error::Error GLES2DecoderImpl::HandleUniform1iv( uint32 immediate_data_size, const gles2::Uniform1iv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) { @@ -1833,8 +1828,7 @@ error::Error GLES2DecoderImpl::HandleUniform1iv( error::Error GLES2DecoderImpl::HandleUniform1ivImmediate( uint32 immediate_data_size, const gles2::Uniform1ivImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 1, &data_size)) { @@ -1854,8 +1848,7 @@ error::Error GLES2DecoderImpl::HandleUniform1ivImmediate( error::Error GLES2DecoderImpl::HandleUniform2f( uint32 immediate_data_size, const gles2::Uniform2f& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); GLfloat temp[2] = { x, y, }; @@ -1865,8 +1858,7 @@ error::Error GLES2DecoderImpl::HandleUniform2f( error::Error GLES2DecoderImpl::HandleUniform2fv( uint32 immediate_data_size, const gles2::Uniform2fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) { @@ -1883,8 +1875,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fv( error::Error GLES2DecoderImpl::HandleUniform2fvImmediate( uint32 immediate_data_size, const gles2::Uniform2fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 2, &data_size)) { @@ -1904,8 +1895,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fvImmediate( error::Error GLES2DecoderImpl::HandleUniform2i( uint32 immediate_data_size, const gles2::Uniform2i& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); GLint temp[2] = { x, y, }; @@ -1915,8 +1905,7 @@ error::Error GLES2DecoderImpl::HandleUniform2i( error::Error GLES2DecoderImpl::HandleUniform2iv( uint32 immediate_data_size, const gles2::Uniform2iv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) { @@ -1933,8 +1922,7 @@ error::Error GLES2DecoderImpl::HandleUniform2iv( error::Error GLES2DecoderImpl::HandleUniform2ivImmediate( uint32 immediate_data_size, const gles2::Uniform2ivImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 2, &data_size)) { @@ -1954,8 +1942,7 @@ error::Error GLES2DecoderImpl::HandleUniform2ivImmediate( error::Error GLES2DecoderImpl::HandleUniform3f( uint32 immediate_data_size, const gles2::Uniform3f& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); GLfloat z = static_cast<GLfloat>(c.z); @@ -1966,8 +1953,7 @@ error::Error GLES2DecoderImpl::HandleUniform3f( error::Error GLES2DecoderImpl::HandleUniform3fv( uint32 immediate_data_size, const gles2::Uniform3fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) { @@ -1984,8 +1970,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fv( error::Error GLES2DecoderImpl::HandleUniform3fvImmediate( uint32 immediate_data_size, const gles2::Uniform3fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 3, &data_size)) { @@ -2005,8 +1990,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fvImmediate( error::Error GLES2DecoderImpl::HandleUniform3i( uint32 immediate_data_size, const gles2::Uniform3i& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); GLint z = static_cast<GLint>(c.z); @@ -2017,8 +2001,7 @@ error::Error GLES2DecoderImpl::HandleUniform3i( error::Error GLES2DecoderImpl::HandleUniform3iv( uint32 immediate_data_size, const gles2::Uniform3iv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) { @@ -2035,8 +2018,7 @@ error::Error GLES2DecoderImpl::HandleUniform3iv( error::Error GLES2DecoderImpl::HandleUniform3ivImmediate( uint32 immediate_data_size, const gles2::Uniform3ivImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 3, &data_size)) { @@ -2056,8 +2038,7 @@ error::Error GLES2DecoderImpl::HandleUniform3ivImmediate( error::Error GLES2DecoderImpl::HandleUniform4f( uint32 immediate_data_size, const gles2::Uniform4f& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLfloat x = static_cast<GLfloat>(c.x); GLfloat y = static_cast<GLfloat>(c.y); GLfloat z = static_cast<GLfloat>(c.z); @@ -2069,8 +2050,7 @@ error::Error GLES2DecoderImpl::HandleUniform4f( error::Error GLES2DecoderImpl::HandleUniform4fv( uint32 immediate_data_size, const gles2::Uniform4fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) { @@ -2087,8 +2067,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fv( error::Error GLES2DecoderImpl::HandleUniform4fvImmediate( uint32 immediate_data_size, const gles2::Uniform4fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLfloat), 4, &data_size)) { @@ -2108,8 +2087,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fvImmediate( error::Error GLES2DecoderImpl::HandleUniform4i( uint32 immediate_data_size, const gles2::Uniform4i& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLint x = static_cast<GLint>(c.x); GLint y = static_cast<GLint>(c.y); GLint z = static_cast<GLint>(c.z); @@ -2121,8 +2099,7 @@ error::Error GLES2DecoderImpl::HandleUniform4i( error::Error GLES2DecoderImpl::HandleUniform4iv( uint32 immediate_data_size, const gles2::Uniform4iv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) { @@ -2139,8 +2116,7 @@ error::Error GLES2DecoderImpl::HandleUniform4iv( error::Error GLES2DecoderImpl::HandleUniform4ivImmediate( uint32 immediate_data_size, const gles2::Uniform4ivImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); uint32 data_size; if (!ComputeDataSize(count, sizeof(GLint), 4, &data_size)) { @@ -2160,8 +2136,7 @@ error::Error GLES2DecoderImpl::HandleUniform4ivImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix2fv( uint32 immediate_data_size, const gles2::UniformMatrix2fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; @@ -2184,8 +2159,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fv( error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix2fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; @@ -2211,8 +2185,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix3fv( uint32 immediate_data_size, const gles2::UniformMatrix3fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; @@ -2235,8 +2208,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fv( error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix3fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; @@ -2262,8 +2234,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( error::Error GLES2DecoderImpl::HandleUniformMatrix4fv( uint32 immediate_data_size, const gles2::UniformMatrix4fv& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; @@ -2286,8 +2257,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fv( error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate( uint32 immediate_data_size, const gles2::UniformMatrix4fvImmediate& c) { - GLint location = GLES2Util::UnswizzleLocation( - static_cast<GLint>(c.location)); + GLint location = static_cast<GLint>(c.location); GLsizei count = static_cast<GLsizei>(c.count); GLboolean transpose = static_cast<GLboolean>(c.transpose); uint32 data_size; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 863a7f9..0376efc 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2ElementFakeLocation), + 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, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2ElementFakeLocation), + 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, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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_, - GLES2Util::SwizzleLocation(kUniform2FakeLocation), + 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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 2); + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), + cmd.Init(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( - GLES2Util::SwizzleLocation(kUniform1FakeLocation), + 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(GLES2Util::SwizzleLocation(kUniform1FakeLocation), 1, + cmd.Init(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(GLES2Util::SwizzleLocation(kUniform2FakeLocation), *result); + EXPECT_EQ(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(GLES2Util::SwizzleLocation(kUniform2FakeLocation), *result); + EXPECT_EQ(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(GLES2Util::SwizzleLocation(kUniform2FakeLocation), *result); + EXPECT_EQ(kUniform2FakeLocation, *result); SetBucketAsCString(kBucketId, kNonExistentName); *result = -1; cmd.Init(client_program_id_, kBucketId, @@ -7377,6 +7377,55 @@ TEST_F(GLES2DecoderANGLEManualInitTest, DrawClearsDepthTexture) { EXPECT_EQ(GL_NO_ERROR, GetGLError()); } +TEST_F(GLES2DecoderWithShaderTest, BindUniformLocationCHROMIUM) { + const GLint kLocation = 2; + const char* kName = "testing"; + const uint32 kNameSize = strlen(kName); + const char* kBadName1 = "gl_testing"; + const uint32 kBadName1Size = strlen(kBadName1); + const char* kBadName2 = "testing[1]"; + const uint32 kBadName2Size = strlen(kBadName2); + memcpy(shared_memory_address_, kName, kNameSize); + BindUniformLocationCHROMIUM cmd; + cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, + kNameSize); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + // check negative location + memcpy(shared_memory_address_, kName, kNameSize); + cmd.Init(client_program_id_, -1, kSharedMemoryId, kSharedMemoryOffset, + kNameSize); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); + // check highest location + memcpy(shared_memory_address_, kName, kNameSize); + GLint kMaxLocation = + (kMaxFragmentUniformVectors + kMaxVertexUniformVectors) * 4 - 1; + cmd.Init(client_program_id_, kMaxLocation, kSharedMemoryId, + kSharedMemoryOffset, kNameSize); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + // check too high location + memcpy(shared_memory_address_, kName, kNameSize); + cmd.Init(client_program_id_, kMaxLocation + 1, kSharedMemoryId, + kSharedMemoryOffset, kNameSize); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); + // check bad name "gl_..." + memcpy(shared_memory_address_, kBadName1, kBadName1Size); + cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, + kBadName1Size); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); + // check bad name "name[1]" non zero + memcpy(shared_memory_address_, kBadName2, kBadName2Size); + cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, + kBadName2Size); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); +} + + // TODO(gman): Complete this test. // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { // } 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 1ed5126..c315152 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(GLES2Util::SwizzleLocation(1), 2); + cmd.Init(1, 2); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -711,9 +711,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvValidArgs) { 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform1fv, 0>(true); Uniform1fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -722,9 +720,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -733,7 +729,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -741,9 +737,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); SpecializedSetup<Uniform1fv, 0>(false); Uniform1fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -754,9 +748,8 @@ TEST_F(GLES2DecoderTest2, Uniform1fvValidArgsCountTooLarge) { SpecializedSetup<Uniform1fv, 0>(true); Uniform1fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -769,7 +762,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform1fvImmediate, 0>(true); GLfloat temp[1 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -782,7 +775,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fValidArgs) { EXPECT_CALL(*gl_, Uniform2fv(1, 1, _)); SpecializedSetup<Uniform2f, 0>(true); Uniform2f cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3); + cmd.Init(1, 2, 3); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -793,9 +786,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvValidArgs) { 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform2fv, 0>(true); Uniform2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -804,9 +795,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -815,7 +804,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -823,9 +812,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); SpecializedSetup<Uniform2fv, 0>(false); Uniform2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -836,9 +823,8 @@ TEST_F(GLES2DecoderTest2, Uniform2fvValidArgsCountTooLarge) { SpecializedSetup<Uniform2fv, 0>(true); Uniform2fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -851,7 +837,7 @@ TEST_F(GLES2DecoderTest2, Uniform2fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform2fvImmediate, 0>(true); GLfloat temp[2 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -861,7 +847,7 @@ TEST_F(GLES2DecoderTest2, Uniform2iValidArgs) { EXPECT_CALL(*gl_, Uniform2iv(1, 1, _)); SpecializedSetup<Uniform2i, 0>(true); Uniform2i cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3); + cmd.Init(1, 2, 3); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -872,9 +858,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivValidArgs) { 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform2iv, 0>(true); Uniform2iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -883,9 +867,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -894,7 +876,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -902,9 +884,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); SpecializedSetup<Uniform2iv, 0>(false); Uniform2iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -915,9 +895,8 @@ TEST_F(GLES2DecoderTest2, Uniform2ivValidArgsCountTooLarge) { SpecializedSetup<Uniform2iv, 0>(true); Uniform2iv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -930,7 +909,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform2ivImmediate, 0>(true); GLint temp[2 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -940,7 +919,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fValidArgs) { EXPECT_CALL(*gl_, Uniform3fv(1, 1, _)); SpecializedSetup<Uniform3f, 0>(true); Uniform3f cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4); + cmd.Init(1, 2, 3, 4); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -951,9 +930,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvValidArgs) { 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform3fv, 0>(true); Uniform3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -962,9 +939,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -973,7 +948,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -981,9 +956,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); SpecializedSetup<Uniform3fv, 0>(false); Uniform3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -994,9 +967,8 @@ TEST_F(GLES2DecoderTest2, Uniform3fvValidArgsCountTooLarge) { SpecializedSetup<Uniform3fv, 0>(true); Uniform3fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1009,7 +981,7 @@ TEST_F(GLES2DecoderTest2, Uniform3fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform3fvImmediate, 0>(true); GLfloat temp[3 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1019,7 +991,7 @@ TEST_F(GLES2DecoderTest2, Uniform3iValidArgs) { EXPECT_CALL(*gl_, Uniform3iv(1, 1, _)); SpecializedSetup<Uniform3i, 0>(true); Uniform3i cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4); + cmd.Init(1, 2, 3, 4); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1030,9 +1002,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivValidArgs) { 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform3iv, 0>(true); Uniform3iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1041,9 +1011,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1052,7 +1020,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1060,9 +1028,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); SpecializedSetup<Uniform3iv, 0>(false); Uniform3iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1073,9 +1039,8 @@ TEST_F(GLES2DecoderTest2, Uniform3ivValidArgsCountTooLarge) { SpecializedSetup<Uniform3iv, 0>(true); Uniform3iv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1088,7 +1053,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform3ivImmediate, 0>(true); GLint temp[3 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1098,7 +1063,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fValidArgs) { EXPECT_CALL(*gl_, Uniform4fv(1, 1, _)); SpecializedSetup<Uniform4f, 0>(true); Uniform4f cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4, 5); + cmd.Init(1, 2, 3, 4, 5); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1109,9 +1074,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvValidArgs) { 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); SpecializedSetup<Uniform4fv, 0>(true); Uniform4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1120,9 +1083,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1131,7 +1092,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1139,9 +1100,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); SpecializedSetup<Uniform4fv, 0>(false); Uniform4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1152,9 +1111,8 @@ TEST_F(GLES2DecoderTest2, Uniform4fvValidArgsCountTooLarge) { SpecializedSetup<Uniform4fv, 0>(true); Uniform4fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1167,7 +1125,7 @@ TEST_F(GLES2DecoderTest2, Uniform4fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform4fvImmediate, 0>(true); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1177,7 +1135,7 @@ TEST_F(GLES2DecoderTest2, Uniform4iValidArgs) { EXPECT_CALL(*gl_, Uniform4iv(1, 1, _)); SpecializedSetup<Uniform4i, 0>(true); Uniform4i cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, 3, 4, 5); + cmd.Init(1, 2, 3, 4, 5); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1188,9 +1146,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivValidArgs) { 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); SpecializedSetup<Uniform4iv, 0>(true); Uniform4iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1199,9 +1155,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs1_0) { EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1210,7 +1164,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_0) { EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1218,9 +1172,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_1) { EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); SpecializedSetup<Uniform4iv, 0>(false); Uniform4iv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1231,9 +1183,8 @@ TEST_F(GLES2DecoderTest2, Uniform4ivValidArgsCountTooLarge) { SpecializedSetup<Uniform4iv, 0>(true); Uniform4iv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1246,7 +1197,7 @@ TEST_F(GLES2DecoderTest2, Uniform4ivImmediateValidArgs) { reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<Uniform4ivImmediate, 0>(true); GLint temp[4 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, &temp[0]); + cmd.Init(1, 2, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1259,9 +1210,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgs) { shared_memory_address_))); SpecializedSetup<UniformMatrix2fv, 0>(true); UniformMatrix2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1270,9 +1219,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs1_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1281,9 +1228,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, true, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } @@ -1292,7 +1237,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1300,9 +1245,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_1) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fv, 0>(false); UniformMatrix2fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1314,9 +1257,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix2fv, 0>(true); UniformMatrix2fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1330,7 +1272,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix2fvImmediate, 0>(true); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(1, 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1342,7 +1284,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix2fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix2fvImmediate, 0>(false); GLfloat temp[4 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(1, 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1355,9 +1297,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgs) { shared_memory_address_))); SpecializedSetup<UniformMatrix3fv, 0>(true); UniformMatrix3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1366,9 +1306,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs1_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1377,9 +1315,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, true, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } @@ -1388,7 +1324,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1396,9 +1332,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_1) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fv, 0>(false); UniformMatrix3fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1410,9 +1344,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix3fv, 0>(true); UniformMatrix3fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1426,7 +1359,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix3fvImmediate, 0>(true); GLfloat temp[9 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(1, 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1438,7 +1371,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix3fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix3fvImmediate, 0>(false); GLfloat temp[9 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(1, 2, true, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); @@ -1451,9 +1384,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgs) { shared_memory_address_))); SpecializedSetup<UniformMatrix4fv, 0>(true); UniformMatrix4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1462,9 +1393,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs1_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), -1, false, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, -1, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1473,9 +1402,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, true, shared_memory_id_, shared_memory_offset_); + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } @@ -1484,7 +1411,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, kInvalidSharedMemoryId, 0); + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1492,9 +1419,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_1) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fv, 0>(false); UniformMatrix4fv cmd; - cmd.Init( - GLES2Util::SwizzleLocation( - 1), 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } @@ -1506,9 +1431,8 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvValidArgsCountTooLarge) { SpecializedSetup<UniformMatrix4fv, 0>(true); UniformMatrix4fv cmd; cmd.Init( - GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation( - 1, 1)), 5, false, shared_memory_id_, shared_memory_offset_); + ProgramManager::MakeFakeLocation( + 1, 1), 5, false, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -1522,7 +1446,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateValidArgs) { reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); SpecializedSetup<UniformMatrix4fvImmediate, 0>(true); GLfloat temp[16 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, false, &temp[0]); + cmd.Init(1, 2, false, &temp[0]); EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); EXPECT_EQ(GL_NO_ERROR, GetGLError()); @@ -1534,7 +1458,7 @@ TEST_F(GLES2DecoderTest2, UniformMatrix4fvImmediateInvalidArgs2_0) { EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); SpecializedSetup<UniformMatrix4fvImmediate, 0>(false); GLfloat temp[16 * 2] = { 0, }; - cmd.Init(GLES2Util::SwizzleLocation(1), 2, true, &temp[0]); + cmd.Init(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/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h index ccdc475..12d8e6e 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h @@ -39,5 +39,10 @@ // TODO(gman): ProduceTextureCHROMIUMImmediate // TODO(gman): ConsumeTextureCHROMIUM // TODO(gman): ConsumeTextureCHROMIUMImmediate +// TODO(gman): BindUniformLocationCHROMIUM + +// TODO(gman): BindUniformLocationCHROMIUMImmediate + +// TODO(gman): BindUniformLocationCHROMIUMBucket #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ 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 b4a3df8..ae7c768 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -601,8 +601,8 @@ void GLES2DecoderTestBase::SetupShaderForUniform() { { "goo", 1, GL_FLOAT, 2, }, }; static UniformInfo uniforms[] = { - { "bar", 1, GL_INT, 0, 2, }, - { "car", 4, GL_INT, 1, 1, }, + { "bar", 1, GL_INT, 0, 2, -1, }, + { "car", 4, GL_INT, 1, 1, -1, }, }; const GLuint kClientVertexShaderId = 5001; const GLuint kServiceVertexShaderId = 6001; @@ -1073,6 +1073,9 @@ const GLint GLES2DecoderTestBase::kUniform1FakeLocation; const GLint GLES2DecoderTestBase::kUniform2FakeLocation; const GLint GLES2DecoderTestBase::kUniform2ElementFakeLocation; const GLint GLES2DecoderTestBase::kUniform3FakeLocation; +const GLint GLES2DecoderTestBase::kUniform1DesiredLocation; +const GLint GLES2DecoderTestBase::kUniform2DesiredLocation; +const GLint GLES2DecoderTestBase::kUniform3DesiredLocation; const GLenum GLES2DecoderTestBase::kUniform1Type; const GLenum GLES2DecoderTestBase::kUniform2Type; const GLenum GLES2DecoderTestBase::kUniform3Type; @@ -1098,11 +1101,14 @@ void GLES2DecoderTestBase::SetupDefaultProgram() { }; static UniformInfo uniforms[] = { { kUniform1Name, kUniform1Size, kUniform1Type, - kUniform1FakeLocation, kUniform1RealLocation }, + kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation }, { kUniform2Name, kUniform2Size, kUniform2Type, - kUniform2FakeLocation, kUniform2RealLocation }, + kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation }, { kUniform3Name, kUniform3Size, kUniform3Type, - kUniform3FakeLocation, kUniform3RealLocation }, + kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation }, }; SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms), client_program_id_, kServiceProgramId, @@ -1129,11 +1135,14 @@ void GLES2DecoderTestBase::SetupCubemapProgram() { }; static UniformInfo uniforms[] = { { kUniform1Name, kUniform1Size, kUniformCubemapType, - kUniform1FakeLocation, kUniform1RealLocation, }, + kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation, }, { kUniform2Name, kUniform2Size, kUniform2Type, - kUniform2FakeLocation, kUniform2RealLocation, }, + kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, }, { kUniform3Name, kUniform3Size, kUniform3Type, - kUniform3FakeLocation, kUniform3RealLocation, }, + kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, }, }; SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms), client_program_id_, kServiceProgramId, 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 e310d7f..19b1e85 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -434,6 +434,9 @@ class GLES2DecoderTestBase : public testing::Test { static const GLint kUniform2FakeLocation = 1; // hardcoded static const GLint kUniform2ElementFakeLocation = 0x10001; // to match static const GLint kUniform3FakeLocation = 2; // ProgramManager. + static const GLint kUniform1DesiredLocation = -1; + static const GLint kUniform2DesiredLocation = -1; + static const GLint kUniform3DesiredLocation = -1; static const GLenum kUniform1Type = GL_SAMPLER_2D; static const GLenum kUniform2Type = GL_INT_VEC2; static const GLenum kUniform3Type = GL_FLOAT_VEC3; diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index 0eb90a3..8b94e8b 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -4,7 +4,6 @@ #include "gpu/command_buffer/service/program_manager.h" -#include <algorithm> #include <set> #include <vector> @@ -21,7 +20,9 @@ namespace gpu { namespace gles2 { -static int ShaderTypeToIndex(GLenum shader_type) { +namespace { + +int ShaderTypeToIndex(GLenum shader_type) { switch (shader_type) { case GL_VERTEX_SHADER: return 0; @@ -33,6 +34,51 @@ static int ShaderTypeToIndex(GLenum shader_type) { } } +// Given a name like "foo.bar[123].moo[456]" sets new_name to "foo.bar[123].moo" +// and sets element_index to 456. returns false if element expression was not a +// whole decimal number. For example: "foo[1b2]" +bool GetUniformNameSansElement( + const std::string name, int* element_index, std::string* new_name) { + DCHECK(element_index); + DCHECK(new_name); + if (name.size() < 3 || name[name.size() - 1] != ']') { + *element_index = 0; + *new_name = name; + return true; + } + + // Look for an array specification. + size_t open_pos = name.find_last_of('['); + if (open_pos == std::string::npos || + open_pos >= name.size() - 2) { + return false; + } + + GLint index = 0; + size_t last = name.size() - 1; + for (size_t pos = open_pos + 1; pos < last; ++pos) { + int8 digit = name[pos] - '0'; + if (digit < 0 || digit > 9) { + return false; + } + index = index * 10 + digit; + } + + if (index < 0) { + return false; + } + + *element_index = index; + *new_name = name.substr(0, open_pos); + return true; +} + +} // anonymous namespace. + +ProgramManager::ProgramInfo::UniformInfo::UniformInfo() + : size(0) { +} + ProgramManager::ProgramInfo::UniformInfo::UniformInfo( GLsizei _size, GLenum _type, @@ -63,13 +109,15 @@ ProgramManager::ProgramInfo::ProgramInfo( deleted_(false), valid_(false), link_status_(false), - uniforms_cleared_(false) { + uniforms_cleared_(false), + num_uniforms_(0) { manager_->StartTracking(this); } void ProgramManager::ProgramInfo::Reset() { valid_ = false; link_status_ = false; + num_uniforms_ = 0; max_uniform_name_length_ = 0; max_attrib_name_length_ = 0; attrib_infos_.clear(); @@ -102,6 +150,9 @@ void ProgramManager::ProgramInfo::ClearUniforms( uniforms_cleared_ = true; for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { const UniformInfo& uniform_info = uniform_infos_[ii]; + if (!uniform_info.IsValid()) { + continue; + } GLint location = uniform_info.element_locations[0]; GLsizei size = uniform_info.size; uint32 unit_size = GLES2Util::GetGLDataTypeSizeForUniforms( @@ -167,11 +218,15 @@ void ProgramManager::ProgramInfo::ClearUniforms( namespace { struct UniformData { + UniformData() : size(-1), type(GL_NONE), added(false) { + } std::string queried_name; std::string corrected_name; std::string original_name; GLsizei size; GLenum type; + GLint location; + bool added; }; struct UniformDataComparer { @@ -235,7 +290,7 @@ void ProgramManager::ProgramInfo::Update() { 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 + // Reads all the names. std::vector<UniformData> uniform_data_; for (GLint ii = 0; ii < num_uniforms; ++ii) { GLsizei length = 0; @@ -254,28 +309,50 @@ void ProgramManager::ProgramInfo::Update() { } } - std::sort(uniform_data_.begin(), uniform_data_.end(), UniformDataComparer()); + // NOTE: We don't care if 2 uniforms are bound to the same location. + // One of them will take preference. The spec allows this, same as + // BindAttribLocation. + // + // The reason we don't check is if we were to fail we'd have to + // restore the previous program but since we've already linked successfully + // at this point the previous program is gone. + // Assigns the uniforms with bindings. + size_t next_available_index = 0; for (size_t ii = 0; ii < uniform_data_.size(); ++ii) { - const UniformData& data = uniform_data_[ii]; - GLint location = glGetUniformLocation( + UniformData& data = uniform_data_[ii]; + data.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); + // remove "[0]" + std::string short_name; + int element_index = 0; + bool good ALLOW_UNUSED = GetUniformNameSansElement( + data.queried_name, &element_index, &short_name);\ + DCHECK(good); + LocationMap::const_iterator it = bind_uniform_location_map_.find( + short_name); + if (it != bind_uniform_location_map_.end()) { + data.added = AddUniformInfo( + data.size, data.type, data.location, it->second, data.corrected_name, + data.original_name, &next_available_index); + } + } + + // Assigns the uniforms that were not bound. + for (size_t ii = 0; ii < uniform_data_.size(); ++ii) { + const UniformData& data = uniform_data_[ii]; + if (!data.added) { + AddUniformInfo( + data.size, data.type, data.location, -1, data.corrected_name, + data.original_name, &next_available_index); } - max_uniform_name_length_ = - std::max(max_uniform_name_length_, - static_cast<GLsizei>(info->name.size())); } + valid_ = true; } void ProgramManager::ProgramInfo::ExecuteBindAttribLocationCalls() { - for (std::map<std::string, GLint>::const_iterator it = - bind_attrib_location_map_.begin(); + for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); it != bind_attrib_location_map_.end(); ++it) { const std::string* mapped_name = GetAttribMappedName(it->first); if (mapped_name && *mapped_name != it->first) @@ -318,6 +395,9 @@ 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.IsValid()) { + continue; + } if (info.name == name || (info.is_array && info.name.compare(0, info.name.size() - 3, name) == 0)) { @@ -342,7 +422,8 @@ GLint ProgramManager::ProgramInfo::GetUniformFakeLocation( index = index * 10 + digit; } if (!bad && index >= 0 && index < info.size) { - return GLES2Util::MakeFakeLocation(info.fake_location_base, index); + return ProgramManager::MakeFakeLocation( + info.fake_location_base, index); } } } @@ -374,6 +455,9 @@ const ProgramManager::ProgramInfo::UniformInfo* if (uniform_index >= 0 && static_cast<size_t>(uniform_index) < uniform_infos_.size()) { const UniformInfo& uniform_info = uniform_infos_[uniform_index]; + if (!uniform_info.IsValid()) { + return NULL; + } GLint element_index = GetArrayElementIndexFromFakeLocation(fake_location); if (element_index < uniform_info.size) { *real_location = uniform_info.element_locations[element_index]; @@ -398,6 +482,19 @@ const std::string* ProgramManager::ProgramInfo::GetAttribMappedName( return NULL; } +bool ProgramManager::ProgramInfo::SetUniformLocationBinding( + const std::string& name, GLint location) { + std::string short_name; + int element_index = 0; + if (!GetUniformNameSansElement(name, &element_index, &short_name) || + element_index != 0) { + return false; + } + + bind_uniform_location_map_[short_name] = location; + return true; +} + // Note: This is only valid to call right after a program has been linked // successfully. void ProgramManager::ProgramInfo::GetCorrectedVariableInfo( @@ -435,15 +532,29 @@ void ProgramManager::ProgramInfo::GetCorrectedVariableInfo( *original_name = name; } -const ProgramManager::ProgramInfo::UniformInfo* - ProgramManager::ProgramInfo::AddUniformInfo( - GLsizei size, GLenum type, GLint location, - const std::string& name, const std::string& original_name) { +bool ProgramManager::ProgramInfo::AddUniformInfo( + GLsizei size, GLenum type, GLint location, GLint fake_base_location, + const std::string& name, const std::string& original_name, + size_t* next_available_index) { + DCHECK(next_available_index); const char* kArraySpec = "[0]"; - int uniform_index = uniform_infos_.size(); - uniform_infos_.push_back( - UniformInfo(size, type, uniform_index, original_name)); - UniformInfo& info = uniform_infos_.back(); + size_t uniform_index = + fake_base_location >= 0 ? fake_base_location : *next_available_index; + if (uniform_infos_.size() < uniform_index + 1) { + uniform_infos_.resize(uniform_index + 1); + } + + // return if this location is already in use. + if (uniform_infos_[uniform_index].IsValid()) { + DCHECK_GE(fake_base_location, 0); + return false; + } + + uniform_infos_[uniform_index] = UniformInfo( + size, type, uniform_index, original_name); + ++num_uniforms_; + + UniformInfo& info = uniform_infos_[uniform_index]; info.element_locations.resize(size); info.element_locations[0] = location; DCHECK_GE(size, 0); @@ -476,7 +587,30 @@ const ProgramManager::ProgramInfo::UniformInfo* (info.name.size() > 3 && info.name.rfind(kArraySpec) == info.name.size() - 3)); - return &info; + 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())); + + while (*next_available_index < uniform_infos_.size() && + uniform_infos_[*next_available_index].IsValid()) { + *next_available_index = *next_available_index + 1; + } + + return true; +} + +const ProgramManager::ProgramInfo::UniformInfo* + ProgramManager::ProgramInfo::GetUniformInfo( + GLint index) const { + if (static_cast<size_t>(index) >= uniform_infos_.size()) { + return NULL; + } + + const UniformInfo& info = uniform_infos_[index]; + return info.IsValid() ? &info : NULL; } bool ProgramManager::ProgramInfo::SetSamplers( @@ -489,6 +623,9 @@ bool ProgramManager::ProgramInfo::SetSamplers( if (uniform_index >= 0 && static_cast<size_t>(uniform_index) < uniform_infos_.size()) { UniformInfo& info = uniform_infos_[uniform_index]; + if (!info.IsValid()) { + return false; + } GLint element_index = GetArrayElementIndexFromFakeLocation(fake_location); if (element_index < info.size) { count = std::min(info.size - element_index, count); @@ -517,7 +654,7 @@ void ProgramManager::ProgramInfo::GetProgramiv(GLenum pname, GLint* params) { *params = max_attrib_name_length_ + 1; break; case GL_ACTIVE_UNIFORMS: - *params = uniform_infos_.size(); + *params = num_uniforms_; break; case GL_ACTIVE_UNIFORM_MAX_LENGTH: // Notice +1 to accomodate NULL terminator. @@ -593,8 +730,7 @@ bool ProgramManager::ProgramInfo::CanLink() const { bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const { std::set<GLint> location_binding_used; - for (std::map<std::string, GLint>::const_iterator it = - bind_attrib_location_map_.begin(); + for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); it != bind_attrib_location_map_.end(); ++it) { // Find out if an attribute is declared in this program's shaders. bool active = false; @@ -638,11 +774,13 @@ void ProgramManager::ProgramInfo::GetProgramInfo( for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { const UniformInfo& info = uniform_infos_[ii]; - num_locations += info.element_locations.size(); - total_string_size += info.name.size(); + if (info.IsValid()) { + num_locations += info.element_locations.size(); + total_string_size += info.name.size(); + } } - uint32 num_inputs = attrib_infos_.size() + uniform_infos_.size(); + uint32 num_inputs = attrib_infos_.size() + num_uniforms_; uint32 input_size = num_inputs * sizeof(ProgramInput); uint32 location_size = num_locations * sizeof(int32); uint32 size = sizeof(ProgramInfoHeader) + @@ -664,7 +802,7 @@ void ProgramManager::ProgramInfo::GetProgramInfo( header->link_status = link_status_; header->num_attribs = attrib_infos_.size(); - header->num_uniforms = uniform_infos_.size(); + header->num_uniforms = num_uniforms_; for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { const VertexAttribInfo& info = attrib_infos_[ii]; @@ -681,19 +819,20 @@ void ProgramManager::ProgramInfo::GetProgramInfo( for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { const UniformInfo& info = uniform_infos_[ii]; - inputs->size = info.size; - inputs->type = info.type; - inputs->location_offset = ComputeOffset(header, locations); - inputs->name_offset = ComputeOffset(header, strings); - 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++ = GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation(ii, jj)); + if (info.IsValid()) { + inputs->size = info.size; + inputs->type = info.type; + inputs->location_offset = ComputeOffset(header, locations); + inputs->name_offset = ComputeOffset(header, strings); + 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++ = ProgramManager::MakeFakeLocation(ii, jj); + } + memcpy(strings, info.name.c_str(), info.name.size()); + strings += info.name.size(); + ++inputs; } - memcpy(strings, info.name.c_str(), info.name.size()); - strings += info.name.size(); - ++inputs; } DCHECK_EQ(ComputeOffset(header, strings), size); @@ -823,6 +962,10 @@ void ProgramManager::ClearUniforms(ProgramManager::ProgramInfo* info) { } } +int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { + return index + element * 0x10000; +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h index d2655cc..964b933 100644 --- a/gpu/command_buffer/service/program_manager.h +++ b/gpu/command_buffer/service/program_manager.h @@ -36,11 +36,16 @@ class GPU_EXPORT ProgramManager { static const int kMaxAttachedShaders = 2; struct UniformInfo { + UniformInfo(); UniformInfo( GLsizei _size, GLenum _type, GLint _fake_location_base, const std::string& _name); ~UniformInfo(); + bool IsValid() const { + return size != 0; + } + bool IsSampler() const { return type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES; @@ -103,10 +108,7 @@ class GPU_EXPORT ProgramManager { return NULL; } - const UniformInfo* GetUniformInfo(GLint index) const { - return (static_cast<size_t>(index) < uniform_infos_.size()) ? - &uniform_infos_[index] : NULL; - } + const UniformInfo* GetUniformInfo(GLint index) const; // If the original name is not found, return NULL. const std::string* GetAttribMappedName( @@ -163,11 +165,14 @@ class GPU_EXPORT ProgramManager { } // Sets attribute-location binding from a glBindAttribLocation() call. - void SetAttribLocationBinding(const std::string& attrib, - GLint location) { + void SetAttribLocationBinding(const std::string& attrib, GLint location) { bind_attrib_location_map_[attrib] = location; } + // Sets uniform-location binding from a glBindUniformLocationCHROMIUM call. + // returns false if error. + bool SetUniformLocationBinding(const std::string& name, GLint location); + // Detects if there are attribute location conflicts from // glBindAttribLocation() calls. // We only consider the declared attributes in the program. @@ -177,6 +182,8 @@ class GPU_EXPORT ProgramManager { friend class base::RefCounted<ProgramInfo>; friend class ProgramManager; + typedef std::map<std::string, GLint> LocationMap; + ~ProgramInfo(); void set_log_info(const char* str) { @@ -219,9 +226,10 @@ class GPU_EXPORT ProgramManager { // translated. void ExecuteBindAttribLocationCalls(); - const UniformInfo* AddUniformInfo( - GLsizei size, GLenum type, GLint location, - const std::string& name, const std::string& original_name); + bool AddUniformInfo( + GLsizei size, GLenum type, GLint location, GLint fake_base_location, + const std::string& name, const std::string& original_name, + size_t* next_available_index); void GetCorrectedVariableInfo( bool use_uniforms, const std::string& name, std::string* corrected_name, @@ -277,11 +285,18 @@ class GPU_EXPORT ProgramManager { // True if the uniforms have been cleared. bool uniforms_cleared_; + // This is different than uniform_infos_.size() because + // that is a sparce array. + GLint num_uniforms_; + // Log info scoped_ptr<std::string> log_info_; // attribute-location binding map from glBindAttribLocation() calls. - std::map<std::string, GLint> bind_attrib_location_map_; + LocationMap bind_attrib_location_map_; + + // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. + LocationMap bind_uniform_location_map_; }; ProgramManager(); @@ -317,6 +332,8 @@ class GPU_EXPORT ProgramManager { // Check if a ProgramInfo is owned by this ProgramManager. bool IsOwned(ProgramInfo* info); + static int32 MakeFakeLocation(int32 index, int32 element); + private: void StartTracking(ProgramInfo* info); void StopTracking(ProgramInfo* info); diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc index c05113f..8dca84d 100644 --- a/gpu/command_buffer/service/program_manager_unittest.cc +++ b/gpu/command_buffer/service/program_manager_unittest.cc @@ -179,6 +179,9 @@ class ProgramManagerWithShaderTest : public testing::Test { static const GLint kUniform1RealLocation = 11; static const GLint kUniform2RealLocation = 22; static const GLint kUniform3RealLocation = 33; + static const GLint kUniform1DesiredLocation = -1; + static const GLint kUniform2DesiredLocation = -1; + static const GLint kUniform3DesiredLocation = -1; static const GLenum kUniform1Type = GL_FLOAT_VEC4; static const GLenum kUniform2Type = GL_INT_VEC2; static const GLenum kUniform3Type = GL_FLOAT_VEC3; @@ -300,6 +303,9 @@ const GLint ProgramManagerWithShaderTest::kUniform3FakeLocation; const GLint ProgramManagerWithShaderTest::kUniform1RealLocation; const GLint ProgramManagerWithShaderTest::kUniform2RealLocation; const GLint ProgramManagerWithShaderTest::kUniform3RealLocation; +const GLint ProgramManagerWithShaderTest::kUniform1DesiredLocation; +const GLint ProgramManagerWithShaderTest::kUniform2DesiredLocation; +const GLint ProgramManagerWithShaderTest::kUniform3DesiredLocation; const GLenum ProgramManagerWithShaderTest::kUniform1Type; const GLenum ProgramManagerWithShaderTest::kUniform2Type; const GLenum ProgramManagerWithShaderTest::kUniform3Type; @@ -317,6 +323,7 @@ ProgramManagerWithShaderTest::UniformInfo kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, @@ -324,6 +331,7 @@ ProgramManagerWithShaderTest::UniformInfo kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, kUniform2Name, }, { kUniform3BadName, @@ -331,6 +339,7 @@ ProgramManagerWithShaderTest::UniformInfo kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, kUniform3GoodName, }, }; @@ -483,12 +492,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(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 1), + EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 1), program_info->GetUniformFakeLocation("uniform2[1]")); - EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 2), + EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 2), program_info->GetUniformFakeLocation("uniform2[2]")); EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform2[3]")); - EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform3FakeLocation, 1), + EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform3FakeLocation, 1), program_info->GetUniformFakeLocation("uniform3[1]")); EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform3[2]")); } @@ -533,6 +542,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, @@ -540,6 +550,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, kUniform2Name, }, { kUniform3BadName, @@ -547,6 +558,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, kUniform3GoodName, }, }; @@ -635,6 +647,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, @@ -642,6 +655,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { kUniform2BadType, kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, kUniform2Name, }, { kUniform3BadName, @@ -649,6 +663,7 @@ TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, kUniform3GoodName, }, }; @@ -835,8 +850,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(GLES2Util::SwizzleLocation( - GLES2Util::MakeFakeLocation(expected.fake_location, jj)), + EXPECT_EQ( + ProgramManager::MakeFakeLocation(expected.fake_location, jj), locations[jj]); } const char* name_buf = bucket.GetDataAs<const char*>( @@ -958,6 +973,7 @@ TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { kUniform1Type, kUniform1FakeLocation, kUniform1RealLocation, + kUniform1DesiredLocation, kUniform1Name, }, { kUniform2Name, @@ -965,6 +981,7 @@ TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { kSamplerTypes[ii], kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, kUniform2Name, }, { kUniform3BadName, @@ -972,6 +989,7 @@ TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, kUniform3GoodName, }, }; @@ -985,73 +1003,80 @@ TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { } } -TEST_F(ProgramManagerWithShaderTest, UniformsAreSorted) { +TEST_F(ProgramManagerWithShaderTest, BindUniformLocation) { const GLuint kVShaderClientId = 2001; const GLuint kFShaderClientId = 2002; const GLuint kVShaderServiceId = 3001; const GLuint kFShaderServiceId = 3002; + + const GLint kUniform1DesiredLocation = 10; + const GLint kUniform2DesiredLocation = -1; + const GLint kUniform3DesiredLocation = 5; + ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); ASSERT_TRUE(vshader != NULL); - vshader->SetStatus(true, "", NULL); + vshader->SetStatus(true, NULL, NULL); ShaderManager::ShaderInfo* fshader = shader_manager_.CreateShaderInfo( kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); ASSERT_TRUE(fshader != NULL); - fshader->SetStatus(true, "", NULL); + fshader->SetStatus(true, NULL, NULL); + static const GLuint kClientProgramId = 1234; + static const GLuint kServiceProgramId = 5679; + 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)); + EXPECT_TRUE(program_info->SetUniformLocationBinding( + kUniform1Name, kUniform1DesiredLocation)); + EXPECT_TRUE(program_info->SetUniformLocationBinding( + kUniform3BadName, kUniform3DesiredLocation)); + static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, }; - static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { + ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { + { kUniform1Name, + kUniform1Size, + kUniform1Type, + kUniform1FakeLocation, + kUniform1RealLocation, + kUniform1DesiredLocation, + kUniform1Name, + }, { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2FakeLocation, kUniform2RealLocation, + kUniform2DesiredLocation, kUniform2Name, }, - { kUniform3GoodName, + { kUniform3BadName, kUniform3Size, kUniform3Type, kUniform3FakeLocation, kUniform3RealLocation, + kUniform3DesiredLocation, kUniform3GoodName, }, - { kUniform1Name, - kUniform1Size, - kUniform1Type, - kUniform1FakeLocation, - kUniform1RealLocation, - kUniform1Name, - }, }; - const size_t kNumAttribs= arraysize(kAttribs); + + 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); + + EXPECT_EQ(kUniform1DesiredLocation, + program_info->GetUniformFakeLocation(kUniform1Name)); + EXPECT_EQ(kUniform3DesiredLocation, + program_info->GetUniformFakeLocation(kUniform3BadName)); + EXPECT_EQ(kUniform3DesiredLocation, + program_info->GetUniformFakeLocation(kUniform3GoodName)); } } // namespace gles2 diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc index 33a1703..bd95c4f7 100644 --- a/gpu/command_buffer/service/test_helper.cc +++ b/gpu/command_buffer/service/test_helper.cc @@ -12,7 +12,6 @@ #include "gpu/command_buffer/service/program_manager.h" #include "testing/gtest/include/gtest/gtest.h" -#include <algorithm> #include <string.h> using ::testing::_; @@ -369,17 +368,6 @@ 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, @@ -436,9 +424,6 @@ void TestHelper::SetupShader( .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; @@ -460,33 +445,37 @@ void TestHelper::SetupShader( SetArrayArgument<6>(info.name, info.name + strlen(info.name) + 1))) .RetiresOnSaturation(); - if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { - 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 (int pass = 0; pass < 2; ++pass) { + for (size_t ii = 0; ii < num_uniforms; ++ii) { + const UniformInfo& info = uniforms[ii]; + if (ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { + continue; } - 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)) + if (pass == 0) { + EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name))) + .WillOnce(Return(info.real_location)) .RetiresOnSaturation(); } + if ((pass == 0 && info.desired_location >= 0) || + (pass == 1 && info.desired_location < 0)) { + 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(); + } + } + } } } } diff --git a/gpu/command_buffer/service/test_helper.h b/gpu/command_buffer/service/test_helper.h index 7515e6c..c0dd80f 100644 --- a/gpu/command_buffer/service/test_helper.h +++ b/gpu/command_buffer/service/test_helper.h @@ -52,6 +52,7 @@ class TestHelper { GLenum type; GLint fake_location; GLint real_location; + GLint desired_location; const char* good_name; }; diff --git a/gpu/command_buffer/tests/gl_consistent_uniform_locations_unittest.cc b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc index e5f7dc3..f942c15 100644 --- a/gpu/command_buffer/tests/gl_consistent_uniform_locations_unittest.cc +++ b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc @@ -14,7 +14,7 @@ namespace gpu { -class ConsistenUniformLocationsTest : public testing::Test { +class BindUniformLocationTest : public testing::Test { protected: static const GLsizei kResolution = 4; virtual void SetUp() { @@ -28,18 +28,9 @@ class ConsistenUniformLocationsTest : public testing::Test { GLManager gl_; }; -namespace { - -struct FormatType { - GLenum format; - GLenum type; -}; - -} // anonymous namespace - -TEST_F(ConsistenUniformLocationsTest, Basic) { +TEST_F(BindUniformLocationTest, Basic) { ASSERT_TRUE( - GLTestHelper::HasExtension("GL_CHROMIUM_consistent_uniform_locations")); + GLTestHelper::HasExtension("GL_CHROMIUM_bind_uniform_location")); static const char* v_shader_str = SHADER( attribute vec4 a_position; @@ -59,23 +50,29 @@ TEST_F(ConsistenUniformLocationsTest, Basic) { } ); - static const GLUniformDefinitionCHROMIUM defs[] = { - { GL_FLOAT_VEC4, 1, "u_colorC", }, - { GL_FLOAT_VEC4, 2, "u_colorB", }, - { GL_FLOAT_VEC4, 1, "u_colorA", }, - }; + GLint color_a_location = 3; + GLint color_b_location = 10; + GLint color_c_location = 5; - GLuint program = GLTestHelper::LoadProgram(v_shader_str, f_shader_str); + GLuint vertex_shader = GLTestHelper::LoadShader( + GL_VERTEX_SHADER, v_shader_str); + GLuint fragment_shader = GLTestHelper::LoadShader( + GL_FRAGMENT_SHADER, f_shader_str); - GLint locations[4]; + GLuint program = glCreateProgram(); - glGetUniformLocationsCHROMIUM( - program, defs, arraysize(defs), arraysize(locations), locations); + glBindUniformLocationCHROMIUM(program, color_a_location, "u_colorA"); + glBindUniformLocationCHROMIUM(program, color_b_location, "u_colorB[0]"); + glBindUniformLocationCHROMIUM(program, color_c_location, "u_colorC"); - GLint u_colorCLocation = locations[0]; - GLint u_colorB0Location = locations[1]; - GLint u_colorB1Location = locations[2]; - GLint u_colorALocation = locations[3]; + glAttachShader(program, vertex_shader); + glAttachShader(program, fragment_shader); + // Link the program + glLinkProgram(program); + // Check the link status + GLint linked = 0; + glGetProgramiv(program, GL_LINK_STATUS, &linked); + EXPECT_EQ(1, linked); GLint position_loc = glGetAttribLocation(program, "a_position"); @@ -83,10 +80,13 @@ TEST_F(ConsistenUniformLocationsTest, Basic) { 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); + static const float color_b[] = { + 0.0f, 0.50f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.75f, 0.0f, + }; + glUniform4f(color_a_location, 0.25f, 0.0f, 0.0f, 0.0f); + glUniform4fv(color_b_location, 2, color_b); + glUniform4f(color_c_location, 0.0f, 0.0f, 0.0f, 1.0f); glDrawArrays(GL_TRIANGLES, 0, 6); diff --git a/gpu/gpu_common.gypi b/gpu/gpu_common.gypi index 2e425f9..6e19802 100644 --- a/gpu/gpu_common.gypi +++ b/gpu/gpu_common.gypi @@ -232,9 +232,9 @@ 'sources': [ '<@(gles2_c_lib_source_files)', 'command_buffer/tests/occlusion_query_unittests.cc', + 'command_buffer/tests/gl_bind_uniform_location_unittest.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', |