Commit 20797261 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Check tex_image_failed instead of glGetError

TextureManager does some validation and will reject a bad glTexImage2D
before it gets issued to the driver. We should prefer to check
tex_image_failed (which is set by TextureManager) over glGetError.

This issue was found by clusterfuzz. I added a gpu_unittest that fails
without this change because it hits DCHECKS in texture_manager.cc when
we call SetImmutable in raster_decoder.cc.

I have confirmed locally that this CL resolves the clusterfuzz issue.

Bug: 850056
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ibedec4ccc9ec4e3758eb38292642a8671ee8f975
Reviewed-on: https://chromium-review.googlesource.com/1089030Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564953}
parent bb024f15
...@@ -2461,7 +2461,7 @@ bool RasterDecoderImpl::TexImage2D(TextureRef* texture_ref, ...@@ -2461,7 +2461,7 @@ bool RasterDecoderImpl::TexImage2D(TextureRef* texture_ref,
// context preemption and GPU watchdog checks. // context preemption and GPU watchdog checks.
ExitCommandProcessingEarly(); ExitCommandProcessingEarly();
return LOCAL_PEEK_GL_ERROR("glTexImage2D") == GL_NO_ERROR; return !texture_state_.tex_image_failed;
} }
void RasterDecoderImpl::DoTexStorage2D(GLuint client_id, void RasterDecoderImpl::DoTexStorage2D(GLuint client_id,
......
...@@ -401,6 +401,25 @@ TEST_P(RasterDecoderTest, CreateTextureETC1Unsupported) { ...@@ -401,6 +401,25 @@ TEST_P(RasterDecoderTest, CreateTextureETC1Unsupported) {
EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
} }
// Need GL_EXT_texture_rg to support viz::ResourceFormat::RED_8
TEST_P(RasterDecoderTest, RED_8DefaultUnsupported) {
GLuint source_texture_id = kNewClientId;
EXPECT_CALL(*gl_, GenTextures(1, _))
.WillOnce(SetArgPointee<1>(kNewServiceId))
.RetiresOnSaturation();
cmds::CreateTexture create_cmd;
create_cmd.Init(false /* use_buffer */, gfx::BufferUsage::GPU_READ,
viz::ResourceFormat::RED_8, source_texture_id);
EXPECT_EQ(error::kNoError, ExecuteCmd(create_cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
SetScopedTextureBinderExpectations(GL_TEXTURE_2D);
cmds::TexStorage2D storage_cmd;
storage_cmd.Init(source_texture_id, kWidth, kHeight);
EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd));
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_P(RasterDecoderTest, CopyTexSubImage2DTwiceClearsUnclearedTexture) { TEST_P(RasterDecoderTest, CopyTexSubImage2DTwiceClearsUnclearedTexture) {
// Create uninitialized source texture. // Create uninitialized source texture.
GLuint source_texture_id = kNewClientId; GLuint source_texture_id = kNewClientId;
......
...@@ -431,7 +431,6 @@ void RasterDecoderTestBase::DoTexStorage2D(GLuint client_id, ...@@ -431,7 +431,6 @@ void RasterDecoderTestBase::DoTexStorage2D(GLuint client_id,
.RetiresOnSaturation(); .RetiresOnSaturation();
} else { } else {
EXPECT_CALL(*gl_, GetError()) EXPECT_CALL(*gl_, GetError())
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR)) .WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR)) .WillOnce(Return(GL_NO_ERROR))
.RetiresOnSaturation(); .RetiresOnSaturation();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment