Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc

Issue 14188053: gpu: Change Produce/ConsumeTexture to allow texture sharing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/texture_manager_unittest.cc ('k') | gpu/command_buffer_service.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
index 6491e41f1a2f120c8bed5f024fef6e987b3688a1..566189f9e44288a78528c88627ecadbed6039f58 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
@@ -167,5 +167,104 @@ TEST_F(GLTextureMailboxTest, ConsumeTextureValidatesKey) {
EXPECT_EQ(source_pixel, ReadTexel(tex, 0, 0));
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
}
+
+TEST_F(GLTextureMailboxTest, SharedTextures) {
+ gl1_.MakeCurrent();
+ GLuint tex1;
+ glGenTextures(1, &tex1);
+
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ uint32 source_pixel = 0xFF0000FF;
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1, 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ &source_pixel);
+ GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox);
+
+ glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ glFlush();
+
+ gl2_.MakeCurrent();
+ GLuint tex2;
+ glGenTextures(1, &tex2);
+
+ glBindTexture(GL_TEXTURE_2D, tex2);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // Change texture in context 2.
+ source_pixel = 0xFF00FF00;
+ glTexSubImage2D(GL_TEXTURE_2D,
+ 0,
+ 0, 0,
+ 1, 1,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ &source_pixel);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ glFlush();
+
+ // Check it in context 1.
+ gl1_.MakeCurrent();
+ EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0));
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // Change parameters (note: ReadTexel will reset those).
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_NEAREST);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ glFlush();
+
+ // Check in context 2.
+ gl2_.MakeCurrent();
+ GLint parameter = 0;
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &parameter);
+ EXPECT_EQ(GL_REPEAT, parameter);
+ parameter = 0;
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &parameter);
+ EXPECT_EQ(GL_LINEAR, parameter);
+ parameter = 0;
+ glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &parameter);
+ EXPECT_EQ(GL_LINEAR_MIPMAP_NEAREST, parameter);
+
+ // Delete texture in context 1.
+ gl1_.MakeCurrent();
+ glDeleteTextures(1, &tex1);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // Check texture still exists in context 2.
+ gl2_.MakeCurrent();
+ EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0));
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // The mailbox should still exist too.
+ GLuint tex3;
+ glGenTextures(1, &tex3);
+ glBindTexture(GL_TEXTURE_2D, tex3);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // Delete both textures.
+ glDeleteTextures(1, &tex2);
+ glDeleteTextures(1, &tex3);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+
+ // Mailbox should be gone now.
+ glGenTextures(1, &tex2);
+ glBindTexture(GL_TEXTURE_2D, tex2);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
+ glDeleteTextures(1, &tex2);
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+}
+
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/texture_manager_unittest.cc ('k') | gpu/command_buffer_service.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698