diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 19:09:32 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-27 19:09:32 +0000 |
commit | 71f1d10c0878554ec80c6ca7092417ebab21c069 (patch) | |
tree | b1712eae070d6009f256e3bfa25f34414acbfba3 /gpu | |
parent | 00c8782f343fe3e3fc12c62e72237bcfd06d982e (diff) | |
download | chromium_src-71f1d10c0878554ec80c6ca7092417ebab21c069.zip chromium_src-71f1d10c0878554ec80c6ca7092417ebab21c069.tar.gz chromium_src-71f1d10c0878554ec80c6ca7092417ebab21c069.tar.bz2 |
Revert "Revert 169641 - Cache resource bindings on client"
This reverts commit 7ced098111694ae800d0a54fc889ef9f6e81a3e3.
BUG=160370
TBR=apatrick@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11316191
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169702 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
5 files changed, 149 insertions, 61 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 88eaa4e..32e53f4 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1159,7 +1159,6 @@ _FUNCTION_INFO = { 'type': 'Bind', 'decoder_func': 'DoBindBuffer', 'gen_func': 'GenBuffersARB', - 'impl_func': False, }, 'BindFramebuffer': { 'type': 'Bind', @@ -1177,6 +1176,8 @@ _FUNCTION_INFO = { 'type': 'Bind', 'decoder_func': 'DoBindTexture', 'gen_func': 'GenTextures', + # TODO(gman): remove this once client side caching works. + 'client_test': False, }, 'BlitFramebufferEXT': { 'decoder_func': 'DoBlitFramebufferEXT', @@ -1976,7 +1977,11 @@ _FUNCTION_INFO = { 'client_test': False, 'pepper_interface': 'ChromiumMapSub', }, - 'UseProgram': {'decoder_func': 'DoUseProgram', 'unit_test': False}, + 'UseProgram': { + 'decoder_func': 'DoUseProgram', + 'impl_func': False, + 'unit_test': False, + }, 'ValidateProgram': {'decoder_func': 'DoValidateProgram'}, 'VertexAttrib1f': {'decoder_func': 'DoVertexAttrib1f'}, 'VertexAttrib1fv': { @@ -3463,8 +3468,9 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); return; } - Bind%(type)sHelper(%(arg_string)s); - helper_->%(name)s(%(arg_string)s); + if (Bind%(type)sHelper(%(arg_string)s)) { + helper_->%(name)s(%(arg_string)s); + } } """ @@ -3484,6 +3490,39 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { 'lc_type': name_arg.resource_type.lower(), }) + def WriteGLES2ImplementationUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + client_test = func.GetInfo('client_test') + if client_test == False: + return + code = """ +TEST_F(GLES2ImplementationTest, %(name)s) { + struct Cmds { + %(name)s cmd; + }; + Cmds expected; + expected.cmd.Init(%(cmd_args)s); + + gl_->%(name)s(%(args)s); + EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + ClearCommands(); + gl_->%(name)s(%(args)s); + EXPECT_TRUE(NoCommandsWritten()); +} +""" + cmd_arg_strings = [] + for count, arg in enumerate(func.GetCmdArgs()): + cmd_arg_strings.append(arg.GetValidClientSideCmdArg(func, count, 0)) + count += 1 + gl_arg_strings = [] + for count, arg in enumerate(func.GetOriginalArgs()): + gl_arg_strings.append(arg.GetValidClientSideArg(func, count, 0)) + file.Write(code % { + 'name': func.name, + 'args': ", ".join(gl_arg_strings), + 'cmd_args': ", ".join(cmd_arg_strings), + }) + class GENnHandler(TypeHandler): """Handler for glGen___ type functions.""" diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index e45a4bc..8fc6e75 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -438,6 +438,7 @@ GLES2Implementation::GLES2Implementation( active_texture_unit_(0), bound_framebuffer_(0), bound_renderbuffer_(0), + current_program_(0), bound_array_buffer_id_(0), bound_element_array_buffer_id_(0), bound_pixel_unpack_transfer_buffer_id_(0), @@ -1226,20 +1227,6 @@ void GLES2Implementation::BindUniformLocationCHROMIUM( helper_->SetBucketSize(kResultBucketId, 0); } -void GLES2Implementation::BindBuffer(GLenum target, GLuint buffer) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindBuffer(" - << GLES2Util::GetStringBufferTarget(target) << ", " - << buffer << ")"); - if (IsBufferReservedId(buffer)) { - SetGLError(GL_INVALID_OPERATION, "BindBuffer", "buffer reserved id"); - return; - } - BindBufferHelper(target, buffer); - if (target != GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) - helper_->BindBuffer(target, buffer); -} - void GLES2Implementation::GetVertexAttribPointerv( GLuint index, GLenum pname, void** ptr) { GPU_CLIENT_SINGLE_THREAD_CHECK(); @@ -1280,6 +1267,9 @@ bool GLES2Implementation::DeleteProgramHelper(GLuint program) { "glDeleteProgram", "id not created by this context."); return false; } + if (program == current_program_) { + current_program_ = 0; + } return true; } @@ -1365,6 +1355,15 @@ GLint GLES2Implementation::GetUniformLocation( return loc; } +void GLES2Implementation::UseProgram(GLuint program) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUseProgram(" << program << ")"); + if (current_program_ != program) { + current_program_ = program; + helper_->UseProgram(program); + } +} + bool GLES2Implementation::GetProgramivHelper( GLuint program, GLenum pname, GLint* params) { bool got_value = share_group_->program_info_manager()->GetProgramiv( @@ -2484,80 +2483,116 @@ void GLES2Implementation::ActiveTexture(GLenum texture) { // the old model but possibly not true in the new model if another context has // deleted the resource. -void GLES2Implementation::BindBufferHelper( +bool GLES2Implementation::BindBufferHelper( GLenum target, GLuint buffer) { // TODO(gman): See note #1 above. + bool changed = false; switch (target) { case GL_ARRAY_BUFFER: - bound_array_buffer_id_ = buffer; + if (bound_array_buffer_id_ != buffer) { + bound_array_buffer_id_ = buffer; + changed = true; + } break; case GL_ELEMENT_ARRAY_BUFFER: - bound_element_array_buffer_id_ = buffer; + if (bound_element_array_buffer_id_ != buffer) { + bound_element_array_buffer_id_ = buffer; + changed = true; + } break; case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: bound_pixel_unpack_transfer_buffer_id_ = buffer; break; default: + changed = true; break; } // TODO(gman): There's a bug here. If the target is invalid the ID will not be // used even though it's marked it as used here. GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer); + return changed; } -void GLES2Implementation::BindFramebufferHelper( +bool GLES2Implementation::BindFramebufferHelper( GLenum target, GLuint framebuffer) { // TODO(gman): See note #1 above. + bool changed = false; switch (target) { case GL_FRAMEBUFFER: - bound_framebuffer_ = framebuffer; + if (bound_framebuffer_ != framebuffer) { + bound_framebuffer_ = framebuffer; + changed = true; + } break; default: + changed = true; break; } // TODO(gman): There's a bug here. If the target is invalid the ID will not be // used even though it's marked it as used here. GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer); + return changed; } -void GLES2Implementation::BindRenderbufferHelper( +bool GLES2Implementation::BindRenderbufferHelper( GLenum target, GLuint renderbuffer) { // TODO(gman): See note #1 above. + bool changed = false; switch (target) { case GL_RENDERBUFFER: - bound_renderbuffer_ = renderbuffer; + if (bound_renderbuffer_ != renderbuffer) { + bound_renderbuffer_ = renderbuffer; + changed = true; + } break; default: + changed = true; break; } // TODO(gman): There's a bug here. If the target is invalid the ID will not be // used even though it's marked it as used here. GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer); + return changed; } -void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { +bool GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { // TODO(gman): See note #1 above. + // TODO(gman): Change this to false once we figure out why it's failing + // on daisy. + bool changed = true; TextureUnit& unit = texture_units_[active_texture_unit_]; switch (target) { case GL_TEXTURE_2D: - unit.bound_texture_2d = texture; + if (unit.bound_texture_2d != texture) { + unit.bound_texture_2d = texture; + changed = true; + } break; case GL_TEXTURE_CUBE_MAP: - unit.bound_texture_cube_map = texture; + if (unit.bound_texture_cube_map != texture) { + unit.bound_texture_cube_map = texture; + changed = true; + } break; default: + changed = true; break; } // TODO(gman): There's a bug here. If the target is invalid the ID will not be // used. even though it's marked it as used here. GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture); + return changed; } -void GLES2Implementation::BindVertexArrayHelper(GLuint array) { +bool GLES2Implementation::BindVertexArrayHelper(GLuint array) { // TODO(gman): See note #1 above. - bound_vertex_array_id_ = array; - + bool changed = false; + if (bound_vertex_array_id_ != array) { + bound_vertex_array_id_ = array; + changed = true; + } GetIdHandler(id_namespaces::kVertexArrays)->MarkAsUsedForBind(array); + return changed; } #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 016c73a..0f9b765 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -383,11 +383,11 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { bool IsTextureReservedId(GLuint id) { return false; } bool IsVertexArrayReservedId(GLuint id) { return false; } - void BindBufferHelper(GLenum target, GLuint texture); - void BindFramebufferHelper(GLenum target, GLuint texture); - void BindRenderbufferHelper(GLenum target, GLuint texture); - void BindTextureHelper(GLenum target, GLuint texture); - void BindVertexArrayHelper(GLuint array); + bool BindBufferHelper(GLenum target, GLuint texture); + bool BindFramebufferHelper(GLenum target, GLuint texture); + bool BindRenderbufferHelper(GLenum target, GLuint texture); + bool BindTextureHelper(GLenum target, GLuint texture); + bool BindVertexArrayHelper(GLuint array); void DeleteBuffersHelper(GLsizei n, const GLuint* buffers); void DeleteFramebuffersHelper(GLsizei n, const GLuint* framebuffers); @@ -509,6 +509,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation : public GLES2Interface { GLuint bound_framebuffer_; GLuint bound_renderbuffer_; + // The program in use by glUseProgram + GLuint current_program_; + // The currently bound array buffer. GLuint bound_array_buffer_id_; diff --git a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h index 10a76a6..4ce044e 100644 --- a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h @@ -17,6 +17,18 @@ void GLES2Implementation::AttachShader(GLuint program, GLuint shader) { helper_->AttachShader(program, shader); } +void GLES2Implementation::BindBuffer(GLenum target, GLuint buffer) { + GPU_CLIENT_SINGLE_THREAD_CHECK(); + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindBuffer(" << GLES2Util::GetStringBufferTarget(target) << ", " << buffer << ")"); // NOLINT + if (IsBufferReservedId(buffer)) { + SetGLError(GL_INVALID_OPERATION, "BindBuffer", "buffer reserved id"); + return; + } + if (BindBufferHelper(target, buffer)) { + helper_->BindBuffer(target, buffer); + } +} + void GLES2Implementation::BindFramebuffer(GLenum target, GLuint framebuffer) { GPU_CLIENT_SINGLE_THREAD_CHECK(); GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindFramebuffer(" << GLES2Util::GetStringFrameBufferTarget(target) << ", " << framebuffer << ")"); // NOLINT @@ -25,8 +37,9 @@ void GLES2Implementation::BindFramebuffer(GLenum target, GLuint framebuffer) { GL_INVALID_OPERATION, "BindFramebuffer", "framebuffer reserved id"); return; } - BindFramebufferHelper(target, framebuffer); - helper_->BindFramebuffer(target, framebuffer); + if (BindFramebufferHelper(target, framebuffer)) { + helper_->BindFramebuffer(target, framebuffer); + } } void GLES2Implementation::BindRenderbuffer( @@ -38,8 +51,9 @@ void GLES2Implementation::BindRenderbuffer( GL_INVALID_OPERATION, "BindRenderbuffer", "renderbuffer reserved id"); return; } - BindRenderbufferHelper(target, renderbuffer); - helper_->BindRenderbuffer(target, renderbuffer); + if (BindRenderbufferHelper(target, renderbuffer)) { + helper_->BindRenderbuffer(target, renderbuffer); + } } void GLES2Implementation::BindTexture(GLenum target, GLuint texture) { @@ -49,8 +63,9 @@ void GLES2Implementation::BindTexture(GLenum target, GLuint texture) { SetGLError(GL_INVALID_OPERATION, "BindTexture", "texture reserved id"); return; } - BindTextureHelper(target, texture); - helper_->BindTexture(target, texture); + if (BindTextureHelper(target, texture)) { + helper_->BindTexture(target, texture); + } } void GLES2Implementation::BlendColor( @@ -1181,12 +1196,6 @@ void GLES2Implementation::UniformMatrix4fv( helper_->UniformMatrix4fvImmediate(location, count, transpose, value); } -void GLES2Implementation::UseProgram(GLuint program) { - GPU_CLIENT_SINGLE_THREAD_CHECK(); - GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUseProgram(" << program << ")"); - helper_->UseProgram(program); -} - void GLES2Implementation::ValidateProgram(GLuint program) { GPU_CLIENT_SINGLE_THREAD_CHECK(); GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glValidateProgram(" << program << ")"); // NOLINT @@ -1415,8 +1424,9 @@ void GLES2Implementation::BindVertexArrayOES(GLuint array) { GL_INVALID_OPERATION, "BindVertexArrayOES", "array reserved id"); return; } - BindVertexArrayHelper(array); - helper_->BindVertexArrayOES(array); + if (BindVertexArrayHelper(array)) { + helper_->BindVertexArrayOES(array); + } } void GLES2Implementation::GetTranslatedShaderSourceANGLE( diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h index 2366a42..879e47a 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h @@ -33,6 +33,9 @@ TEST_F(GLES2ImplementationTest, BindBuffer) { gl_->BindBuffer(GL_ARRAY_BUFFER, 2); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + ClearCommands(); + gl_->BindBuffer(GL_ARRAY_BUFFER, 2); + EXPECT_TRUE(NoCommandsWritten()); } TEST_F(GLES2ImplementationTest, BindFramebuffer) { @@ -44,6 +47,9 @@ TEST_F(GLES2ImplementationTest, BindFramebuffer) { gl_->BindFramebuffer(GL_FRAMEBUFFER, 2); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + ClearCommands(); + gl_->BindFramebuffer(GL_FRAMEBUFFER, 2); + EXPECT_TRUE(NoCommandsWritten()); } TEST_F(GLES2ImplementationTest, BindRenderbuffer) { @@ -55,17 +61,9 @@ TEST_F(GLES2ImplementationTest, BindRenderbuffer) { gl_->BindRenderbuffer(GL_RENDERBUFFER, 2); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); -} - -TEST_F(GLES2ImplementationTest, BindTexture) { - struct Cmds { - BindTexture cmd; - }; - Cmds expected; - expected.cmd.Init(GL_TEXTURE_2D, 2); - - gl_->BindTexture(GL_TEXTURE_2D, 2); - EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + ClearCommands(); + gl_->BindRenderbuffer(GL_RENDERBUFFER, 2); + EXPECT_TRUE(NoCommandsWritten()); } TEST_F(GLES2ImplementationTest, BlendColor) { @@ -1645,6 +1643,9 @@ TEST_F(GLES2ImplementationTest, BindVertexArrayOES) { gl_->BindVertexArrayOES(1); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); + ClearCommands(); + gl_->BindVertexArrayOES(1); + EXPECT_TRUE(NoCommandsWritten()); } // TODO: Implement unit test for GenSharedIdsCHROMIUM // TODO: Implement unit test for DeleteSharedIdsCHROMIUM |