diff options
author | reveman <reveman@chromium.org> | 2015-06-08 22:14:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-09 05:15:46 +0000 |
commit | 842a0983ef88f1dd426fb841e90e3c180455288f (patch) | |
tree | 06821e8e5044a2be074face428c1fb29fe39a3dc /gpu | |
parent | 43fd86763b002480899f10184fbaba6c9581d889 (diff) | |
download | chromium_src-842a0983ef88f1dd426fb841e90e3c180455288f.zip chromium_src-842a0983ef88f1dd426fb841e90e3c180455288f.tar.gz chromium_src-842a0983ef88f1dd426fb841e90e3c180455288f.tar.bz2 |
gpu: Make sure we restore scissor rect after clearing a texture level.
BUG=460288
TEST=gpu_unittests
Review URL: https://codereview.chromium.org/1168213003
Cr-Commit-Position: refs/heads/master@{#333451}
Diffstat (limited to 'gpu')
5 files changed, 139 insertions, 102 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 607db13..964fc2f 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -5713,9 +5713,10 @@ void GLES2DecoderImpl::RestoreClearState() { state_.color_clear_alpha); glClearStencil(state_.stencil_clear); glClearDepth(state_.depth_clear); - if (state_.enable_flags.scissor_test) { - state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); - } + state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, + state_.enable_flags.scissor_test); + glScissor(state_.scissor_x, state_.scissor_y, state_.scissor_width, + state_.scissor_height); } GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { @@ -8958,7 +8959,6 @@ bool GLES2DecoderImpl::ClearLevel(Texture* texture, glScissor(xoffset, yoffset, width, height); glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); - state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); RestoreClearState(); glDeleteFramebuffersEXT(1, &fb); 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 cfe01c5..40f37a2 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -692,19 +692,16 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearing( GLclampf restore_alpha, GLuint restore_stencil, GLclampf restore_depth, - bool restore_scissor_test) { + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height) { SetupExpectationsForFramebufferClearingMulti( - 0, - 0, - target, - clear_bits, - restore_red, - restore_green, - restore_blue, - restore_alpha, - restore_stencil, - restore_depth, - restore_scissor_test); + 0, 0, target, clear_bits, restore_red, restore_green, restore_blue, + restore_alpha, restore_stencil, restore_depth, restore_scissor_test, + restore_scissor_x, restore_scissor_y, restore_scissor_width, + restore_scissor_height); } void GLES2DecoderTestBase::SetupExpectationsForRestoreClearState( @@ -714,7 +711,11 @@ void GLES2DecoderTestBase::SetupExpectationsForRestoreClearState( GLclampf restore_alpha, GLuint restore_stencil, GLclampf restore_depth, - bool restore_scissor_test) { + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height) { EXPECT_CALL(*gl_, ClearColor( restore_red, restore_green, restore_blue, restore_alpha)) .Times(1) @@ -725,11 +726,11 @@ void GLES2DecoderTestBase::SetupExpectationsForRestoreClearState( EXPECT_CALL(*gl_, ClearDepth(restore_depth)) .Times(1) .RetiresOnSaturation(); - if (restore_scissor_test) { - EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); - } + SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, restore_scissor_test); + EXPECT_CALL(*gl_, Scissor(restore_scissor_x, restore_scissor_y, + restore_scissor_width, restore_scissor_height)) + .Times(1) + .RetiresOnSaturation(); } void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearingMulti( @@ -743,7 +744,11 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearingMulti( GLclampf restore_alpha, GLuint restore_stencil, GLclampf restore_depth, - bool restore_scissor_test) { + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height) { // TODO(gman): Figure out why InSequence stopped working. // InSequence sequence; EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(target)) @@ -783,8 +788,9 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearingMulti( .Times(1) .RetiresOnSaturation(); SetupExpectationsForRestoreClearState( - restore_red, restore_green, restore_blue, restore_alpha, - restore_stencil, restore_depth, restore_scissor_test); + restore_red, restore_green, restore_blue, restore_alpha, restore_stencil, + restore_depth, restore_scissor_test, restore_scissor_x, restore_scissor_y, + restore_scissor_width, restore_scissor_height); if (target == GL_READ_FRAMEBUFFER_EXT) { EXPECT_CALL(*gl_, BindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, read_framebuffer_service_id)) @@ -1676,6 +1682,18 @@ void GLES2DecoderTestBase::DoBufferSubData( EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } +void GLES2DecoderTestBase::DoScissor(GLint x, + GLint y, + GLsizei width, + GLsizei height) { + EXPECT_CALL(*gl_, Scissor(x, y, width, height)) + .Times(1) + .RetiresOnSaturation(); + cmds::Scissor cmd; + cmd.Init(x, y, width, height); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); +} + void GLES2DecoderTestBase::SetupVertexBuffer() { DoEnableVertexAttribArray(1); DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); 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 3104e05..42a44e2 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -327,6 +327,8 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool> { void DoBufferSubData( GLenum target, GLint offset, GLsizei size, const void* data); + void DoScissor(GLint x, GLint y, GLsizei width, GLsizei height); + void SetupVertexBuffer(); void SetupAllNeededVertexBuffers(); @@ -349,25 +351,31 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool> { GLsizei width, GLsizei height); - void SetupExpectationsForRestoreClearState( - GLclampf restore_red, - GLclampf restore_green, - GLclampf restore_blue, - GLclampf restore_alpha, - GLuint restore_stencil, - GLclampf restore_depth, - bool restore_scissor_test); - - void SetupExpectationsForFramebufferClearing( - GLenum target, - GLuint clear_bits, - GLclampf restore_red, - GLclampf restore_green, - GLclampf restore_blue, - GLclampf restore_alpha, - GLuint restore_stencil, - GLclampf restore_depth, - bool restore_scissor_test); + void SetupExpectationsForRestoreClearState(GLclampf restore_red, + GLclampf restore_green, + GLclampf restore_blue, + GLclampf restore_alpha, + GLuint restore_stencil, + GLclampf restore_depth, + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height); + + void SetupExpectationsForFramebufferClearing(GLenum target, + GLuint clear_bits, + GLclampf restore_red, + GLclampf restore_green, + GLclampf restore_blue, + GLclampf restore_alpha, + GLuint restore_stencil, + GLclampf restore_depth, + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height); void SetupExpectationsForFramebufferClearingMulti( GLuint read_framebuffer_service_id, @@ -380,7 +388,11 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool> { GLclampf restore_alpha, GLuint restore_stencil, GLclampf restore_depth, - bool restore_scissor_test); + bool restore_scissor_test, + GLint restore_scissor_x, + GLint restore_scissor_y, + GLsizei restore_scissor_width, + GLsizei restore_scissor_height); void SetupExpectationsForDepthMask(bool mask); void SetupExpectationsForEnableDisable(GLenum cap, bool enable); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc index dfcccf5..579e84b 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc @@ -1912,19 +1912,20 @@ TEST_P(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) { kFBOServiceTextureId, 0, GL_NO_ERROR); + DoEnableDisable(GL_SCISSOR_TEST, false); + DoScissor(0, 0, 1, 1); // Setup "render from" texture. SetupTexture(); SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + false, // scissor test + 0, 0, 1, 1); SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB false, // Framebuffer has depth @@ -2003,16 +2004,17 @@ TEST_P(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) { client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); + DoEnableDisable(GL_SCISSOR_TEST, false); + DoScissor(0, 0, 1, 1); SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + false, // scissor test + 0, 0, 1, 1); AddExpectationsForSimulatedAttrib0(kNumVertices, 0); SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB @@ -2138,18 +2140,18 @@ TEST_P(GLES2DecoderWithShaderTest, client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); - + DoEnableDisable(GL_SCISSOR_TEST, false); + DoScissor(0, 0, 1, 1); SetupTexture(); SetupExpectationsForFramebufferClearing( GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + false, // scissor test + 0, 0, 1, 1); AddExpectationsForSimulatedAttrib0(kNumVertices, 0); SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB @@ -2270,8 +2272,9 @@ TEST_P(GLES2DecoderManualInitTest, DrawClearsDepthTexture) { 0, 0); - // Disable GL_SCISSOR_TEST to make sure we enable it in the clear, - // then disable it again. + // Set scissor rect and disable GL_SCISSOR_TEST to make sure we enable it in + // the clear, then disable it and restore the rect again. + DoScissor(0, 0, 32, 32); DoEnableDisable(GL_SCISSOR_TEST, false); EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); @@ -2296,14 +2299,13 @@ TEST_P(GLES2DecoderManualInitTest, DrawClearsDepthTexture) { GLES2Decoder::kDefaultStencilMask); EXPECT_CALL(*gl_, ClearDepth(1.0f)).Times(1).RetiresOnSaturation(); SetupExpectationsForDepthMask(true); - EXPECT_CALL(*gl_, Scissor(0.0f, 0.0f, 1.0f, 1.0f)) - .Times(1) - .RetiresOnSaturation(); + SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, true); + EXPECT_CALL(*gl_, Scissor(0, 0, 1, 1)).Times(1).RetiresOnSaturation(); EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)).Times(1).RetiresOnSaturation(); - EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)).Times(1).RetiresOnSaturation(); - SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, true); + SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, false, + 0, 0, 32, 32); EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)).Times(1).RetiresOnSaturation(); EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc index 4255ffa..6e47194 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc @@ -1675,19 +1675,22 @@ TEST_P(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) { kFBOServiceTextureId, 0, GL_NO_ERROR); + // Set scissor rect and enable GL_SCISSOR_TEST to make sure we re-enable it + // and restore the rect again after the clear. + DoEnableDisable(GL_SCISSOR_TEST, true); + DoScissor(0, 0, 64, 64); // Setup "render from" texture. SetupTexture(); SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + true, // scissor test + 0, 0, 64, 64); SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB false, // Framebuffer has depth false, // Framebuffer has stencil @@ -1729,19 +1732,20 @@ TEST_P(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) { kFBOServiceTextureId, 0, GL_NO_ERROR); + DoEnableDisable(GL_SCISSOR_TEST, false); + DoScissor(0, 0, 1, 1); // Setup "render from" texture. SetupTexture(); SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + false, // scissor test + 0, 0, 1, 1); EXPECT_CALL(*gl_, GetError()) .WillOnce(Return(GL_NO_ERROR)) @@ -1800,22 +1804,22 @@ TEST_P(GLES2DecoderManualInitTest, 0, GL_NO_ERROR); - // Enable GL_SCISSOR_TEST to make sure we disable it in the clear, - // then re-enable after. - DoEnableDisable(GL_SCISSOR_TEST, true); + // Set scissor rect and disable GL_SCISSOR_TEST to make sure we enable it in + // the clear, then disable it and restore the rect again. + DoScissor(0, 0, 32, 32); + DoEnableDisable(GL_SCISSOR_TEST, false); SetupExpectationsForFramebufferClearingMulti( kServiceFramebufferId, // read framebuffer service id 0, // backbuffer service id GL_READ_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, + 0, 0, 0, 0, // color 0, // stencil 1.0f, // depth - true); // scissor test + false, // scissor test + 0, 0, 32, 32); EXPECT_CALL(*gl_, GetError()) .WillOnce(Return(GL_NO_ERROR)) @@ -2201,19 +2205,20 @@ TEST_P(GLES2DecoderManualInitTest, kFBOServiceTextureId, 0, GL_NO_ERROR); + DoEnableDisable(GL_SCISSOR_TEST, false); + DoScissor(0, 0, 1, 1); // Setup "render from" texture. SetupTexture(); SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target GL_COLOR_BUFFER_BIT, // clear bits - 0, - 0, - 0, - 0, // color - 0, // stencil - 1.0f, // depth - false); // scissor test + 0, 0, 0, + 0, // color + 0, // stencil + 1.0f, // depth + false, // scissor test + 0, 0, 1, 1); SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB false, // Framebuffer has depth false, // Framebuffer has stencil |