Fix negative CompressedTexImage2D tests
authorAlexander Galazin <alexander.galazin@arm.com>
Mon, 8 May 2017 12:31:15 +0000 (14:31 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 24 May 2017 14:22:36 +0000 (10:22 -0400)
Certain tests expect GL_INVALID_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
VK-GL-CTS issue: 424

Affects:
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d
dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube

Change-Id: Ia37e3fecaf3547abfb209803378114043c63a243
(cherry picked from commit 9de005f0355e389f1782543f34e0fb3c65a0a700)

modules/gles2/functional/es2fNegativeTextureApiTests.cpp

index 4d8d72e75c6189ebc49638b743cc33820f3524b3..964746eb695acbb0447dd3671c3bf3db85708ef0 100644 (file)
@@ -183,10 +183,23 @@ void NegativeTextureApiTests::init (void)
                        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 @@ void NegativeTextureApiTests::init (void)
                        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",