glTexSubImage2D should always allow non-power-of-two inputs
If GL_OES_texture_npot isn't active then ANGLE currently prevents
calls to glTexSubImage2D with:
- level > 0
- width/height NPOT
This isn't correct. It is legitimate to supply data to a NPOT subregion of a
POT texture via glTexSubImage2D.
Fixes these dEQP tests on 9_3:
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.a8_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.a8_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.l8_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.l8_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.la88_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.la88_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgb565_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgb565_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgb888_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgb888_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba4444_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba4444_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba5551_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba5551_cube
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba8888_2d
dEQP-GLES2.functional.texture.specification.basic_texsubimage2d.rgba8888_cube
Change-Id: I5889a27edbfa807995fa20b16f36456f676b80fc
Reviewed-on: https://chromium-review.googlesource.com/304612
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Austin Kinross <aukinros@microsoft.com>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index a693e8c..c744529 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -668,6 +668,26 @@
EXPECT_GL_NO_ERROR();
}
+// Test to ensure that glTexSubImage2D always accepts data for non-power-of-two subregions.
+// ANGLE previously rejected this if GL_OES_texture_npot wasn't active, which is incorrect.
+TEST_P(TextureTest, NPOTSubImageParameters)
+{
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, mTexture2D);
+
+ // Create an 8x8 (i.e. power-of-two) texture.
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glGenerateMipmap(GL_TEXTURE_2D);
+
+ // Supply a 3x3 (i.e. non-power-of-two) subimage to the texture.
+ // This should always work, even if GL_OES_texture_npot isn't active.
+ glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, 3, 3, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+
+ EXPECT_GL_NO_ERROR();
+}
+
// In the D3D11 renderer, we need to initialize some texture formats, to fill empty channels. EG RBA->RGBA8, with 1.0
// in the alpha channel. This test covers a bug where redefining array textures with these formats does not work as
// expected.