Fix WebGL 1 conformance regressions when USE_ANGLE=1
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Oct 2019 03:48:11 +0000 (03:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Oct 2019 03:48:11 +0000 (03:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202545

Prevent ANGLE from automatically using ES3 when ES2 is requested.

WEBGL_debug_shaders extension should not accept or return null.

Enable ANGLE's new support for emulating RGB on RGBA IOSurfaces.

Patch by James Darpinian <jdarpinian@chromium.org> on 2019-10-03
Reviewed by Alex Christensen.

* html/canvas/WebGLDebugShaders.cpp:
(WebCore::WebGLDebugShaders::getTranslatedShaderSource):
* html/canvas/WebGLDebugShaders.h:
* html/canvas/WebGLDebugShaders.idl:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateVertexAttributes):
* platform/graphics/angle/Extensions3DANGLE.cpp:
(WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):
* platform/graphics/cocoa/WebGLLayer.mm:
(-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250697 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLDebugShaders.cpp
Source/WebCore/html/canvas/WebGLDebugShaders.h
Source/WebCore/html/canvas/WebGLDebugShaders.idl
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm

index 764d620..93a9aed 100644 (file)
@@ -1,3 +1,29 @@
+2019-10-03  James Darpinian  <jdarpinian@chromium.org>
+
+        Fix WebGL 1 conformance regressions when USE_ANGLE=1
+        https://bugs.webkit.org/show_bug.cgi?id=202545
+
+        Prevent ANGLE from automatically using ES3 when ES2 is requested.
+
+        WEBGL_debug_shaders extension should not accept or return null.
+
+        Enable ANGLE's new support for emulating RGB on RGBA IOSurfaces.
+
+        Reviewed by Alex Christensen.
+
+        * html/canvas/WebGLDebugShaders.cpp:
+        (WebCore::WebGLDebugShaders::getTranslatedShaderSource):
+        * html/canvas/WebGLDebugShaders.h:
+        * html/canvas/WebGLDebugShaders.idl:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::validateVertexAttributes):
+        * platform/graphics/angle/Extensions3DANGLE.cpp:
+        (WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE):
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        * platform/graphics/cocoa/WebGLLayer.mm:
+        (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
+
 2019-10-03  Jer Noble  <jer.noble@apple.com>
 
     [iOS] WebContent process can be interrupted during suspension; loses "Now Playing" status
index 80cdd5c..b8a821b 100644 (file)
@@ -48,13 +48,13 @@ WebGLExtension::ExtensionName WebGLDebugShaders::getName() const
     return WebGLDebugShadersName;
 }
 
-String WebGLDebugShaders::getTranslatedShaderSource(WebGLShader* shader)
+String WebGLDebugShaders::getTranslatedShaderSource(WebGLShader& shader)
 {
     if (m_context.isContextLost())
         return String();
-    if (!m_context.validateWebGLObject("getTranslatedShaderSource", shader))
+    if (!m_context.validateWebGLObject("getTranslatedShaderSource", &shader))
         return emptyString();
-    return m_context.graphicsContext3D()->getExtensions().getTranslatedShaderSourceANGLE(shader->object());
+    return m_context.graphicsContext3D()->getExtensions().getTranslatedShaderSourceANGLE(shader.object());
 }
 
 } // namespace WebCore
index 0d180fa..4560e22 100644 (file)
@@ -40,7 +40,7 @@ public:
 
     ExtensionName getName() const override;
 
-    String getTranslatedShaderSource(WebGLShader*);
+    String getTranslatedShaderSource(WebGLShader&);
 };
 
 } // namespace WebCore
index 97c5e36..935a6f1 100644 (file)
@@ -28,5 +28,5 @@
     GenerateIsReachable=ImplWebGLRenderingContext,
     NoInterfaceObject,
 ] interface WebGLDebugShaders {
-    DOMString? getTranslatedShaderSource(WebGLShader? shader); // FIXME: The return value and the parameter should not be nullable.
+    DOMString getTranslatedShaderSource(WebGLShader shader);
 };
index 2d150c7..3a01d37 100644 (file)
@@ -2120,6 +2120,9 @@ bool WebGLRenderingContextBase::validateVertexAttributes(unsigned elementCount,
             return false;
         }
     }
+#else
+    UNUSED_PARAM(elementCount);
+    UNUSED_PARAM(primitiveCount);
 #endif
     
     return true;
index aa143d0..2dbf3cc 100644 (file)
@@ -111,7 +111,8 @@ String Extensions3DANGLE::getTranslatedShaderSourceANGLE(Platform3DObject shader
     gl::GetTranslatedShaderSourceANGLE(shader, sourceLength, &returnedLength, name.data());
     if (!returnedLength)
         return emptyString();
-    ASSERT(returnedLength == sourceLength);
+    // returnedLength does not include the null terminator.
+    ASSERT(returnedLength == sourceLength - 1);
     return String(name.data(), returnedLength);
 }
 
index ec98051..ae24c78 100644 (file)
@@ -327,6 +327,9 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     std::vector<EGLint> contextAttributes;
     contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
     contextAttributes.push_back(2);
+    // ANGLE will upgrade the context to ES3 automatically unless this is specified.
+    contextAttributes.push_back(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE);
+    contextAttributes.push_back(EGL_FALSE);
     contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
     contextAttributes.push_back(EGL_TRUE);
     if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
index 7dec9ec..8780860 100644 (file)
@@ -220,7 +220,7 @@ static void freeData(void *, const void *data, size_t /* size */)
         EGL_HEIGHT, size.height(),
         EGL_IOSURFACE_PLANE_ANGLE, 0,
         EGL_TEXTURE_TARGET, EGL_TEXTURE_RECTANGLE_ANGLE,
-        EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, GL_BGRA_EXT,
+        EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, usingAlpha ? GL_BGRA_EXT : GL_RGB,
         EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
         EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE,
         EGL_NONE, EGL_NONE