Fix negative CompressedTexImage2D tests
Certain tests expect GL_VALID_VAULE for
glCompressedTexImage2D(GL_TEXTURE_2D, -1, 0x8b90, 0, 0, 0, 0, 0).
0x8b90 is a palette format PALETTE4_RGB8 and
the OES_compressed_paletted_texture extension allows
negative values for the level parameter:
Accepted by the <level> parameter of CompressedTexImage2D
Zero and negative values. |level| + 1 determines the number of
mip levels defined for the paletted texture.
This change fixes the tests in presence of
the OES_compressed_paletted_texture extension.
Components: AOSP
Google bug: 38109626
Affects:
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube
Change-Id: Ia37e3fecaf3547abfb209803378114043c63a243
diff --git a/framework/opengl/wrapper/glwEnums.inl b/framework/opengl/wrapper/glwEnums.inl
index 452c9de..e0c4d6c 100644
--- a/framework/opengl/wrapper/glwEnums.inl
+++ b/framework/opengl/wrapper/glwEnums.inl
@@ -875,6 +875,16 @@
#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
diff --git a/modules/gles2/functional/es2fNegativeTextureApiTests.cpp b/modules/gles2/functional/es2fNegativeTextureApiTests.cpp
index 4c8b5e4..2ee5a59 100644
--- a/modules/gles2/functional/es2fNegativeTextureApiTests.cpp
+++ b/modules/gles2/functional/es2fNegativeTextureApiTests.cpp
@@ -183,10 +183,23 @@
getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
if (!compressedFormats.empty())
{
- m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
- glCompressedTexImage2D(GL_TEXTURE_2D, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- m_log << TestLog::EndSection;
+ size_t firstNonPalettedFormatNdx = 0;
+ // Negtive values are valid for palette formats
+ if (m_context.getContextInfo().isExtensionSupported("GL_OES_compressed_paletted_texture"))
+ {
+ while (GL_PALETTE4_RGB8_OES <= compressedFormats[firstNonPalettedFormatNdx] &&
+ GL_PALETTE8_RGB5_A1_OES >= compressedFormats[firstNonPalettedFormatNdx])
+ {
+ ++firstNonPalettedFormatNdx;
+ }
+ }
+ if (firstNonPalettedFormatNdx < compressedFormats.size())
+ {
+ m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
+ glCompressedTexImage2D(GL_TEXTURE_2D, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ m_log << TestLog::EndSection;
+ }
}
});
ES2F_ADD_API_CASE(compressedteximage2d_neg_level_cube, "Invalid glCompressedTexImage2D() usage",
@@ -195,20 +208,33 @@
getSupportedExtensions(GL_NUM_COMPRESSED_TEXTURE_FORMATS, GL_COMPRESSED_TEXTURE_FORMATS, compressedFormats);
if (!compressedFormats.empty())
{
- m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, compressedFormats[0], 0, 0, 0, 0, 0);
- expectError(GL_INVALID_VALUE);
- m_log << TestLog::EndSection;
+ size_t firstNonPalettedFormatNdx = 0;
+ // Negtive values are valid for palette formats
+ if (m_context.getContextInfo().isExtensionSupported("GL_OES_compressed_paletted_texture"))
+ {
+ while (GL_PALETTE4_RGB8_OES <= compressedFormats[firstNonPalettedFormatNdx] &&
+ GL_PALETTE8_RGB5_A1_OES >= compressedFormats[firstNonPalettedFormatNdx])
+ {
+ ++firstNonPalettedFormatNdx;
+ }
+ }
+ if (firstNonPalettedFormatNdx < compressedFormats.size())
+ {
+ m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0.");
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, -1, compressedFormats[firstNonPalettedFormatNdx], 0, 0, 0, 0, 0);
+ expectError(GL_INVALID_VALUE);
+ m_log << TestLog::EndSection;
+ }
}
});
ES2F_ADD_API_CASE(compressedteximage2d_level_max_tex2d, "Invalid glCompressedTexImage2D() usage",
diff --git a/scripts/opengl/src_util.py b/scripts/opengl/src_util.py
index 1c248b0..03b3051 100644
--- a/scripts/opengl/src_util.py
+++ b/scripts/opengl/src_util.py
@@ -54,6 +54,7 @@
'GL_EXT_primitive_bounding_box',
'GL_OES_EGL_image',
'GL_OES_compressed_ETC1_RGB8_texture',
+ 'GL_OES_compressed_paletted_texture',
'GL_OES_texture_half_float',
'GL_OES_texture_storage_multisample_2d_array',
'GL_OES_sample_shading',