@@ -83,6 +83,9 @@ class SRGBTextureTest : public ANGLETest
8383 GLint mTextureLocation = -1 ;
8484};
8585
86+ class SRGBTextureTestES3 : public SRGBTextureTest
87+ {};
88+
8689// GenerateMipmaps should generate INVALID_OPERATION in ES 2.0 / WebGL 1.0 with EXT_sRGB.
8790// https://bugs.chromium.org/p/chromium/issues/detail?id=769989
8891TEST_P (SRGBTextureTest, SRGBValidation)
@@ -160,14 +163,11 @@ TEST_P(SRGBTextureTest, SRGBAValidation)
160163}
161164
162165// Test that sized SRGBA formats allow generating mipmaps
163- TEST_P (SRGBTextureTest , SRGBASizedValidation)
166+ TEST_P (SRGBTextureTestES3 , SRGBASizedValidation)
164167{
165168 // TODO(fjhenigman): Figure out why this fails on Ozone Intel.
166169 ANGLE_SKIP_TEST_IF (IsOzone () && IsIntel () && IsOpenGLES ());
167170
168- // ES3 required for sized SRGB textures
169- ANGLE_SKIP_TEST_IF (getClientMajorVersion () < 3 );
170-
171171 GLTexture tex;
172172 glBindTexture (GL_TEXTURE_2D, tex);
173173
@@ -304,11 +304,72 @@ TEST_P(SRGBTextureTest, SRGBOverrideTextureParameter)
304304 EXPECT_PIXEL_COLOR_NEAR (0 , 0 , srgbColor, 1.0 );
305305}
306306
307+ // Test that all supported formats can be overridden
308+ TEST_P (SRGBTextureTestES3, SRGBOverrideFormats)
309+ {
310+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_override" ));
311+
312+ constexpr GLenum possibleFormats[] = {GL_RGB8,
313+ GL_RGBA8,
314+ GL_COMPRESSED_RGB8_ETC2,
315+ GL_COMPRESSED_RGBA8_ETC2_EAC,
316+ GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
317+ GL_COMPRESSED_RGBA_ASTC_4x4,
318+ GL_COMPRESSED_RGBA_ASTC_5x4,
319+ GL_COMPRESSED_RGBA_ASTC_5x5,
320+ GL_COMPRESSED_RGBA_ASTC_6x5,
321+ GL_COMPRESSED_RGBA_ASTC_6x6,
322+ GL_COMPRESSED_RGBA_ASTC_8x5,
323+ GL_COMPRESSED_RGBA_ASTC_8x6,
324+ GL_COMPRESSED_RGBA_ASTC_8x8,
325+ GL_COMPRESSED_RGBA_ASTC_10x5,
326+ GL_COMPRESSED_RGBA_ASTC_10x6,
327+ GL_COMPRESSED_RGBA_ASTC_10x8,
328+ GL_COMPRESSED_RGBA_ASTC_10x10,
329+ GL_COMPRESSED_RGBA_ASTC_12x10,
330+ GL_COMPRESSED_RGBA_ASTC_12x12,
331+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
332+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
333+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
334+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
335+ GL_R8,
336+ GL_RG8,
337+ GL_COMPRESSED_RGBA_BPTC_UNORM_EXT};
338+
339+ for (GLenum format : possibleFormats)
340+ {
341+ GLTexture tex;
342+ glBindTexture (GL_TEXTURE_2D, tex.get ());
343+ glTexStorage2D (GL_TEXTURE_2D, 1 , format, 1 , 1 );
344+ GLenum error = glGetError ();
345+ if (error == GL_INVALID_ENUM)
346+ {
347+ // Format is not supported, we don't require the sRGB counterpart to be supported either
348+ continue ;
349+ }
350+ else
351+ {
352+ ASSERT_EQ (static_cast <GLenum>(GL_NO_ERROR), error);
353+ }
354+
355+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT, GL_NONE);
356+ ASSERT_GL_NO_ERROR ();
357+
358+ glUseProgram (mProgram );
359+ glUniform1i (mTextureLocation , 0 );
360+
361+ glDisable (GL_DEPTH_TEST);
362+ drawQuad (mProgram , " position" , 0 .5f );
363+ ASSERT_GL_NO_ERROR ();
364+ // Discard result, we are only checking that we don't try to reinterpret to an unsupported
365+ // format
366+ }
367+ }
368+
307369// Test interaction between sRGB_override and sampler objects
308- TEST_P (SRGBTextureTest , SRGBOverrideTextureParameterWithSampler)
370+ TEST_P (SRGBTextureTestES3 , SRGBOverrideTextureParameterWithSampler)
309371{
310- ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_override" ) ||
311- getClientMajorVersion () < 3 );
372+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_override" ));
312373
313374 GLColor linearColor = kLinearColor ;
314375 GLColor srgbColor = kNonlinearColor ;
@@ -348,10 +409,10 @@ TEST_P(SRGBTextureTest, SRGBOverrideTextureParameterWithSampler)
348409// EXT_texture_format_sRGB_override spec says:
349410// "If the internal format is not one of the above formats, then
350411// the value of TEXTURE_FORMAT_SRGB_OVERRIDE_EXT is ignored."
351- TEST_P (SRGBTextureTest , SRGBOverrideTextureParameterNoop)
412+ TEST_P (SRGBTextureTestES3 , SRGBOverrideTextureParameterNoop)
352413{
353414 ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_override" ));
354- ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_sRGB" ) || getClientMajorVersion () < 3 );
415+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_sRGB" ));
355416
356417 GLColor linearColor = kLinearColor ;
357418 GLColor srgbColor = kNonlinearColor ;
@@ -378,10 +439,9 @@ TEST_P(SRGBTextureTest, SRGBOverrideTextureParameterNoop)
378439}
379440
380441// Test basic functionality of SRGB decode using the sampler parameter
381- TEST_P (SRGBTextureTest , SRGBDecodeSamplerParameter)
442+ TEST_P (SRGBTextureTestES3 , SRGBDecodeSamplerParameter)
382443{
383- ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ) ||
384- getClientMajorVersion () < 3 );
444+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ));
385445
386446 GLColor linearColor = kLinearColor ;
387447 GLColor srgbColor = kNonlinearColor ;
@@ -411,10 +471,9 @@ TEST_P(SRGBTextureTest, SRGBDecodeSamplerParameter)
411471}
412472
413473// Test that sampler state overrides texture state for srgb decode
414- TEST_P (SRGBTextureTest , SRGBDecodeTextureAndSamplerParameter)
474+ TEST_P (SRGBTextureTestES3 , SRGBDecodeTextureAndSamplerParameter)
415475{
416- ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ) ||
417- getClientMajorVersion () < 3 );
476+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ));
418477
419478 GLColor linearColor = kLinearColor ;
420479 GLColor srgbColor = kNonlinearColor ;
@@ -448,10 +507,9 @@ TEST_P(SRGBTextureTest, SRGBDecodeTextureAndSamplerParameter)
448507}
449508
450509// Test that srgb decode state takes priority over srgb override state
451- TEST_P (SRGBTextureTest , SRGBDecodeOverridePriority)
510+ TEST_P (SRGBTextureTestES3 , SRGBDecodeOverridePriority)
452511{
453- ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ) ||
454- getClientMajorVersion () < 3 );
512+ ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_decode" ));
455513 ANGLE_SKIP_TEST_IF (!IsGLExtensionEnabled (" GL_EXT_texture_sRGB_override" ));
456514
457515 GLColor linearColor = kLinearColor ;
@@ -477,10 +535,8 @@ TEST_P(SRGBTextureTest, SRGBDecodeOverridePriority)
477535}
478536
479537// Test that mipmaps are generated correctly for sRGB textures
480- TEST_P (SRGBTextureTest , GenerateMipmaps)
538+ TEST_P (SRGBTextureTestES3 , GenerateMipmaps)
481539{
482- ANGLE_SKIP_TEST_IF (getClientMajorVersion () < 3 );
483-
484540 ANGLE_SKIP_TEST_IF (IsOpenGL () && ((IsIntel () && IsOSX ()) || IsAMD ()));
485541
486542 auto createAndReadBackTexture = [this ](GLenum internalFormat, const GLColor &color) {
@@ -538,5 +594,6 @@ TEST_P(SRGBTextureTest, GenerateMipmaps)
538594// Use this to select which configurations (e.g. which renderer, which GLES major version) these
539595// tests should be run against.
540596ANGLE_INSTANTIATE_TEST_ES2_AND_ES3 (SRGBTextureTest);
597+ ANGLE_INSTANTIATE_TEST_ES3 (SRGBTextureTestES3);
541598
542599} // namespace angle
0 commit comments