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

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

Issue 299043003: Adding bindless variants mailbox produce/consume (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Addressed, added more tests Created 6 years, 6 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
Index: gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
index ba3324d718cfb1a5c08f2ea6ba35f4fcbb1fc83b..814819edea2c5af644ea23f682d2f724a1ea9c46 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
@@ -18,7 +18,7 @@
namespace gpu {
namespace {
-uint32 ReadTexel(GLuint id, GLint x, GLint y) {
+uint32 ReadTexel(GLuint id, GLint x, GLint y, GLenum format = GL_RGBA) {
piman 2014/06/09 14:37:25 nit: no default argument in Chromium style.
GLint old_fbo = 0;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo);
@@ -41,7 +41,7 @@ uint32 ReadTexel(GLuint id, GLint x, GLint y) {
glCheckFramebufferStatus(GL_FRAMEBUFFER));
uint32 texel = 0;
- glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel);
+ glReadPixels(x, y, 1, 1, format, GL_UNSIGNED_BYTE, &texel);
glBindFramebuffer(GL_FRAMEBUFFER, old_fbo);
@@ -113,6 +113,91 @@ TEST_F(GLTextureMailboxTest, ProduceAndConsumeTexture) {
EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0));
}
+TEST_F(GLTextureMailboxTest, ProduceAndConsumeTextureRGB) {
+ gl1_.MakeCurrent();
+
+ GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox1);
+
+ GLbyte mailbox2[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox2);
+
+ GLuint tex1;
+ glGenTextures(1, &tex1);
+
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ uint32 source_pixel = 0xFF0000;
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGB,
+ 1, 1,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ &source_pixel);
+
+ glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox1);
+ glFlush();
+
+ gl2_.MakeCurrent();
+
+ GLuint tex2;
+ glGenTextures(1, &tex2);
+
+ glBindTexture(GL_TEXTURE_2D, tex2);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1);
+ EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0, GL_RGB));
+ glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox2);
+ glFlush();
+
+ gl1_.MakeCurrent();
+
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2);
+ EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0, GL_RGB));
+}
+
+TEST_F(GLTextureMailboxTest, ProduceAndConsumeTextureDirect) {
+ gl1_.MakeCurrent();
+
+ GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox1);
+
+ GLbyte mailbox2[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox2);
+
+ 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);
+
+ glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1);
+ glFlush();
+
+ gl2_.MakeCurrent();
+
+ GLuint tex2 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox1);
+ glBindTexture(GL_TEXTURE_2D, tex2);
+ EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0));
+ glProduceTextureDirectCHROMIUM(tex2, GL_TEXTURE_2D, mailbox2);
+ glFlush();
+
+ gl1_.MakeCurrent();
+
+ GLuint tex3 = glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2);
+ glBindTexture(GL_TEXTURE_2D, tex3);
+ EXPECT_EQ(source_pixel, ReadTexel(tex3, 0, 0));
+}
+
TEST_F(GLTextureMailboxTest, ConsumeTextureValidatesKey) {
GLuint tex;
glGenTextures(1, &tex);
@@ -288,6 +373,30 @@ TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) {
glDeleteTextures(1, &tex1);
}
+TEST_F(GLTextureMailboxTest, ProduceTextureDirectInvalideTarget) {
piman 2014/06/09 14:37:25 nit: Invalide->Invalid ?
+ gl1_.MakeCurrent();
+
+ GLbyte mailbox1[GL_MAILBOX_SIZE_CHROMIUM];
+ glGenMailboxCHROMIUM(mailbox1);
+
+ GLuint tex1;
+ glGenTextures(1, &tex1);
+
+ glBindTexture(GL_TEXTURE_CUBE_MAP, tex1);
+ uint32 source_pixel = 0xFF0000FF;
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+ 0,
+ GL_RGBA,
+ 1, 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ &source_pixel);
+
+ glProduceTextureDirectCHROMIUM(tex1, GL_TEXTURE_2D, mailbox1);
+ EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
+}
+
// http://crbug.com/281565
#if !defined(OS_ANDROID)
TEST_F(GLTextureMailboxTest, ProduceFrontBufferMultipleContexts) {
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc ('k') | webkit/common/gpu/webgraphicscontext3d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698