Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 168983005: Do not rely on a texture's internalformat matching format (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add unit tests for TexSubImage2D on GLES3 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e7187d07e59a52242226f2fd55dca614301297b7..297e0c70deda24da9dc34a765af53357595a9402 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -1873,9 +1873,9 @@ TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) {
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(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
EXPECT_CALL(*gl_, TexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST))
.Times(1)
@@ -4596,9 +4596,9 @@ TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) {
GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset);
} else {
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, kWidth, kHeight);
+ 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kWidth, kHeight);
cmd.Init(
GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, 0, 0);
@@ -5914,9 +5914,9 @@ 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(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ 0, GL_RGBA, 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_))
@@ -6037,9 +6037,9 @@ TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) {
// It won't actually call TexImage2D, just mark it as uncleared.
EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd));
// Next call to TexSubImage2d should clear.
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ 0, GL_RGBA, 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_))
@@ -6061,12 +6061,12 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) {
DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
0, 0);
// Expect 2 levels will be cleared.
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
- SetupClearTextureExpections(
+ 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
+ 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
SetupExpectationsForApplyingDefaultDirtyState();
EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
.Times(1)
@@ -6094,12 +6094,12 @@ TEST_F(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) {
DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
0, 0);
// Expect 2 levels will be cleared.
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
- SetupClearTextureExpections(
+ 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
+ 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
SetupExpectationsForApplyingDefaultDirtyState();
EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount,
@@ -6249,9 +6249,9 @@ TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) {
DoTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
+ 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1))
.Times(1)
.RetiresOnSaturation();
@@ -6529,12 +6529,14 @@ TEST_F(GLES2DecoderTest, DrawArraysClearsAfterTexImage2DNULLCubemap) {
GL_UNSIGNED_BYTE, shm_id, shm_offset);
}
// Expect 2 levels will be cleared.
- SetupClearTextureExpections(
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
- SetupClearTextureExpections(
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE,
+ 2, 2);
+ SetupClearTextureExpectations(
kServiceTextureId, kServiceTextureId, GL_TEXTURE_CUBE_MAP,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, GL_UNSIGNED_BYTE, 1, 1);
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE,
+ 1, 1);
AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
SetupExpectationsForApplyingDefaultDirtyState();
EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
@@ -8946,6 +8948,65 @@ TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES3) {
GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0);
}
+TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatOnGLES3) {
+ InitDecoder("GL_OES_texture_float GL_EXT_color_buffer_float", // extensions
+ "opengl es 3.0", // gl version
+ false, // has alpha
+ false, // has depth
+ false, // has stencil
+ false, // request alpha
+ false, // request depth
+ false, // request stencil
+ false); // bind generates resource
+ const int kWidth = 8;
+ const int kHeight = 4;
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA,
+ GL_FLOAT, 0, 0);
+ EXPECT_CALL(*gl_, TexImage2D(
+ GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, GL_FLOAT,
+ shared_memory_address_))
+ .Times(1)
+ .RetiresOnSaturation();
+ TexSubImage2D cmd;
+ cmd.Init(
+ GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA, GL_FLOAT,
+ kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
+TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatDoesClearOnGLES3) {
+ InitDecoder("GL_OES_texture_float GL_EXT_color_buffer_float", // extensions
+ "opengl es 3.0", // gl version
+ false, // has alpha
+ false, // has depth
+ false, // has stencil
+ false, // request alpha
+ false, // request depth
+ false, // request stencil
+ false); // bind generates resource
+ const int kWidth = 8;
+ const int kHeight = 4;
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA,
+ GL_FLOAT, 0, 0);
+ SetupClearTextureExpectations(
+ kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
+ 0, GL_RGBA32F, GL_RGBA, GL_FLOAT, kWidth, kHeight);
+ EXPECT_CALL(*gl_, TexSubImage2D(
+ GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT,
+ shared_memory_address_))
+ .Times(1)
+ .RetiresOnSaturation();
+ TexSubImage2D cmd;
+ cmd.Init(
+ GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT,
+ kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) {
InitDecoder("GL_ARB_texture_float", // extensions
"2.1", // gl version
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698