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 212a64fe4facafbba2e5ec7f65e877a30d316abb..314610c4538dd728eb52f4390a6d98583a407604 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
@@ -4718,6 +4718,66 @@ TEST_P(GLES2DecoderTest, TestDiscardableTextureBindGeneratesUnlocked) { |
EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
} |
+// Test texture base level is set before texImage2D when workaround |
+// RESET_TEXIMAGE2D_BASE_LEVEL is enabled |
+TEST_P(GLES3DecoderManualInitTest, SetTextureBaseLevelBeforeTexImage2D) { |
+ base::CommandLine command_line(0, nullptr); |
+ command_line.AppendSwitchASCII( |
+ switches::kGpuDriverBugWorkarounds, |
+ base::IntToString(gpu::SET_ZERO_LEVEL_BEFORE_GENERATING_MIPMAP) + "," + |
+ base::IntToString(gpu::RESET_TEXIMAGE2D_BASE_LEVEL)); |
+ InitState init; |
+ init.gl_version = "OpenGL ES 3.0"; |
+ init.bind_generates_resource = true; |
+ init.context_type = CONTEXT_TYPE_OPENGLES3; |
+ InitDecoderWithCommandLine(init, &command_line); |
+ |
+ EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
+ GLint base_level = 2; |
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
+ DoTexImage2D(GL_TEXTURE_2D, base_level, GL_RGBA, 2, 2, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, 0, 0); |
+ SetupClearTextureExpectations(kServiceTextureId, kServiceTextureId, |
+ GL_TEXTURE_2D, GL_TEXTURE_2D, base_level, |
+ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 2, 2); |
+ DoTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
+ DoTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
+ DoTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level); |
+ EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, nullptr)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, |
+ TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, |
+ GL_UNSIGNED_BYTE, nullptr)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, |
+ TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, base_level)) |
+ .Times(1) |
+ .RetiresOnSaturation(); |
+ EXPECT_CALL(*gl_, GetError()) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .WillOnce(Return(GL_NO_ERROR)) |
+ .RetiresOnSaturation(); |
+ GenerateMipmap cmd; |
+ cmd.Init(GL_TEXTURE_2D); |
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
+ EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
+} |
+ |
// TODO(gman): Complete this test. |
// TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) { |
// } |