Title: [249218] trunk/Source/WebCore
Revision
249218
Author
[email protected]
Date
2019-08-28 13:34:19 -0700 (Wed, 28 Aug 2019)

Log Message

Create ANGLE EGL Context with all extensions disabled by default
https://bugs.webkit.org/show_bug.cgi?id=200900

Patch by Austin Eng <[email protected]> on 2019-08-28
Reviewed by Alex Christensen.

In WebGL, extensions must be explicitly requested before they are enabled.
Fixes the following WebGL conformance tests with the ANGLE backend
LayoutTests/webgl/*/conformance/extensions/ext-blend-minmax.html
LayoutTests/webgl/*/conformance/extensions/ext-frag-depth.html
LayoutTests/webgl/*/conformance/extensions/ext-shader-texture-lod.html
LayoutTests/webgl/*/conformance/extensions/ext-sRGB.html
LayoutTests/webgl/*/conformance/extensions/oes-standard-derivatives.html
LayoutTests/webgl/*/conformance/extensions/oes-texture-float.html
LayoutTests/webgl/*/conformance/extensions/webgl-compressed-texture-s3tc.html
LayoutTests/webgl/*/conformance/glsl/misc/shader-with-dfdx.frag.html
LayoutTests/webgl/*/conformance/glsl/variables/glsl-built-ins.html
LayoutTests/webgl/*/conformance/textures/misc/texture-npot-video.html
LayoutTests/webgl/*/conformance/textures/misc/texture-npot.html

* html/canvas/ANGLEInstancedArrays.cpp:
(WebCore::ANGLEInstancedArrays::ANGLEInstancedArrays):
(WebCore::ANGLEInstancedArrays::supported):
* html/canvas/WebGLCompressedTextureASTC.cpp:
(WebCore::WebGLCompressedTextureASTC::WebGLCompressedTextureASTC):
* html/canvas/WebGLCompressedTextureATC.cpp:
(WebCore::WebGLCompressedTextureATC::WebGLCompressedTextureATC):
* html/canvas/WebGLCompressedTexturePVRTC.cpp:
(WebCore::WebGLCompressedTexturePVRTC::WebGLCompressedTexturePVRTC):
* html/canvas/WebGLCompressedTextureS3TC.cpp:
(WebCore::WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC):
(WebCore::WebGLCompressedTextureS3TC::supported):
* html/canvas/WebGLDebugShaders.cpp:
(WebCore::WebGLDebugShaders::WebGLDebugShaders):
* html/canvas/WebGLDepthTexture.cpp:
(WebCore::WebGLDepthTexture::WebGLDepthTexture):
* html/canvas/WebGLDrawBuffers.cpp:
(WebCore::WebGLDrawBuffers::WebGLDrawBuffers):
(WebCore::WebGLDrawBuffers::supported):
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::validateDepthStencil):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249217 => 249218)


--- trunk/Source/WebCore/ChangeLog	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/ChangeLog	2019-08-28 20:34:19 UTC (rev 249218)
@@ -1,3 +1,49 @@
+2019-08-28  Austin Eng  <[email protected]>
+
+        Create ANGLE EGL Context with all extensions disabled by default
+        https://bugs.webkit.org/show_bug.cgi?id=200900
+
+        Reviewed by Alex Christensen.
+
+        In WebGL, extensions must be explicitly requested before they are enabled.
+        Fixes the following WebGL conformance tests with the ANGLE backend
+        LayoutTests/webgl/*/conformance/extensions/ext-blend-minmax.html
+        LayoutTests/webgl/*/conformance/extensions/ext-frag-depth.html
+        LayoutTests/webgl/*/conformance/extensions/ext-shader-texture-lod.html
+        LayoutTests/webgl/*/conformance/extensions/ext-sRGB.html
+        LayoutTests/webgl/*/conformance/extensions/oes-standard-derivatives.html
+        LayoutTests/webgl/*/conformance/extensions/oes-texture-float.html
+        LayoutTests/webgl/*/conformance/extensions/webgl-compressed-texture-s3tc.html
+        LayoutTests/webgl/*/conformance/glsl/misc/shader-with-dfdx.frag.html
+        LayoutTests/webgl/*/conformance/glsl/variables/glsl-built-ins.html
+        LayoutTests/webgl/*/conformance/textures/misc/texture-npot-video.html
+        LayoutTests/webgl/*/conformance/textures/misc/texture-npot.html
+
+        * html/canvas/ANGLEInstancedArrays.cpp:
+        (WebCore::ANGLEInstancedArrays::ANGLEInstancedArrays):
+        (WebCore::ANGLEInstancedArrays::supported):
+        * html/canvas/WebGLCompressedTextureASTC.cpp:
+        (WebCore::WebGLCompressedTextureASTC::WebGLCompressedTextureASTC):
+        * html/canvas/WebGLCompressedTextureATC.cpp:
+        (WebCore::WebGLCompressedTextureATC::WebGLCompressedTextureATC):
+        * html/canvas/WebGLCompressedTexturePVRTC.cpp:
+        (WebCore::WebGLCompressedTexturePVRTC::WebGLCompressedTexturePVRTC):
+        * html/canvas/WebGLCompressedTextureS3TC.cpp:
+        (WebCore::WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC):
+        (WebCore::WebGLCompressedTextureS3TC::supported):
+        * html/canvas/WebGLDebugShaders.cpp:
+        (WebCore::WebGLDebugShaders::WebGLDebugShaders):
+        * html/canvas/WebGLDepthTexture.cpp:
+        (WebCore::WebGLDepthTexture::WebGLDepthTexture):
+        * html/canvas/WebGLDrawBuffers.cpp:
+        (WebCore::WebGLDrawBuffers::WebGLDrawBuffers):
+        (WebCore::WebGLDrawBuffers::supported):
+        * platform/graphics/angle/GraphicsContext3DANGLE.cpp:
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::validateDepthStencil):
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+
 2019-08-28  Said Abou-Hallawa  <[email protected]>
 
         All image drawing functions should take an argument of type ImagePaintingOptions

Modified: trunk/Source/WebCore/html/canvas/ANGLEInstancedArrays.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/ANGLEInstancedArrays.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/ANGLEInstancedArrays.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -28,7 +28,7 @@
 #if ENABLE(WEBGL)
 #include "ANGLEInstancedArrays.h"
 
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || USE(ANGLE)
 #include "Extensions3D.h"
 #endif
 
@@ -37,6 +37,9 @@
 ANGLEInstancedArrays::ANGLEInstancedArrays(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+#if USE(ANGLE)
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_ANGLE_instanced_arrays");
+#endif
 }
 
 ANGLEInstancedArrays::~ANGLEInstancedArrays() = default;
@@ -49,8 +52,12 @@
 bool ANGLEInstancedArrays::supported(WebGLRenderingContextBase& context)
 {
 #if PLATFORM(COCOA)
+#if USE(ANGLE)
+    return context.graphicsContext3D()->getExtensions().supports("GL_ANGLE_instanced_arrays");
+#else
     UNUSED_PARAM(context);
     return true;
+#endif
 #elif PLATFORM(GTK)
     return context.graphicsContext3D()->getExtensions().supports("GL_ANGLE_instanced_arrays");
 #else

Modified: trunk/Source/WebCore/html/canvas/WebGLCompressedTextureASTC.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLCompressedTextureASTC.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLCompressedTextureASTC.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -39,6 +39,9 @@
     , m_isHDRSupported(context.graphicsContext3D()->getExtensions().supports("GL_KHR_texture_compression_astc_hdr"_s))
     , m_isLDRSupported(context.graphicsContext3D()->getExtensions().supports("GL_KHR_texture_compression_astc_ldr"_s))
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_KHR_texture_compression_astc_hdr"_s);
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_KHR_texture_compression_astc_ldr"_s);
+
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_ASTC_4x4_KHR);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_ASTC_5x4_KHR);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_ASTC_5x5_KHR);

Modified: trunk/Source/WebCore/html/canvas/WebGLCompressedTextureATC.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLCompressedTextureATC.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLCompressedTextureATC.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -36,6 +36,8 @@
 WebGLCompressedTextureATC::WebGLCompressedTextureATC(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_AMD_compressed_ATC_texture");
+
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_ATC_RGB_AMD);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD);

Modified: trunk/Source/WebCore/html/canvas/WebGLCompressedTexturePVRTC.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLCompressedTexturePVRTC.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLCompressedTexturePVRTC.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -37,6 +37,8 @@
 WebGLCompressedTexturePVRTC::WebGLCompressedTexturePVRTC(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_IMG_texture_compression_pvrtc");
+
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG);

Modified: trunk/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLCompressedTextureS3TC.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -37,6 +37,11 @@
 WebGLCompressedTextureS3TC::WebGLCompressedTextureS3TC(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    auto& extensions = context.graphicsContext3D()->getExtensions();
+    extensions.ensureEnabled("GL_EXT_texture_compression_dxt1");
+    extensions.ensureEnabled("GL_ANGLE_texture_compression_dxt3");
+    extensions.ensureEnabled("GL_ANGLE_texture_compression_dxt5");
+
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT);
     context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT);
@@ -53,8 +58,14 @@
 bool WebGLCompressedTextureS3TC::supported(WebGLRenderingContextBase& context)
 {
     auto& extensions = context.graphicsContext3D()->getExtensions();
+#if USE(ANGLE)
+    return extensions.supports("GL_EXT_texture_compression_dxt1")
+        && extensions.supports("GL_ANGLE_texture_compression_dxt3")
+        && extensions.supports("GL_ANGLE_texture_compression_dxt5");
+#else
     return extensions.supports("GL_EXT_texture_compression_s3tc")
         || extensions.supports("GL_EXT_texture_compression_dxt1");
+#endif
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/canvas/WebGLDebugShaders.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLDebugShaders.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLDebugShaders.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -38,6 +38,7 @@
 WebGLDebugShaders::WebGLDebugShaders(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_ANGLE_translated_shader_source");
 }
 
 WebGLDebugShaders::~WebGLDebugShaders() = default;

Modified: trunk/Source/WebCore/html/canvas/WebGLDepthTexture.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLDepthTexture.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLDepthTexture.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -36,6 +36,8 @@
 WebGLDepthTexture::WebGLDepthTexture(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_OES_depth_texture");
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_ARB_depth_texture");
 }
 
 WebGLDepthTexture::~WebGLDepthTexture() = default;

Modified: trunk/Source/WebCore/html/canvas/WebGLDrawBuffers.cpp (249217 => 249218)


--- trunk/Source/WebCore/html/canvas/WebGLDrawBuffers.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/html/canvas/WebGLDrawBuffers.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -35,6 +35,7 @@
 WebGLDrawBuffers::WebGLDrawBuffers(WebGLRenderingContextBase& context)
     : WebGLExtension(context)
 {
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_EXT_draw_buffers");
 }
 
 WebGLDrawBuffers::~WebGLDrawBuffers() = default;
@@ -46,8 +47,12 @@
 
 bool WebGLDrawBuffers::supported(WebGLRenderingContextBase& context)
 {
+#if USE(ANGLE)
+    return context.graphicsContext3D()->getExtensions().supports("GL_EXT_draw_buffers");
+#else
     return context.graphicsContext3D()->getExtensions().supports("GL_EXT_draw_buffers")
         && satisfiesWebGLRequirements(context);
+#endif
 }
 
 void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GC3Denum>& buffers)

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp (249217 => 249218)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp	2019-08-28 20:34:19 UTC (rev 249218)
@@ -145,7 +145,7 @@
 
         Extensions3D& extensions = getExtensions();
         // Use a 24 bit depth buffer where we know we have it.
-        if (extensions.supports("GL_OES_packed_depth_stencil"))
+        if (extensions.supports(packedDepthStencilExtensionName))
             internalDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
         else
             internalDepthStencilFormat = GL_DEPTH_COMPONENT16;
@@ -392,13 +392,10 @@
 
 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension)
 {
-    // Note there are no Extensions3D::ensureEnabled calls here. The ANGLE
-    // backend currently assumes at a fairly deep level that
-    // EGL_EXTENSIONS_ENABLED_ANGLE is set to true during context creation: for
-    // the allocation of rectangular textures, etc.
     Extensions3D& extensions = getExtensions();
     if (m_attrs.stencil) {
         if (extensions.supports(packedDepthStencilExtension)) {
+            extensions.ensureEnabled(packedDepthStencilExtension);
             // Force depth if stencil is true.
             m_attrs.depth = true;
         } else
@@ -409,6 +406,11 @@
         // FIXME: must adjust this when upgrading to WebGL 2.0 / OpenGL ES 3.0 support.
         if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || !extensions.supports("GL_ANGLE_framebuffer_blit") || !extensions.supports("GL_OES_rgb8_rgba8") || isGLES2Compliant())
             m_attrs.antialias = false;
+        else {
+            extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
+            extensions.ensureEnabled("GL_ANGLE_framebuffer_blit");
+            extensions.ensureEnabled("GL_OES_rgb8_rgba8");
+        }
     }
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm (249217 => 249218)


--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2019-08-28 20:23:39 UTC (rev 249217)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm	2019-08-28 20:34:19 UTC (rev 249218)
@@ -329,8 +329,6 @@
     contextAttributes.push_back(2);
     contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
     contextAttributes.push_back(EGL_TRUE);
-    contextAttributes.push_back(EGL_EXTENSIONS_ENABLED_ANGLE);
-    contextAttributes.push_back(EGL_TRUE);
     if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
         contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
         // EGL_LOW_POWER_ANGLE is the default. Change to
@@ -348,6 +346,31 @@
 
     EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
 
+    static constexpr const char* requiredExtensions[] = {
+        "GL_ANGLE_texture_rectangle", // For IOSurface-backed textures
+        "GL_EXT_texture_format_BGRA8888", // For creating the EGL surface from an IOSurface
+    };
+
+    static constexpr const char* optionalExtensions[] = {
+        "GL_EXT_debug_marker",
+    };
+
+    Extensions3D& extensions = getExtensions();
+
+    for (size_t i = 0; i < WTF_ARRAY_LENGTH(requiredExtensions); ++i) {
+        if (!extensions.supports(requiredExtensions[i])) {
+            LOG(WebGL, "Missing required extension.");
+            return;
+        }
+
+        extensions.ensureEnabled(requiredExtensions[i]);
+    }
+
+    for (size_t i = 0; i < WTF_ARRAY_LENGTH(optionalExtensions); ++i) {
+        if (extensions.supports(optionalExtensions[i]))
+            extensions.ensureEnabled(optionalExtensions[i]);
+    }
+
 #endif // #elif USE(ANGLE)
 
     validateAttributes();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to