diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 11:21:39 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 11:21:39 +0000 |
commit | 1bed6223a3ee38429d387b03d3e04c62cb53177d (patch) | |
tree | c0a0dce9f63583b838c5c53559bacb490b012d92 /gpu | |
parent | 937d29eb8a773372e8aad1fd381387c5f47a1b10 (diff) | |
download | chromium_src-1bed6223a3ee38429d387b03d3e04c62cb53177d.zip chromium_src-1bed6223a3ee38429d387b03d3e04c62cb53177d.tar.gz chromium_src-1bed6223a3ee38429d387b03d3e04c62cb53177d.tar.bz2 |
Make texImage2D with NULL always clear texture.
I had made an optimization that if you call texImage2D with NULL
and format, type, and size were all the same then I wouldn't
call texImage2D at all but that broke WebGL conformance
While it's not needed for OpenGL ES 2.0 conformance it's
probably not enough of an optimization to matter so...
This patch just marks the texture level as uncleared. The
deferred clearing code will then clear it later if it needs
to be cleared
TEST=unit tests
BUG=108138
R=kbr@chromium.org
Review URL: http://codereview.chromium.org/9006043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 7 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc | 12 |
2 files changed, 15 insertions, 4 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index dde33df..9b038f8 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -6440,6 +6440,11 @@ error::Error GLES2DecoderImpl::DoTexImage2D( type == tex_type && format == tex_format; if (level_is_same && !pixels) { + // Just set the level info but mark the texture as uncleared. + texture_manager()->SetLevelInfo( + feature_info_, info, + target, level, internal_format, width, height, 1, border, format, type, + false); tex_image_2d_failed_ = false; return error::kNoError; } @@ -6451,7 +6456,7 @@ error::Error GLES2DecoderImpl::DoTexImage2D( framebuffer_manager()->IncFramebufferStateChangeCount(); } - if (!teximage2d_faster_than_texsubimage2d_ && level_is_same) { + if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); tex_image_2d_failed_ = false; return error::kNoError; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 3bb9299..e3c6598 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -3977,6 +3977,9 @@ TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); } else { + SetupClearTextureExpections( + kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, + 0, 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); @@ -5131,8 +5134,7 @@ TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DNULL) { EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); } -TEST_F(GLES2DecoderTest, - TexSubImage2DDoesNotClearAfterTexImage2DWithDataThenNULL) { +TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) { DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); // Put in data (so it should be marked as cleared) DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, @@ -5141,8 +5143,12 @@ TEST_F(GLES2DecoderTest, TexImage2D tex_cmd; tex_cmd.Init( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); - // There is no expectation. Same size, no data = no-op. + // 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( + kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, + 0, 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_)) |