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

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

Issue 2125023002: Reland "webgl: use immutable texture for the default FBO." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: m_webGLVersion > WebGL1 (for future versions) Created 4 years, 5 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_copy_texture_CHROMIUM_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
index 4b8fa4a5fb84c9d4cf73ac9f346ce58df400faf1..44701c96b195fc0fedef0472d198686c8a72464e 100644
--- a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
+++ b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
@@ -73,6 +73,20 @@ class GLCopyTextureCHROMIUMTest
}
}
+ GLenum ExtractFormatFrom(GLenum internalformat) {
+ switch (internalformat) {
+ case GL_RGBA8_OES:
+ return GL_RGBA;
+ case GL_RGB8_OES:
+ return GL_RGB;
+ case GL_BGRA8_EXT:
+ return GL_BGRA_EXT;
+ default:
+ NOTREACHED();
+ return GL_NONE;
+ }
+ }
+
GLManager gl_;
GLuint textures_[2];
GLuint framebuffer_id_;
@@ -124,41 +138,53 @@ TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) {
return;
}
CopyType copy_type = GetParam();
+ GLenum src_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT};
+ GLenum dest_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT};
- uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
+ uint8_t pixels[1 * 4] = {255u, 0u, 255u, 255u};
- glBindTexture(GL_TEXTURE_2D, textures_[0]);
- glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
- pixels);
+ for (auto src_internal_format : src_internal_formats) {
+ for (auto dest_internal_format : dest_internal_formats) {
+ glDeleteTextures(2, textures_);
+ glDeleteFramebuffers(1, &framebuffer_id_);
+ CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, textures_[1]);
- glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- textures_[1], 0);
- EXPECT_TRUE(glGetError() == GL_NO_ERROR);
+ glBindTexture(GL_TEXTURE_2D, textures_[0]);
+ glTexStorage2DEXT(GL_TEXTURE_2D, 1, src_internal_format, 1, 1);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1,
+ ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE,
+ pixels);
- if (copy_type == TexImage) {
- glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA,
- GL_UNSIGNED_BYTE, false, false, false);
- EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
- } else {
- glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0,
- 0, 1, 1, false, false, false);
- EXPECT_TRUE(glGetError() == GL_NO_ERROR);
+ glBindTexture(GL_TEXTURE_2D, textures_[1]);
+ glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, textures_[1], 0);
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR);
- // Check the FB is still bound.
- GLint value = 0;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
- GLuint fb_id = value;
- EXPECT_EQ(framebuffer_id_, fb_id);
+ if (copy_type == TexImage) {
+ glCopyTextureCHROMIUM(textures_[0], textures_[1],
+ ExtractFormatFrom(dest_internal_format),
+ GL_UNSIGNED_BYTE, false, false, false);
+ EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
+ } else {
+ glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 0, 1, 1,
+ false, false, false);
+ EXPECT_TRUE(glGetError() == GL_NO_ERROR);
- // Check that FB is complete.
- EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- glCheckFramebufferStatus(GL_FRAMEBUFFER));
+ // Check the FB is still bound.
+ GLint value = 0;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
+ GLuint fb_id = value;
+ EXPECT_EQ(framebuffer_id_, fb_id);
- GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels);
- EXPECT_TRUE(GL_NO_ERROR == glGetError());
+ // Check that FB is complete.
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
+ glCheckFramebufferStatus(GL_FRAMEBUFFER));
+
+ GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels);
+ EXPECT_TRUE(GL_NO_ERROR == glGetError());
+ }
+ }
}
}
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698