summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-08 05:36:07 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-08 05:36:07 +0000
commitf4647693006cf1a5cd70aa7058fe7dde14610e57 (patch)
tree4ad19c6fe107fd49fca37c1975e091c76c929cb7 /gpu
parent683bc4d5ed48e09b85cc75279b1d9877d91fd6e1 (diff)
downloadchromium_src-f4647693006cf1a5cd70aa7058fe7dde14610e57.zip
chromium_src-f4647693006cf1a5cd70aa7058fe7dde14610e57.tar.gz
chromium_src-f4647693006cf1a5cd70aa7058fe7dde14610e57.tar.bz2
gpu: make sure we can ProduceFrontBuffer in 2 contexts of the same share group
r204194 introduced ProduceFrontBuffer. The created TextureRef was never meant to be mapped to a client id, let alone 0, in the share group, and doing so prevents ProduceFrontBuffer from being called in 2 contexts in the same share group. BUG=247710 Review URL: https://chromiumcodereview.appspot.com/16132013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc3
-rw-r--r--gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc49
2 files changed, 51 insertions, 1 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index e6f5027..5cfe248 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -3234,7 +3234,8 @@ bool GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) {
return false;
if (!offscreen_saved_color_texture_info_.get()) {
GLuint service_id = offscreen_saved_color_texture_->id();
- offscreen_saved_color_texture_info_ = CreateTexture(0, service_id);
+ offscreen_saved_color_texture_info_ = TextureRef::Create(
+ texture_manager(), 0, service_id);
texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(),
GL_TEXTURE_2D);
UpdateParentTextureInfo();
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
index dbd513c..d960efc 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
@@ -318,5 +318,54 @@ TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) {
glDeleteTextures(1, &tex1);
}
+TEST_F(GLTextureMailboxTest, ProduceFrontBufferMultipleContexts) {
+ gl1_.MakeCurrent();
+ Mailbox mailbox[2];
+ glGenMailboxCHROMIUM(mailbox[0].name);
+ glGenMailboxCHROMIUM(mailbox[1].name);
+ GLuint tex[2];
+ glGenTextures(2, tex);
+
+ GLManager::Options options;
+ options.share_mailbox_manager = &gl1_;
+ GLManager other_gl[2];
+ for (size_t i = 0; i < 2; ++i) {
+ other_gl[i].Initialize(options);
+ other_gl[i].MakeCurrent();
+ other_gl[i].decoder()->ProduceFrontBuffer(mailbox[i]);
+ // Make sure both "other gl" are in the same share group.
+ if (!options.share_group_manager)
+ options.share_group_manager = other_gl+i;
+ }
+
+
+ gl1_.MakeCurrent();
+ for (size_t i = 0; i < 2; ++i) {
+ glBindTexture(GL_TEXTURE_2D, tex[i]);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox[i].name);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ }
+
+ for (size_t i = 0; i < 2; ++i) {
+ other_gl[i].MakeCurrent();
+ glResizeCHROMIUM(10, 10, 1);
+ glClearColor(1-i%2, i%2, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+ ::gles2::GetGLContext()->SwapBuffers();
+ }
+
+ gl1_.MakeCurrent();
+ EXPECT_EQ(0xFF0000FFu, ReadTexel(tex[0], 0, 0));
+ EXPECT_EQ(0xFF00FF00u, ReadTexel(tex[1], 9, 9));
+
+ for (size_t i = 0; i < 2; ++i) {
+ other_gl[i].MakeCurrent();
+ other_gl[i].Destroy();
+ }
+
+ gl1_.MakeCurrent();
+ glDeleteTextures(2, tex);
+}
+
} // namespace gpu