Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
index 22d8a1d0cd0fe4ab8aec888030208e4de533f284..b1d478ccafcfea618860f0ac5a5aefbf7a64c7f4 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
@@ -1213,6 +1213,161 @@ TEST_P(GLES3DecoderTest, CopyTexSubImage3DCheckArgs) { |
EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
} |
+TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopSucceeds0) { |
+ const GLenum kTarget = GL_TEXTURE_3D; |
+ const GLint kInternalFormat = GL_RGB8; |
+ const GLint kXoffset = 0; |
+ const GLint kYoffset = 0; |
+ const GLint kZoffset = 0; |
+ const GLint kX = 0; |
+ const GLint kY = 0; |
+ const GLsizei kWidth = 2; |
+ const GLsizei kHeight = 2; |
+ const GLsizei kDepth = 2; |
+ const GLsizei kBorder = 0; |
+ const GLenum kFormat = GL_RGB; |
+ const GLenum kType = GL_UNSIGNED_BYTE; |
+ |
+ DoBindTexture(kTarget, client_texture_id_, kServiceTextureId); |
+ DoBindFramebuffer( |
+ GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ |
+ FramebufferTextureLayer tex_layer; |
+ CopyTexSubImage3D cmd; |
+ |
+ // The source and the target for CopyTexSubImage3D are the same 3d texture. |
+ // But level of 3D texture != level of read attachment in fbo. |
+ GLint kLevel = 0; |
+ GLint kLayer = 0; // kZoffset is 0 |
+ EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER, |
+ GL_COLOR_ATTACHMENT0, |
+ kServiceTextureId, kLevel, kLayer)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, |
+ kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); |
+ tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_, |
+ kLevel, kLayer); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+ |
+ kLevel = 1; |
+ EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) |
+ .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, |
+ CopyTexSubImage3D(kTarget, kLevel, kXoffset, kYoffset, kZoffset, |
+ kX, kY, kWidth, kHeight)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, |
+ kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); |
+ cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, |
+ kX, kY, kWidth, kHeight); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopSucceeds1) { |
+ const GLenum kTarget = GL_TEXTURE_3D; |
+ const GLint kInternalFormat = GL_RGB8; |
+ const GLint kXoffset = 0; |
+ const GLint kYoffset = 0; |
+ const GLint kZoffset = 0; |
+ const GLint kX = 0; |
+ const GLint kY = 0; |
+ const GLsizei kWidth = 2; |
+ const GLsizei kHeight = 2; |
+ const GLsizei kDepth = 2; |
+ const GLsizei kBorder = 0; |
+ const GLenum kFormat = GL_RGB; |
+ const GLenum kType = GL_UNSIGNED_BYTE; |
+ |
+ DoBindTexture(kTarget, client_texture_id_, kServiceTextureId); |
+ DoBindFramebuffer( |
+ GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ |
+ FramebufferTextureLayer tex_layer; |
+ CopyTexSubImage3D cmd; |
+ |
+ // The source and the target for CopyTexSubImage3D are the same 3d texture. |
+ // But zoffset of 3D texture != layer of read attachment in fbo. |
+ GLint kLevel = 0; |
+ GLint kLayer = 1; // kZoffset is 0 |
+ EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER, |
+ GL_COLOR_ATTACHMENT0, |
+ kServiceTextureId, kLevel, kLayer)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, |
+ kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); |
+ tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_, |
+ kLevel, kLayer); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+ |
+ EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) |
+ .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, |
+ CopyTexSubImage3D(kTarget, kLevel, kXoffset, kYoffset, kZoffset, |
+ kX, kY, kWidth, kHeight)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, |
+ kX, kY, kWidth, kHeight); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
+TEST_P(GLES3DecoderTest, CopyTexSubImage3DFeedbackLoopFails) { |
+ const GLenum kTarget = GL_TEXTURE_3D; |
+ const GLint kInternalFormat = GL_RGB8; |
+ const GLint kXoffset = 0; |
+ const GLint kYoffset = 0; |
+ const GLint kZoffset = 0; |
+ const GLint kX = 0; |
+ const GLint kY = 0; |
+ const GLsizei kWidth = 2; |
+ const GLsizei kHeight = 2; |
+ const GLsizei kDepth = 2; |
+ const GLsizei kBorder = 0; |
+ const GLenum kFormat = GL_RGB; |
+ const GLenum kType = GL_UNSIGNED_BYTE; |
+ |
+ DoBindTexture(kTarget, client_texture_id_, kServiceTextureId); |
+ DoBindFramebuffer( |
+ GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
+ |
+ FramebufferTextureLayer tex_layer; |
+ CopyTexSubImage3D cmd; |
+ |
+ // The source and the target for CopyTexSubImage3D are the same 3d texture. |
+ // And level / zoffset of 3D texture equal to level / layer of read attachment |
+ // in fbo. |
+ GLint kLevel = 1; |
+ GLint kLayer = 0; // kZoffset is 0 |
+ EXPECT_CALL(*gl_, FramebufferTextureLayer(GL_FRAMEBUFFER, |
+ GL_COLOR_ATTACHMENT0, |
+ kServiceTextureId, kLevel, kLayer)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ DoTexImage3D(kTarget, kLevel, kInternalFormat, kWidth, kHeight, kDepth, |
+ kBorder, kFormat, kType, kSharedMemoryId, kSharedMemoryOffset); |
+ tex_layer.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, client_texture_id_, |
+ kLevel, kLayer); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(tex_layer)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+ |
+ EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) |
+ .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
+ .RetiresOnSaturation(); |
+ cmd.Init(kTarget, kLevel, kXoffset, kYoffset, kZoffset, |
+ kX, kY, kWidth, kHeight); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
+} |
+ |
TEST_P(GLES3DecoderTest, CompressedTexImage3DFailsWithBadImageSize) { |
const uint32_t kBucketId = 123; |
const GLenum kTarget = GL_TEXTURE_2D_ARRAY; |