diff options
author | kkinnunen@nvidia.com <kkinnunen@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:07:53 +0000 |
---|---|---|
committer | kkinnunen@nvidia.com <kkinnunen@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:07:53 +0000 |
commit | cedee3399d70b5067c8e2630da25ab4fc0f77e8d (patch) | |
tree | 998cd7adea8c371f5032f7bd27d55535ecfa1b65 /gpu | |
parent | bdae684928898ad2937176cbeda8722b2997757b (diff) | |
download | chromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.zip chromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.tar.gz chromium_src-cedee3399d70b5067c8e2630da25ab4fc0f77e8d.tar.bz2 |
Return early after errors in glVertexAttribDivisor and glCopyTexImage2D implementations
Command buffer command decoder is missing few early returns. Add early
returns after error handling in glVertexAttribDivisorANGLE if no
extension is present and glCopyTexImage2D if texture is immutable.
BUG=373159
Review URL: https://codereview.chromium.org/285703005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
3 files changed, 66 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index a72fcdc..8d50037 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -7164,6 +7164,7 @@ error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( LOCAL_SET_GL_ERROR( GL_INVALID_OPERATION, "glVertexAttribDivisorANGLE", "function not available"); + return error::kNoError; } GLuint index = c.index; GLuint divisor = c.divisor; @@ -8389,6 +8390,7 @@ void GLES2DecoderImpl::DoCopyTexImage2D( if (texture->IsImmutable()) { LOCAL_SET_GL_ERROR( GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); + return; } if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || border != 0) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 8c51b03..002e142 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -35,6 +35,7 @@ using ::gfx::MockGLInterface; using ::testing::_; +using ::testing::AtLeast; using ::testing::DoAll; using ::testing::InSequence; using ::testing::Invoke; @@ -1209,6 +1210,53 @@ TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); } +TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) { + const GLenum kTarget = GL_TEXTURE_2D; + const GLint kLevel = 0; + const GLenum kInternalFormat = GL_RGBA; + const GLenum kSizedInternalFormat = GL_RGBA8; + const GLsizei kWidth = 4; + const GLsizei kHeight = 8; + const GLint kBorder = 0; + InitState init; + init.extensions = "GL_EXT_texture_storage"; + init.gl_version = "3.0"; + init.has_alpha = true; + init.request_alpha = true; + init.bind_generates_resource = true; + InitDecoder(init); + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); + + // CopyTexImage2D will call arbitrary amount of GetErrors. + EXPECT_CALL(*gl_, GetError()) + .Times(AtLeast(1)); + + EXPECT_CALL(*gl_, + CopyTexImage2D( + kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight, + kBorder)) + .Times(1); + + EXPECT_CALL(*gl_, + TexStorage2DEXT( + kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight)) + .Times(1); + CopyTexImage2D copy_cmd; + copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight); + EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + + TexStorage2DEXT storage_cmd; + storage_cmd.Init(kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight); + EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + + // This should not invoke CopyTexImage2D. + copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight); + EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); + EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); +} + INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc index b5e6801..07e31cb 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc @@ -974,6 +974,22 @@ TEST_P(GLES2DecoderWithShaderTest, DrawArraysInstancedANGLEFails) { EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } +TEST_P(GLES2DecoderWithShaderTest, VertexAttribDivisorANGLEFails) { + SetupTexture(); + SetupVertexBuffer(); + DoEnableVertexAttribArray(1); + DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); + + EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(_, _)) + .Times(0) + .RetiresOnSaturation(); + + VertexAttribDivisorANGLE cmd; + cmd.Init(0, 1); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); +} + TEST_P(GLES2DecoderGeometryInstancingTest, DrawArraysInstancedANGLENoAttributesFails) { SetupTexture(); |