EXT_texture_norm16 readpixels fix
Adding validation logic for RGBA16 readpixels.
Change readPixels format from UNSIGNED_BYTE to UNSIGNED_SHORT in the
test.
FYI:
According to https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_norm16.txt
ReadPixels format and type used during CopyTex* are limited to RGBA
Bug: 1024387, 1000354, angleproject:1365, angleproject:4089
Change-Id: I70517f255fe335f60e55bdf15f7ebf82e3de0800
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1914127
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index e179e99..d3f105f 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -48,6 +48,30 @@
}
}
+GLColor16UI SliceFormatColor16UI(GLenum format, GLColor16UI full)
+{
+ switch (format)
+ {
+ case GL_RED:
+ return GLColor16UI(full.R, 0, 0, 0xFFFF);
+ case GL_RG:
+ return GLColor16UI(full.R, full.G, 0, 0xFFFF);
+ case GL_RGB:
+ return GLColor16UI(full.R, full.G, full.B, 0xFFFF);
+ case GL_RGBA:
+ return full;
+ case GL_LUMINANCE:
+ return GLColor16UI(full.R, full.R, full.R, 0xFFFF);
+ case GL_ALPHA:
+ return GLColor16UI(0, 0, 0, full.R);
+ case GL_LUMINANCE_ALPHA:
+ return GLColor16UI(full.R, full.R, full.R, full.G);
+ default:
+ EXPECT_TRUE(false);
+ return GLColor16UI(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
+ }
+}
+
// As above, for 32F colors
GLColor32F SliceFormatColor32F(GLenum format, GLColor32F full)
{
@@ -4151,10 +4175,9 @@
drawQuad(mProgram, "position", 0.5f);
- GLubyte expectedValue = static_cast<GLubyte>(pixelValue >> 8);
- EXPECT_PIXEL_COLOR_EQ(0, 0,
- SliceFormatColor(format, GLColor(expectedValue, expectedValue,
- expectedValue, expectedValue)));
+ EXPECT_PIXEL_16UI_COLOR(0, 0,
+ SliceFormatColor16UI(format, GLColor16UI(pixelValue, pixelValue,
+ pixelValue, pixelValue)));
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, internalformat, 1, 1);
@@ -4166,18 +4189,20 @@
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
- EXPECT_PIXEL_COLOR_EQ(0, 0, SliceFormatColor(format, GLColor::white));
+ EXPECT_PIXEL_16UI_COLOR(
+ 0, 0, SliceFormatColor16UI(format, GLColor16UI(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF)));
glBindTexture(GL_TEXTURE_2D, mTextures[1]);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1],
0);
- EXPECT_PIXEL_COLOR_EQ(0, 0, SliceFormatColor(format, GLColor::white));
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ EXPECT_PIXEL_16UI_COLOR(
+ 0, 0, SliceFormatColor16UI(format, GLColor16UI(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF)));
ASSERT_GL_NO_ERROR();
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
GLuint mTextures[3];
@@ -4205,8 +4230,6 @@
testNorm16Texture(GL_RGB16_SNORM_EXT, GL_RGB, GL_SHORT);
testNorm16Texture(GL_RGBA16_SNORM_EXT, GL_RGBA, GL_SHORT);
- testNorm16Render(GL_R16_EXT, GL_RED, GL_UNSIGNED_SHORT);
- testNorm16Render(GL_RG16_EXT, GL_RG, GL_UNSIGNED_SHORT);
testNorm16Render(GL_RGBA16_EXT, GL_RGBA, GL_UNSIGNED_SHORT);
}