summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 04:25:48 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 04:25:48 +0000
commit87d1a3fef11f647b8c2273de0736b9a5df40e913 (patch)
treee3e5f748057f7a107642746a8f84627a3c340602 /gpu
parent5b87b300558e4c24f384cbffdf12bc66b0f7ba00 (diff)
downloadchromium_src-87d1a3fef11f647b8c2273de0736b9a5df40e913.zip
chromium_src-87d1a3fef11f647b8c2273de0736b9a5df40e913.tar.gz
chromium_src-87d1a3fef11f647b8c2273de0736b9a5df40e913.tar.bz2
Rebind to correct backbuffer after clearing READ buffer.
BUG=none TEST=unit tests R=jbates@chromium.org Review URL: http://codereview.chromium.org/8756001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc9
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc60
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc45
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h49
4 files changed, 141 insertions, 22 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index e2d60da..3de264c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -3979,10 +3979,11 @@ void GLES2DecoderImpl::ClearUnclearedAttachments(
if (target == GL_READ_FRAMEBUFFER_EXT) {
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, info->service_id());
- FramebufferManager::FramebufferInfo*framebuffer =
- GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER);
- glBindFramebufferEXT(
- GL_DRAW_FRAMEBUFFER_EXT, framebuffer ? framebuffer->service_id() : 0);
+ FramebufferManager::FramebufferInfo* framebuffer =
+ GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
+ GLuint service_id =
+ framebuffer ? framebuffer->service_id() : GetBackbufferServiceId();
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id);
}
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 25d96c7..9e587be 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -5459,6 +5459,66 @@ TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
+TEST_F(GLES2DecoderManualInitTest,
+ UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) {
+ InitDecoder(
+ "GL_EXT_framebuffer_multisample", // extensions
+ false, // has alpha
+ false, // has depth
+ false, // has stencil
+ false, // request alpha
+ false, // request depth
+ false, // request stencil
+ true); // bind generates resource
+ const GLuint kFBOClientTextureId = 4100;
+ const GLuint kFBOServiceTextureId = 4101;
+
+ // Register a texture id.
+ EXPECT_CALL(*gl_, GenTextures(_, _))
+ .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
+ .RetiresOnSaturation();
+ GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
+
+ // Setup "render from" texture.
+ DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId);
+ DoTexImage2D(
+ GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
+ DoBindFramebuffer(
+ GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
+ DoFramebufferTexture2D(
+ GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR);
+
+ SetupExpectationsForFramebufferClearingMulti(
+ kServiceFramebufferId, // read framebuffer service id
+ 0, // backbuffer service id
+ GL_READ_FRAMEBUFFER, // target
+ GL_COLOR_BUFFER_BIT, // clear bits
+ 0, 0, 0, 0, // color
+ 0, // stencil
+ 1.0f, // depth
+ false); // scissor test
+
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _))
+ .Times(1)
+ .RetiresOnSaturation();
+ typedef ReadPixels::Result Result;
+ uint32 result_shm_id = kSharedMemoryId;
+ uint32 result_shm_offset = kSharedMemoryOffset;
+ uint32 pixels_shm_id = kSharedMemoryId;
+ uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result);
+ ReadPixels cmd;
+ cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
+ pixels_shm_id, pixels_shm_offset,
+ result_shm_id, result_shm_offset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) {
SetupTexture();
DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
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 9010fb9..3a7c29d 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -344,11 +344,46 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearing(
GLuint restore_stencil,
GLclampf restore_depth,
bool restore_scissor_test) {
+ SetupExpectationsForFramebufferClearingMulti(
+ 0,
+ 0,
+ target,
+ clear_bits,
+ restore_red,
+ restore_green,
+ restore_blue,
+ restore_alpha,
+ restore_stencil,
+ restore_depth,
+ restore_scissor_test);
+}
+
+void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearingMulti(
+ GLuint read_framebuffer_service_id,
+ GLuint draw_framebuffer_service_id,
+ 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) {
// TODO(gman): Figure out why InSequence stopped working.
// InSequence sequence;
EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(target))
.WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
.RetiresOnSaturation();
+ if (target == GL_READ_FRAMEBUFFER_EXT) {
+ EXPECT_CALL(*gl_, BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindFramebufferEXT(
+ GL_DRAW_FRAMEBUFFER_EXT, read_framebuffer_service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
if ((clear_bits & GL_COLOR_BUFFER_BIT) != 0) {
EXPECT_CALL(*gl_, ClearColor(0.0f, 0.0f, 0.0f, 0.0f))
.Times(1)
@@ -394,6 +429,16 @@ void GLES2DecoderTestBase::SetupExpectationsForFramebufferClearing(
.Times(1)
.RetiresOnSaturation();
}
+ if (target == GL_READ_FRAMEBUFFER_EXT) {
+ EXPECT_CALL(*gl_, BindFramebufferEXT(
+ GL_READ_FRAMEBUFFER_EXT, read_framebuffer_service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindFramebufferEXT(
+ GL_DRAW_FRAMEBUFFER_EXT, draw_framebuffer_service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
}
void GLES2DecoderTestBase::SetupShaderForUniform() {
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 f98aea4..92abfc0 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -326,26 +326,39 @@ class GLES2DecoderTestBase : public testing::Test {
GLsizei 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);
+ 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 SetupExpectationsForFramebufferClearingMulti(
+ GLuint read_framebuffer_service_id,
+ GLuint draw_framebuffer_service_id,
+ 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 SetupExpectationsForApplyingDirtyState(
- bool framebuffer_is_rgb,
- bool framebuffer_has_depth,
- bool framebuffer_has_stencil,
- GLuint color_bits, // NOTE! bits are 0x1000, 0x0100, 0x0010, and 0x0001
- bool depth_mask,
- bool depth_enabled,
- GLuint front_stencil_mask,
- GLuint back_stencil_mask,
- bool stencil_enabled);
+ bool framebuffer_is_rgb,
+ bool framebuffer_has_depth,
+ bool framebuffer_has_stencil,
+ GLuint color_bits, // NOTE! bits are 0x1000, 0x0100, 0x0010, and 0x0001
+ bool depth_mask,
+ bool depth_enabled,
+ GLuint front_stencil_mask,
+ GLuint back_stencil_mask,
+ bool stencil_enabled);
void SetupExpectationsForApplyingDefaultDirtyState();