[ANGLE - iOS] webgl/1.0.3/conformance/extensions/ext-sRGB.html is failing
https://bugs.webkit.org/show_bug.cgi?id=212277

Patch by Kenneth Russell <kbr@chromium.org> on 2020-05-22
Reviewed by Dean Jackson.

Source/ThirdParty/ANGLE:

Properly translate GL_EXT_sRGB enums to ES 3.0 enums when
GL_EXT_sRGB is not supported.

* src/libANGLE/renderer/gl/formatutilsgl.cpp:
(rx::nativegl::GetNativeInternalFormat):
(rx::nativegl::GetNativeFormat):

LayoutTests:

Remove failure expectation for the layout test on iOS.

* platform/ios/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@262091 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index de5af13..0ab3b50 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,16 @@
 2020-05-22  Kenneth Russell  <kbr@chromium.org>
 
+        [ANGLE - iOS] webgl/1.0.3/conformance/extensions/ext-sRGB.html is failing
+        https://bugs.webkit.org/show_bug.cgi?id=212277
+
+        Reviewed by Dean Jackson.
+
+        Remove failure expectation for the layout test on iOS.
+
+        * platform/ios/TestExpectations:
+
+2020-05-22  Kenneth Russell  <kbr@chromium.org>
+
         Remove failure expectation for webgl/1.0.3/conformance/extensions/webgl-depth-texture.html on iOS
         https://bugs.webkit.org/show_bug.cgi?id=212284
 
diff --git a/LayoutTests/platform/ios/TestExpectations b/LayoutTests/platform/ios/TestExpectations
index 9caedb0..b2d30dd 100644
--- a/LayoutTests/platform/ios/TestExpectations
+++ b/LayoutTests/platform/ios/TestExpectations
@@ -3475,7 +3475,6 @@
 webkit.org/b/207858 fast/canvas/webgl/oes-vertex-array-object.html [ Pass Failure ]
 webkit.org/b/207858 fast/canvas/webgl/tex-image-and-sub-image-2d-with-video.html [ Pass Failure ]
 webkit.org/b/207858 webgl/1.0.3/conformance/context/context-lost-restored.html [ Pass Failure ]
-webkit.org/b/207858 webgl/1.0.3/conformance/extensions/ext-sRGB.html [ Pass Failure ]
 webkit.org/b/207858 webgl/1.0.3/conformance/glsl/misc/shader-struct-scope.html [ Pass Failure ]
 webkit.org/b/207858 webgl/1.0.3/conformance/misc/uninitialized-test.html [ Pass Failure ]
 webkit.org/b/207858 webgl/1.0.3/conformance/programs/program-test.html [ Failure ]
diff --git a/Source/ThirdParty/ANGLE/ChangeLog b/Source/ThirdParty/ANGLE/ChangeLog
index f7d9803..bc8b798 100644
--- a/Source/ThirdParty/ANGLE/ChangeLog
+++ b/Source/ThirdParty/ANGLE/ChangeLog
@@ -1,5 +1,19 @@
 2020-05-22  Kenneth Russell  <kbr@chromium.org>
 
+        [ANGLE - iOS] webgl/1.0.3/conformance/extensions/ext-sRGB.html is failing
+        https://bugs.webkit.org/show_bug.cgi?id=212277
+
+        Reviewed by Dean Jackson.
+
+        Properly translate GL_EXT_sRGB enums to ES 3.0 enums when
+        GL_EXT_sRGB is not supported.
+
+        * src/libANGLE/renderer/gl/formatutilsgl.cpp:
+        (rx::nativegl::GetNativeInternalFormat):
+        (rx::nativegl::GetNativeFormat):
+
+2020-05-22  Kenneth Russell  <kbr@chromium.org>
+
         [ANGLE - iOS] fast/canvas/webgl/webgl-depth-texture.html is failing
         https://bugs.webkit.org/show_bug.cgi?id=212271
 
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/formatutilsgl.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/formatutilsgl.cpp
index 50b1073..2181eca 100644
--- a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/formatutilsgl.cpp
+++ b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/formatutilsgl.cpp
@@ -540,12 +540,24 @@
             // Workaround Adreno driver not supporting unsized EXT_texture_rg formats
             result = internalFormat.sizedInternalFormat;
         }
-        else if (features.unsizedsRGBReadPixelsDoesntTransform.enabled &&
-                 internalFormat.colorEncoding == GL_SRGB)
+        else if (internalFormat.colorEncoding == GL_SRGB)
         {
-            // Work around some Adreno driver bugs that don't read back SRGB data correctly when
-            // it's in unsized SRGB texture formats.
-            result = internalFormat.sizedInternalFormat;
+            if (features.unsizedsRGBReadPixelsDoesntTransform.enabled)
+            {
+                // Work around some Adreno driver bugs that don't read back SRGB data correctly when
+                // it's in unsized SRGB texture formats.
+                result = internalFormat.sizedInternalFormat;
+            }
+            else if (!functions->hasGLESExtension("GL_EXT_sRGB"))
+            {
+                // Unsized sRGB internal formats are unlikely to be supported by the
+                // driver. Transform them to sized internal formats.
+                if (internalFormat.internalFormat == GL_SRGB ||
+                    internalFormat.internalFormat == GL_SRGB_ALPHA_EXT)
+                {
+                    result = internalFormat.sizedInternalFormat;
+                }
+            }
         }
         else if ((internalFormat.internalFormat == GL_DEPTH_COMPONENT ||
                   internalFormat.internalFormat == GL_DEPTH_STENCIL) &&
@@ -632,14 +644,15 @@
     }
     else if (functions->isAtLeastGLES(gl::Version(3, 0)))
     {
-        if (features.unsizedsRGBReadPixelsDoesntTransform.enabled)
+        if (features.unsizedsRGBReadPixelsDoesntTransform.enabled ||
+            !functions->hasGLESExtension("GL_EXT_sRGB"))
         {
             if (format == GL_SRGB)
             {
                 result = GL_RGB;
             }
 
-            if (format == GL_SRGB_ALPHA)
+            if (format == GL_SRGB_ALPHA_EXT)
             {
                 result = GL_RGBA;
             }