diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 01:55:57 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 01:55:57 +0000 |
commit | 74c1ec481b33194dc7a428f2d58fc89640b313ae (patch) | |
tree | 46b1a16de3a9a74c768fe5ab157eb22ebc8006c0 /gpu | |
parent | a37263d12b0bbbf092aded50fb1e8086cf4397ab (diff) | |
download | chromium_src-74c1ec481b33194dc7a428f2d58fc89640b313ae.zip chromium_src-74c1ec481b33194dc7a428f2d58fc89640b313ae.tar.gz chromium_src-74c1ec481b33194dc7a428f2d58fc89640b313ae.tar.bz2 |
Fix glGetFramebufferAttachmentParameteriv so it returns
current names for buffers.
TEST=unit_tests and conformance tests
BUG=none
Review URL: http://codereview.chromium.org/3135003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
4 files changed, 261 insertions, 153 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 1a41b9a..a2966ff 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -2972,6 +2972,25 @@ void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( return; } glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); + if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { + GLint type = 0; + GLuint client_id = 0; + glGetFramebufferAttachmentParameterivEXT( + target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); + switch (type) { + case GL_RENDERBUFFER: { + renderbuffer_manager()->GetClientId(*params, &client_id); + break; + } + case GL_TEXTURE: { + texture_manager()->GetClientId(*params, &client_id); + break; + } + default: + break; + } + *params = client_id; + } } void GLES2DecoderImpl::DoGetRenderbufferParameteriv( diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 4a37678..200f079 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1227,6 +1227,114 @@ TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } +TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithRenderbuffer) { + DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, + kServiceFramebufferId); + EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, + kServiceRenderbufferId)) + .Times(1) + .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + GL_COLOR_BUFFER_BIT, // clear bits + 0, 0, 0, 0, // color + 0x1111, // color bits + 0, // stencil + -1, // stencil mask back, + -1, // stencil mask front, + 1.0f, // depth + 1, // depth mask + false); // scissor test + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) + .WillOnce(SetArgumentPointee<3>(kServiceRenderbufferId)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, _)) + .WillOnce(SetArgumentPointee<3>(GL_RENDERBUFFER)) + .RetiresOnSaturation(); + GetFramebufferAttachmentParameteriv::Result* result = + static_cast<GetFramebufferAttachmentParameteriv::Result*>( + shared_memory_address_); + result->size = 0; + const GLint* result_value = result->GetData(); + FramebufferRenderbuffer fbrb_cmd; + GetFramebufferAttachmentParameteriv cmd; + fbrb_cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, + client_renderbuffer_id_); + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + EXPECT_EQ(static_cast<GLuint>(*result_value), client_renderbuffer_id_); +} + +TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithTexture) { + DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, + kServiceFramebufferId); + EXPECT_CALL(*gl_, FramebufferTexture2DEXT( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + kServiceTextureId, 5)) + .Times(1) + .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + 0, // clear bits + 0, 0, 0, 0, // color + 0x1111, // color bits + 0, // stencil + -1, // stencil mask back, + -1, // stencil mask front, + 1.0f, // depth + 1, // depth mask + false); // scissor test + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _)) + .WillOnce(SetArgumentPointee<3>(kServiceTextureId)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, _)) + .WillOnce(SetArgumentPointee<3>(GL_TEXTURE)) + .RetiresOnSaturation(); + GetFramebufferAttachmentParameteriv::Result* result = + static_cast<GetFramebufferAttachmentParameteriv::Result*>( + shared_memory_address_); + result->SetNumResults(0); + const GLint* result_value = result->GetData(); + FramebufferTexture2D fbtex_cmd; + GetFramebufferAttachmentParameteriv cmd; + fbtex_cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, + 5); + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + EXPECT_EQ(static_cast<GLuint>(*result_value), client_texture_id_); +} + TEST_F(GLES2DecoderTest, GetRenderbufferParameterivWithNoBoundTarget) { EXPECT_CALL(*gl_, GetError()) .WillOnce(Return(GL_NO_ERROR)) @@ -2315,45 +2423,16 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) { kServiceRenderbufferId)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) - .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ColorMask(0, 1, 0, 1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(1.0f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + GL_COLOR_BUFFER_BIT, // clear bits + 0.1f, 0.2f, 0.3f, 0.4f, // color + 0x0101, // color bits + 0, // stencil + -1, // stencil mask back + -1, // stencil mask front + 1.0f, // depth + 1, // depth mask + true); // scissor test EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); @@ -2383,42 +2462,16 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { kServiceRenderbufferId)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) - .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(1.0f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(0.5f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(0)) - .Times(1) - .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + GL_DEPTH_BUFFER_BIT, // clear bits + 0, 0, 0, 0, // color + 0x1111, // color bits + 0, // stencil + -1, // stencil mask back, + -1, // stencil mask front, + 0.5f, // depth + 0, // depth mask + false); // scissor test EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); @@ -2447,42 +2500,16 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { kServiceRenderbufferId)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) - .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMask(static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Clear(GL_STENCIL_BUFFER_BIT)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(123)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0x1234u)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(1.0f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(1)) - .Times(1) - .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + GL_STENCIL_BUFFER_BIT, // clear bits + 0, 0, 0, 0, // color + 0x1111, // color bits + 123, // stencil + -1, // stencil mask back, + 0x1234u, // stencil mask front, + 1.0f, // depth + 1, // depth mask + false); // scissor test EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); @@ -2512,48 +2539,16 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) { kServiceRenderbufferId)) .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) - .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMask(static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(1.0f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, Clear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearStencil(123)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, static_cast<GLuint>(-1))) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, ClearDepth(0.5f)) - .Times(1) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, DepthMask(1)) - .Times(1) - .RetiresOnSaturation(); + SetupExpectationsForFramebufferAttachment( + GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits + 0, 0, 0, 0, // color + 0x1111, // color bits + 123, // stencil + -1, // stencil mask back, + -1, // stencil mask front, + 0.5f, // depth + 1, // depth mask + false); // scissor test EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 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 9c5b924..51e29dd 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -236,6 +236,86 @@ void GLES2DecoderTestBase::SetBucketAsCString( } } +void GLES2DecoderTestBase::SetupExpectationsForFramebufferAttachment( + GLuint clear_bits, + GLclampf restore_red, + GLclampf restore_green, + GLclampf restore_blue, + GLclampf restore_alpha, + GLuint restore_color_mask, + GLuint restore_stencil, + GLuint restore_stencil_front_mask, + GLuint restore_stencil_back_mask, + GLclampf restore_depth, + GLboolean restore_depth_mask, + bool restore_scissor_test) { + InSequence sequence; + EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) + .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) + .RetiresOnSaturation(); + if ((clear_bits & GL_COLOR_BUFFER_BIT) != 0) { + EXPECT_CALL(*gl_, ClearColor(0, 0, 0, 0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ColorMask(1, 1, 1, 1)) + .Times(1) + .RetiresOnSaturation(); + } + if ((clear_bits & GL_STENCIL_BUFFER_BIT) != 0) { + EXPECT_CALL(*gl_, ClearStencil(0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilMask(static_cast<GLuint>(-1))) + .Times(1) + .RetiresOnSaturation(); + } + if ((clear_bits & GL_DEPTH_BUFFER_BIT) != 0) { + EXPECT_CALL(*gl_, ClearDepth(1.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, DepthMask(1)) + .Times(1) + .RetiresOnSaturation(); + } + EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Clear(clear_bits)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearColor( + restore_red, restore_green, restore_blue, restore_alpha)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ColorMask( + ((restore_color_mask & 0x1000) != 0) ? 1 : 0, + ((restore_color_mask & 0x0100) != 0) ? 1 : 0, + ((restore_color_mask & 0x0010) != 0) ? 1 : 0, + ((restore_color_mask & 0x0001) != 0) ? 1 : 0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearStencil(restore_stencil)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, restore_stencil_front_mask)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, restore_stencil_back_mask)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearDepth(restore_depth)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, DepthMask(restore_depth_mask)) + .Times(1) + .RetiresOnSaturation(); + if (restore_scissor_test) { + EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) + .Times(1) + .RetiresOnSaturation(); + } +} + void GLES2DecoderTestBase::SetupShaderForUniform() { static AttribInfo attribs[] = { { "foo", 1, GL_FLOAT, 1, }, 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 e9fe328..d30e831 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -212,6 +212,20 @@ class GLES2DecoderTestBase : public testing::Test { void DoVertexAttribPointer( GLuint index, GLint size, GLenum type, GLsizei stride, GLuint offset); + void SetupExpectationsForFramebufferAttachment( + GLuint clear_bits, + GLclampf restore_red, + GLclampf restore_green, + GLclampf restore_blue, + GLclampf restore_alpha, + GLuint restore_color_mask, + GLuint restore_stencil, + GLuint restore_stencil_front_mask, + GLuint restore_stencil_back_mask, + GLclampf restore_depth, + GLboolean restore_depth_mask, + bool restore_scissor_test); + GLvoid* BufferOffset(unsigned i) { return static_cast<int8 *>(NULL)+(i); } |