Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
index 286731f53a16f2e9f6537288ec2752c1ec4411d7..db43c85ff7cc60743c5b34a44124b5a0bd5ca8d4 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc |
@@ -56,51 +56,6 @@ class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { |
GLES2DecoderWithShaderTest() |
: GLES2DecoderWithShaderTestBase() { |
} |
- |
- |
- void AddExpectationsForSimulatedAttrib0WithError( |
- GLsizei num_vertices, GLuint buffer_id, GLenum error) { |
- if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
- return; |
- } |
- |
- EXPECT_CALL(*gl_, GetError()) |
- .WillOnce(Return(GL_NO_ERROR)) |
- .WillOnce(Return(error)) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, |
- num_vertices * sizeof(GLfloat) * 4, |
- _, GL_DYNAMIC_DRAW)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- if (error == GL_NO_ERROR) { |
- EXPECT_CALL(*gl_, BufferSubData( |
- GL_ARRAY_BUFFER, 0, num_vertices * sizeof(GLfloat) * 4, _)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, VertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, buffer_id)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- } |
- } |
- |
- void AddExpectationsForSimulatedAttrib0( |
- GLsizei num_vertices, GLuint buffer_id) { |
- AddExpectationsForSimulatedAttrib0WithError( |
- num_vertices, buffer_id, GL_NO_ERROR); |
- } |
}; |
class GLES2DecoderRGBBackbufferTest : public GLES2DecoderWithShaderTest { |
@@ -190,7 +145,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { |
// This is an NPOT texture. As the default filtering requires mips |
// this should trigger replacing with black textures before rendering. |
DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
- 0, 0); |
+ kSharedMemoryId, kSharedMemoryOffset); |
AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
{ |
InSequence sequence; |
@@ -1452,12 +1407,6 @@ TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithRenderbuffer) { |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- 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)) |
@@ -1508,12 +1457,6 @@ TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithTexture) { |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- 0, // 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)) |
@@ -1671,32 +1614,15 @@ void GLES2DecoderTest::CheckReadPixelsOutOfRange( |
// access |
if (init) { |
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
- DoTexImage2D(GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, |
- kFormat, GL_UNSIGNED_BYTE, 0, 0); |
- DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
- kServiceFramebufferId); |
- EXPECT_CALL(*gl_, GetError()) |
- .WillOnce(Return(GL_NO_ERROR)) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, FramebufferTexture2DEXT( |
+ DoTexImage2D( |
+ GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, |
+ kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, |
+ kSharedMemoryOffset); |
+ DoBindFramebuffer( |
+ GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
- kServiceTextureId, 0)) |
- .Times(1) |
- .RetiresOnSaturation(); |
- EXPECT_CALL(*gl_, GetError()) |
- .WillOnce(Return(GL_NO_ERROR)) |
- .RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- 0, // clear bits |
- 0, 0, 0, 0, // color |
- 0, // stencil |
- 1.0f, // depth |
- false); // scissor test |
- FramebufferTexture2D fbtex_cmd; |
- fbtex_cmd.Init( |
- GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, |
- 0); |
- EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
+ client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); |
} |
ReadPixelsEmulator emu( |
@@ -2556,7 +2482,7 @@ TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) { |
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
DoTexImage2D( |
GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
- 0, 0); |
+ kSharedMemoryId, kSharedMemoryOffset); |
EXPECT_CALL(*gl_, TexSubImage2D( |
GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, |
shared_memory_address_)) |
@@ -2637,7 +2563,7 @@ TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { |
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
DoTexImage2D( |
GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
- 0, 0); |
+ kSharedMemoryId, kSharedMemoryOffset); |
EXPECT_CALL(*gl_, CopyTexSubImage2D( |
GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) |
.Times(1) |
@@ -2698,9 +2624,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) { |
EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) |
.Times(1) |
.RetiresOnSaturation(); |
-// EXPECT_CALL(*gl_, ColorMask(0, 1, 0, 1)) |
-// .Times(0) |
-// .RetiresOnSaturation(); |
EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST)) |
.Times(1) |
.RetiresOnSaturation(); |
@@ -2715,12 +2638,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) { |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_COLOR_BUFFER_BIT, // clear bits |
- 0.1f, 0.2f, 0.3f, 0.4f, // color |
- 0, // stencil |
- 1.0f, // depth |
- 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)); |
@@ -2742,9 +2659,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { |
EXPECT_CALL(*gl_, ClearDepth(0.5f)) |
.Times(1) |
.RetiresOnSaturation(); |
-// EXPECT_CALL(*gl_, DepthMask(0)) |
-// .Times(1) |
-// .RetiresOnSaturation(); |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
@@ -2756,12 +2670,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_DEPTH_BUFFER_BIT, // clear bits |
- 0, 0, 0, 0, // color |
- 0, // stencil |
- 0.5f, // depth |
- false); // scissor test |
EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); |
EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); |
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
@@ -2782,9 +2690,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { |
EXPECT_CALL(*gl_, ClearStencil(123)) |
.Times(1) |
.RetiresOnSaturation(); |
-// EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0x1234u)) |
-// .Times(1) |
-// .RetiresOnSaturation(); |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
@@ -2796,12 +2701,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { |
EXPECT_CALL(*gl_, GetError()) |
.WillOnce(Return(GL_NO_ERROR)) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_STENCIL_BUFFER_BIT, // clear bits |
- 0, 0, 0, 0, // color |
- 123, // stencil |
- 1.0f, // depth |
- 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)); |
@@ -2879,12 +2778,6 @@ TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) { |
kServiceRenderbufferId)) |
.Times(1) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits |
- 0, 0, 0, 0, // color |
- 123, // stencil |
- 0.5f, // depth |
- false); // scissor test |
EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); |
EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); |
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
@@ -3224,15 +3117,20 @@ TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMaskFBO) { |
EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
// Setup Frame buffer. |
- DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
- kServiceFramebufferId); |
- EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(_, _, _, _)) |
- .Times(0); |
- FramebufferRenderbuffer fbrb_cmd; |
- fbrb_cmd.Init( |
- GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
- client_renderbuffer_id_); |
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ // needs to be 1x1 or else it's not renderable. |
+ const GLsizei kWidth = 1; |
+ const GLsizei kHeight = 1; |
+ const GLenum kFormat = GL_RGB; |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ // Pass some data so the texture will be marked as cleared. |
+ DoTexImage2D( |
+ GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, |
+ kFormat, GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); |
+ DoBindFramebuffer( |
+ GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); |
// This time state needs to be set. |
SetupExpectationsForApplyingDirtyState( |
@@ -3819,12 +3717,6 @@ TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferDepth) { |
kServiceRenderbufferId)) |
.Times(1) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_DEPTH_BUFFER_BIT, // clear bits |
- 0, 0, 0, 0, // color |
- 0, // stencil |
- 1.0f, // depth |
- false); // scissor test |
FramebufferRenderbuffer fbrb_cmd; |
fbrb_cmd.Init( |
GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
@@ -3896,12 +3788,6 @@ TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferStencil) { |
kServiceRenderbufferId)) |
.Times(1) |
.RetiresOnSaturation(); |
- SetupExpectationsForFramebufferAttachment( |
- GL_STENCIL_BUFFER_BIT, // clear bits |
- 0, 0, 0, 0, // color |
- 0, // stencil |
- 1.0f, // depth |
- false); // scissor test |
FramebufferRenderbuffer fbrb_cmd; |
fbrb_cmd.Init( |
GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
@@ -4072,17 +3958,21 @@ TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { |
EXPECT_CALL(*gl_, GetError()) |
.WillRepeatedly(Return(GL_NO_ERROR)); |
for (int ii = 0; ii < 2; ++ii) { |
+ TexImage2D cmd; |
if (ii == 0) { |
EXPECT_CALL(*gl_, TexImage2D( |
GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
GL_UNSIGNED_BYTE, _)) |
.Times(1) |
.RetiresOnSaturation(); |
+ cmd.Init( |
+ GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); |
+ } else { |
+ cmd.Init( |
+ GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, 0, 0); |
} |
- TexImage2D cmd; |
- cmd.Init( |
- GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
- GL_UNSIGNED_BYTE, 0, 0); |
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
EXPECT_CALL(*gl_, TexSubImage2D( |
GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, |
@@ -4999,6 +4889,512 @@ TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { |
EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
} |
+TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DNULL) { |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ 0, 0); |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
+ EXPECT_CALL(*gl_, TexSubImage2D( |
+ GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
+ shared_memory_address_)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ TexSubImage2D cmd; |
+ cmd.Init( |
+ GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
+ kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ // Test if we call it again it does not clear. |
+ EXPECT_CALL(*gl_, TexSubImage2D( |
+ GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
+ shared_memory_address_)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+} |
+ |
+TEST_F(GLES2DecoderTest, |
+ TexSubImage2DDoesNotClearAfterTexImage2DWithDataThenNULL) { |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ // Put in data (so it should be marked as cleared) |
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ kSharedMemoryId, kSharedMemoryOffset); |
+ // Put in no data. |
+ TexImage2D tex_cmd; |
+ tex_cmd.Init( |
+ GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
+ // There is no expectation. Same size, no data = no-op. |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); |
+ EXPECT_CALL(*gl_, TexSubImage2D( |
+ GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
+ shared_memory_address_)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ TexSubImage2D cmd; |
+ cmd.Init( |
+ GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
+ kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ // Create an uncleared texture with 2 levels. |
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ 0, 0); |
+ DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ 0, 0); |
+ // Expect 2 levels will be cleared. |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
+ AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
+ SetupExpectationsForApplyingDefaultDirtyState(); |
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { |
+ SetupIndexBuffer(); |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ // Create an uncleared texture with 2 levels. |
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ 0, 0); |
+ DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
+ 0, 0); |
+ // Expect 2 levels will be cleared. |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
+ AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
+ SetupExpectationsForApplyingDefaultDirtyState(); |
+ EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, |
+ GL_UNSIGNED_SHORT, |
+ BufferOffset(kValidIndexRangeStart * 2))) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawElements cmd; |
+ cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, |
+ kValidIndexRangeStart * 2); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) { |
+ 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 to" 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_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
+ |
+ // 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 |
+ |
+ AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
+ SetupExpectationsForApplyingDirtyState( |
+ false, // Framebuffer is RGB |
+ false, // Framebuffer has depth |
+ false, // Framebuffer has stencil |
+ 0x1111, // color bits |
+ false, // depth mask |
+ false, // depth enabled |
+ 0, // front stencil mask |
+ 0, // back stencil mask |
+ false); // stencil enabled |
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, DrawWitFBOThatCantClearDoesNotDraw) { |
+ 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 to" 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_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
+ |
+ // Setup "render from" texture. |
+ SetupTexture(); |
+ |
+ EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
+ .WillOnce(Return(GL_FRAMEBUFFER_UNSUPPORTED)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, DrawArrays(_, _, _)) |
+ .Times(0) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ |
+ TextureManager* manager = group().texture_manager(); |
+ TextureManager::TextureInfo* info = |
+ manager->GetTextureInfo(client_texture_id_); |
+ |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ CopyTexImage2D cmd; |
+ cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ |
+ EXPECT_TRUE(info->SafeToRenderFrom()); |
+} |
+ |
+TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ DoTexImage2D( |
+ GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
+ |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, |
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
+ EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ CopyTexSubImage2D cmd; |
+ cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+} |
+ |
+TEST_F(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) { |
+ InitDecoder( |
+ "GL_EXT_texture_compression_s3tc", // extensions |
+ false, // has alpha |
+ false, // has depth |
+ false, // has stencil |
+ false, // request alpha |
+ false, // request depth |
+ false, // request stencil |
+ true); // bind generates resource |
+ |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, CompressedTexImage2D( |
+ GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 16, _)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ CompressedTexImage2D cmd; |
+ cmd.Init(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, |
+ 16, kSharedMemoryId, kSharedMemoryOffset); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ TextureManager* manager = group().texture_manager(); |
+ TextureManager::TextureInfo* info = |
+ manager->GetTextureInfo(client_texture_id_); |
+ EXPECT_TRUE(info->SafeToRenderFrom()); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) { |
+ 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 to" 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_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
+ |
+ // 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 |
+ SetupExpectationsForApplyingDirtyState( |
+ false, // Framebuffer is RGB |
+ false, // Framebuffer has depth |
+ false, // Framebuffer has stencil |
+ 0x1111, // color bits |
+ false, // depth mask |
+ false, // depth enabled |
+ 0, // front stencil mask |
+ 0, // back stencil mask |
+ false); // stencil enabled |
+ EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ |
+ Clear cmd; |
+ cmd.Init(GL_COLOR_BUFFER_BIT); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) { |
+ 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 to" 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_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
+ |
+ // 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 |
+ |
+ 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; |
+ Result* result = GetSharedMemoryAs<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_, |
+ kServiceRenderbufferId); |
+ DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
+ kServiceFramebufferId); |
+ DoRenderbufferStorage( |
+ GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); |
+ DoFramebufferRenderbuffer( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
+ client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); |
+ |
+ SetupExpectationsForFramebufferClearing( |
+ GL_FRAMEBUFFER, // target |
+ GL_COLOR_BUFFER_BIT, // clear bits |
+ 0, 0, 0, 0, // color |
+ 0, // stencil |
+ 1.0f, // depth |
+ false); // scissor test |
+ |
+ AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
+ SetupExpectationsForApplyingDirtyState( |
+ false, // Framebuffer is RGB |
+ false, // Framebuffer has depth |
+ false, // Framebuffer has stencil |
+ 0x1111, // color bits |
+ false, // depth mask |
+ false, // depth enabled |
+ 0, // front stencil mask |
+ 0, // back stencil mask |
+ false); // stencil enabled |
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_F(GLES2DecoderTest, DrawArraysClearsAfterTexImage2DNULLCubemap) { |
+ static const GLenum faces[] = { |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
+ }; |
+ SetupCubemapProgram(); |
+ DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
+ // Fill out all the faces for 2 levels, leave 2 uncleared. |
+ for (int ii = 0; ii < 6; ++ii) { |
+ GLenum face = faces[ii]; |
+ int32 shm_id = |
+ (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryId; |
+ uint32 shm_offset = |
+ (face == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) ? 0 : kSharedMemoryOffset; |
+ DoTexImage2D(face, 0, GL_RGBA, 2, 2, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, shm_id, shm_offset); |
+ DoTexImage2D(face, 1, GL_RGBA, 1, 1, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, shm_id, shm_offset); |
+ } |
+ // Expect 2 levels will be cleared. |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); |
+ SetupClearTextureExpections( |
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP, |
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1); |
+ AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
+ SetupExpectationsForApplyingDefaultDirtyState(); |
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+} |
+ |
+TEST_F(GLES2DecoderWithShaderTest, |
+ DrawClearsAfterRenderbuffersWithMultipleAttachments) { |
+ 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 to" 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_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ DoFramebufferTexture2D( |
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
+ kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); |
+ |
+ DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, |
+ kServiceRenderbufferId); |
+ DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
+ kServiceFramebufferId); |
+ DoRenderbufferStorage( |
+ GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, |
+ 1, 1, GL_NO_ERROR); |
+ DoFramebufferRenderbuffer( |
+ GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
+ client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); |
+ |
+ 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 |
+ |
+ AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
+ SetupExpectationsForApplyingDirtyState( |
+ false, // Framebuffer is RGB |
+ true, // Framebuffer has depth |
+ false, // Framebuffer has stencil |
+ 0x1111, // color bits |
+ true, // depth mask |
+ false, // depth enabled |
+ 0, // front stencil mask |
+ 0, // back stencil mask |
+ false); // stencil enabled |
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DrawArrays cmd; |
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+ |
+ |
// TODO(gman): Complete this test. |
// TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
// } |