diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-12 02:29:24 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-12 02:29:24 +0000 |
commit | 3dc69c43f26e1aa23039262d307fa7874664d4f4 (patch) | |
tree | d83ba1fe9a44cbe50a29a9b8b1d054fe487de5eb /gpu | |
parent | 15a28fd05ef7f31a705078b35539cc62a4cf603b (diff) | |
download | chromium_src-3dc69c43f26e1aa23039262d307fa7874664d4f4.zip chromium_src-3dc69c43f26e1aa23039262d307fa7874664d4f4.tar.gz chromium_src-3dc69c43f26e1aa23039262d307fa7874664d4f4.tar.bz2 |
Fix cmd buf impl of glIsEnabled to return cached value
Since we lazily set certain states we need to return
the cached value.
TEST=unit tests
BUG=127809
R=zmo@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10392053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
10 files changed, 66 insertions, 18 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index f0087c8..eae991f 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -339,10 +339,10 @@ _ENUM_LISTS = { 'Capability': { 'type': 'GLenum', 'valid': [ + 'GL_DITHER', # 1st one is a non-cached value so autogen unit tests work. 'GL_BLEND', 'GL_CULL_FACE', 'GL_DEPTH_TEST', - 'GL_DITHER', 'GL_POLYGON_OFFSET_FILL', 'GL_SAMPLE_ALPHA_TO_COVERAGE', 'GL_SAMPLE_COVERAGE', @@ -1243,7 +1243,10 @@ _FUNCTION_INFO = { 'decoder_func': 'DoIsBuffer', 'expectation': False, }, - 'IsEnabled': {'type': 'Is'}, + 'IsEnabled': { + 'type': 'Is', + 'decoder_func': 'DoIsEnabled', + }, 'IsFramebuffer': { 'type': 'Is', 'decoder_func': 'DoIsFramebuffer', diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 4e59049..b578d7d 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1581,3 +1581,4 @@ void ConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { } #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ + diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h index 8c714bc..6a1c15d 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h @@ -371,9 +371,9 @@ TEST_F(GLES2ImplementationTest, Disable) { Disable cmd; }; Cmds expected; - expected.cmd.Init(GL_BLEND); + expected.cmd.Init(GL_DITHER); - gl_->Disable(GL_BLEND); + gl_->Disable(GL_DITHER); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } @@ -404,9 +404,9 @@ TEST_F(GLES2ImplementationTest, Enable) { Enable cmd; }; Cmds expected; - expected.cmd.Init(GL_BLEND); + expected.cmd.Init(GL_DITHER); - gl_->Enable(GL_BLEND); + gl_->Enable(GL_DITHER); EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); } diff --git a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h index bea92a4..dc2012d 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h @@ -621,10 +621,10 @@ std::string GLES2Util::GetStringBufferUsage(uint32 value) { std::string GLES2Util::GetStringCapability(uint32 value) { static EnumToString string_table[] = { + { GL_DITHER, "GL_DITHER" }, { GL_BLEND, "GL_BLEND" }, { GL_CULL_FACE, "GL_CULL_FACE" }, { GL_DEPTH_TEST, "GL_DEPTH_TEST" }, - { GL_DITHER, "GL_DITHER" }, { GL_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL" }, { GL_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE" }, { GL_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE" }, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 916d792..c7b56b8 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1087,6 +1087,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint *params); // Wrappers for glIsXXX functions. + bool DoIsEnabled(GLenum cap); bool DoIsBuffer(GLuint client_id); bool DoIsFramebuffer(GLuint client_id); bool DoIsProgram(GLuint client_id); @@ -4153,6 +4154,23 @@ void GLES2DecoderImpl::DoEnable(GLenum cap) { } } +bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { + switch (cap) { + case GL_BLEND: + return enable_blend_; + case GL_CULL_FACE: + return enable_cull_face_; + case GL_SCISSOR_TEST: + return enable_scissor_test_; + case GL_DEPTH_TEST: + return enable_depth_test_; + case GL_STENCIL_TEST: + return enable_stencil_test_; + default: + return glIsEnabled(cap) != 0; + } +} + void GLES2DecoderImpl::DoClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { clear_red_ = red; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 49ec263..91e1118 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1358,7 +1358,7 @@ error::Error GLES2DecoderImpl::HandleIsEnabled( SetGLError(GL_INVALID_ENUM, "glIsEnabled: cap GL_INVALID_ENUM"); return error::kNoError; } - *result_dst = glIsEnabled(cap); + *result_dst = DoIsEnabled(cap); return error::kNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 9627b31..861a838 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -6984,6 +6984,32 @@ TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { EXPECT_EQ(kServiceTextureId, info->service_id()); } +TEST_F(GLES2DecoderTest, IsEnabledReturnsCachedValue) { + // NOTE: There are no expectations because no GL functions should be + // called for DEPTH_TEST or STENCIL_TEST + static const GLenum kStates[] = { + GL_DEPTH_TEST, + GL_STENCIL_TEST, + }; + for (size_t ii = 0; ii < arraysize(kStates); ++ii) { + Enable enable_cmd; + GLenum state = kStates[ii]; + enable_cmd.Init(state); + EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); + IsEnabled::Result* result = + static_cast<IsEnabled::Result*>(shared_memory_address_); + IsEnabled is_enabled_cmd; + is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); + EXPECT_NE(0u, *result); + Disable disable_cmd; + disable_cmd.Init(state); + EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); + EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); + EXPECT_EQ(0u, *result); + } +} + // TODO(gman): Complete this test. // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { // } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h index 6d6749b..495b16a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h @@ -669,10 +669,10 @@ TEST_F(GLES2DecoderTest1, DetachShaderValidArgs) { } TEST_F(GLES2DecoderTest1, DisableValidArgs) { - EXPECT_CALL(*gl_, Disable(GL_BLEND)); + EXPECT_CALL(*gl_, Disable(GL_DITHER)); SpecializedSetup<Disable, 0>(true); Disable cmd; - cmd.Init(GL_BLEND); + cmd.Init(GL_DITHER); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -709,10 +709,10 @@ TEST_F(GLES2DecoderTest1, DisableVertexAttribArrayValidArgs) { TEST_F(GLES2DecoderTest1, EnableValidArgs) { - EXPECT_CALL(*gl_, Enable(GL_BLEND)); + EXPECT_CALL(*gl_, Enable(GL_DITHER)); SpecializedSetup<Enable, 0>(true); Enable cmd; - cmd.Init(GL_BLEND); + cmd.Init(GL_DITHER); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } 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 6a62607..33bf614 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 @@ -91,10 +91,10 @@ TEST_F(GLES2DecoderTest2, IsBufferInvalidArgsBadSharedMemoryId) { } TEST_F(GLES2DecoderTest2, IsEnabledValidArgs) { - EXPECT_CALL(*gl_, IsEnabled(GL_BLEND)); + EXPECT_CALL(*gl_, IsEnabled(GL_DITHER)); SpecializedSetup<IsEnabled, 0>(true); IsEnabled cmd; - cmd.Init(GL_BLEND, shared_memory_id_, shared_memory_offset_); + cmd.Init(GL_DITHER, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); EXPECT_EQ(GL_NO_ERROR, GetGLError()); } @@ -118,12 +118,12 @@ TEST_F(GLES2DecoderTest2, IsEnabledInvalidArgs0_1) { } TEST_F(GLES2DecoderTest2, IsEnabledInvalidArgsBadSharedMemoryId) { - EXPECT_CALL(*gl_, IsEnabled(GL_BLEND)).Times(0); + EXPECT_CALL(*gl_, IsEnabled(GL_DITHER)).Times(0); SpecializedSetup<IsEnabled, 0>(false); IsEnabled cmd; - cmd.Init(GL_BLEND, kInvalidSharedMemoryId, shared_memory_offset_); + cmd.Init(GL_DITHER, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); - cmd.Init(GL_BLEND, shared_memory_id_, kInvalidSharedMemoryOffset); + cmd.Init(GL_DITHER, shared_memory_id_, kInvalidSharedMemoryOffset); EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); } diff --git a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h index 44cee12..18e5136 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h @@ -37,10 +37,10 @@ static GLenum valid_buffer_usage_table[] = { }; static GLenum valid_capability_table[] = { + GL_DITHER, GL_BLEND, GL_CULL_FACE, GL_DEPTH_TEST, - GL_DITHER, GL_POLYGON_OFFSET_FILL, GL_SAMPLE_ALPHA_TO_COVERAGE, GL_SAMPLE_COVERAGE, |