Title: [281603] branches/safari-612-branch
Revision
281603
Author
[email protected]
Date
2021-08-25 17:01:30 -0700 (Wed, 25 Aug 2021)

Log Message

Cherry-pick r281245. rdar://problem/82354967

    WebGL via Metal experimental feature does not correctly toggle metal backend
    https://bugs.webkit.org/show_bug.cgi?id=229267
    <rdar://81855735>

    Source/WebCore:

    Patch by Kyle Piddington <[email protected]> on 2021-08-19
    Reviewed by Dean Jackson.

    GraphicsContextGLAttributes defines 'useMetal' as 'true' by default.
    Since this branch was only checking if Metal was enabled via the
    setting, rather than checking the status of the flag, the metal backend
    was never disabled, even when requested.

    Tests: webgl/webgl-metal-disabled.html
           webgl/webgl-metal-enabled.html

    * WebCore.xcodeproj/project.pbxproj:
    * html/canvas/WebGLRenderingContextBase.cpp:
    (WebCore::WebGLRenderingContextBase::create):
    * testing/Internals.cpp:
    (WebCore::Internals::requestedMetal):
    * testing/Internals.h:
    * testing/Internals.idl:
    * testing/Internals.mm:
    (WebCore::Internals::platformSupportsMetal):

    LayoutTests:

    Add tests to verify WebGL feature flag works as intended.

    Patch by Kyle Piddington <[email protected]> on 2021-08-19
    Reviewed by Dean Jackson.

    * webgl/webgl-metal-disabled-expected.txt: Added.
    * webgl/webgl-metal-disabled.html: Added.
    * webgl/webgl-metal-enabled-expected.txt: Added.
    * webgl/webgl-metal-enabled.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (281602 => 281603)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-08-26 00:01:30 UTC (rev 281603)
@@ -1,3 +1,63 @@
+2021-08-25  Alan Coon  <[email protected]>
+
+        Cherry-pick r281245. rdar://problem/82354967
+
+    WebGL via Metal experimental feature does not correctly toggle metal backend
+    https://bugs.webkit.org/show_bug.cgi?id=229267
+    <rdar://81855735>
+    
+    Source/WebCore:
+    
+    Patch by Kyle Piddington <[email protected]> on 2021-08-19
+    Reviewed by Dean Jackson.
+    
+    GraphicsContextGLAttributes defines 'useMetal' as 'true' by default.
+    Since this branch was only checking if Metal was enabled via the
+    setting, rather than checking the status of the flag, the metal backend
+    was never disabled, even when requested.
+    
+    Tests: webgl/webgl-metal-disabled.html
+           webgl/webgl-metal-enabled.html
+    
+    * WebCore.xcodeproj/project.pbxproj:
+    * html/canvas/WebGLRenderingContextBase.cpp:
+    (WebCore::WebGLRenderingContextBase::create):
+    * testing/Internals.cpp:
+    (WebCore::Internals::requestedMetal):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    * testing/Internals.mm:
+    (WebCore::Internals::platformSupportsMetal):
+    
+    LayoutTests:
+    
+    Add tests to verify WebGL feature flag works as intended.
+    
+    Patch by Kyle Piddington <[email protected]> on 2021-08-19
+    Reviewed by Dean Jackson.
+    
+    * webgl/webgl-metal-disabled-expected.txt: Added.
+    * webgl/webgl-metal-disabled.html: Added.
+    * webgl/webgl-metal-enabled-expected.txt: Added.
+    * webgl/webgl-metal-enabled.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-19  Kyle Piddington  <[email protected]>
+
+            WebGL via Metal experimental feature does not correctly toggle metal backend
+            https://bugs.webkit.org/show_bug.cgi?id=229267
+            <rdar://81855735>
+
+            Add tests to verify WebGL feature flag works as intended.
+
+            Reviewed by Dean Jackson.
+
+            * webgl/webgl-metal-disabled-expected.txt: Added.
+            * webgl/webgl-metal-disabled.html: Added.
+            * webgl/webgl-metal-enabled-expected.txt: Added.
+            * webgl/webgl-metal-enabled.html: Added.
+
 2021-08-19  Kate Cheney  <[email protected]>
 
         [App Privacy Report] Some HTTP Redirects from non app initiated requests are marked app initiated

Added: branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled-expected.txt (0 => 281603)


--- branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled-expected.txt	2021-08-26 00:01:30 UTC (rev 281603)
@@ -0,0 +1,2 @@
+Metal for WebGL1 disabled when requested: OK
+

Added: branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled.html (0 => 281603)


--- branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webgl/webgl-metal-disabled.html	2021-08-26 00:01:30 UTC (rev 281603)
@@ -0,0 +1,31 @@
+<!-- webkit-test-runner [ WebGLUsingMetal=false ] -->
+<canvas id="a"></canvas>
+<script>
+if (window.testRunner)
+    window.testRunner.dumpAsText();
+
+function run()
+{
+    const out = document.querySelector("p");
+    let result = "";
+
+    if (!window.internals) {
+        out.innerText = "Test requires internals.";
+        return;
+    }
+
+    const canvasA = document.getElementById("a");
+    const glA = canvasA.getContext("webgl");
+    const requested = internals.requestedMetal(glA);
+    const supported = false;
+    let resultStr = "OK";
+    if (requested != supported)
+        resultStr = "FAIL";
+
+    result += `Metal for WebGL1 disabled when requested: ${resultStr}<br>`;
+    out.innerHTML = result;
+}
+
+window.addEventListener("load", run, false);
+</script>
+<p></p>

Added: branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled-expected.txt (0 => 281603)


--- branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled-expected.txt	2021-08-26 00:01:30 UTC (rev 281603)
@@ -0,0 +1,2 @@
+Metal for WebGL1 enabled matches platform support: OK
+

Added: branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled.html (0 => 281603)


--- branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webgl/webgl-metal-enabled.html	2021-08-26 00:01:30 UTC (rev 281603)
@@ -0,0 +1,30 @@
+<canvas id="a"></canvas>
+<script>
+if (window.testRunner)
+    window.testRunner.dumpAsText();
+
+function run()
+{
+    const out = document.querySelector("p");
+    let result = "";
+
+    if (!window.internals) {
+        out.innerText = "Test requires internals.";
+        return;
+    }
+
+    const canvasA = document.getElementById("a");
+    const glA = canvasA.getContext("webgl");
+    const requested = internals.requestedMetal(glA);
+    const supported = internals.platformSupportsMetal(false);
+    let resultStr = "OK";
+    if (requested != supported)
+        resultStr = "FAIL";
+
+    result += `Metal for WebGL1 enabled matches platform support: ${resultStr}<br>`;
+    out.innerHTML = result;
+}
+
+window.addEventListener("load", run, false);
+</script>
+<p></p>

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-08-26 00:01:30 UTC (rev 281603)
@@ -1,3 +1,74 @@
+2021-08-25  Alan Coon  <[email protected]>
+
+        Cherry-pick r281245. rdar://problem/82354967
+
+    WebGL via Metal experimental feature does not correctly toggle metal backend
+    https://bugs.webkit.org/show_bug.cgi?id=229267
+    <rdar://81855735>
+    
+    Source/WebCore:
+    
+    Patch by Kyle Piddington <[email protected]> on 2021-08-19
+    Reviewed by Dean Jackson.
+    
+    GraphicsContextGLAttributes defines 'useMetal' as 'true' by default.
+    Since this branch was only checking if Metal was enabled via the
+    setting, rather than checking the status of the flag, the metal backend
+    was never disabled, even when requested.
+    
+    Tests: webgl/webgl-metal-disabled.html
+           webgl/webgl-metal-enabled.html
+    
+    * WebCore.xcodeproj/project.pbxproj:
+    * html/canvas/WebGLRenderingContextBase.cpp:
+    (WebCore::WebGLRenderingContextBase::create):
+    * testing/Internals.cpp:
+    (WebCore::Internals::requestedMetal):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    * testing/Internals.mm:
+    (WebCore::Internals::platformSupportsMetal):
+    
+    LayoutTests:
+    
+    Add tests to verify WebGL feature flag works as intended.
+    
+    Patch by Kyle Piddington <[email protected]> on 2021-08-19
+    Reviewed by Dean Jackson.
+    
+    * webgl/webgl-metal-disabled-expected.txt: Added.
+    * webgl/webgl-metal-disabled.html: Added.
+    * webgl/webgl-metal-enabled-expected.txt: Added.
+    * webgl/webgl-metal-enabled.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-19  Kyle Piddington  <[email protected]>
+
+            WebGL via Metal experimental feature does not correctly toggle metal backend
+            https://bugs.webkit.org/show_bug.cgi?id=229267
+            <rdar://81855735>
+
+            Reviewed by Dean Jackson.
+
+            GraphicsContextGLAttributes defines 'useMetal' as 'true' by default.
+            Since this branch was only checking if Metal was enabled via the
+            setting, rather than checking the status of the flag, the metal backend
+            was never disabled, even when requested.
+
+            Tests: webgl/webgl-metal-disabled.html
+                   webgl/webgl-metal-enabled.html
+
+            * WebCore.xcodeproj/project.pbxproj:
+            * html/canvas/WebGLRenderingContextBase.cpp:
+            (WebCore::WebGLRenderingContextBase::create):
+            * testing/Internals.cpp:
+            (WebCore::Internals::requestedMetal):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+            * testing/Internals.mm:
+            (WebCore::Internals::platformSupportsMetal):
+
 2021-08-23  Russell Epstein  <[email protected]>
 
         Cherry-pick r281384. rdar://problem/82218757

Modified: branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-08-26 00:01:30 UTC (rev 281603)
@@ -719,8 +719,7 @@
     attributes.webGLVersion = type;
 
 #if PLATFORM(COCOA)
-    if (scriptExecutionContext->settingsValues().webGLUsingMetal)
-        attributes.useMetal = true;
+    attributes.useMetal = scriptExecutionContext->settingsValues().webGLUsingMetal;
 #endif
 
     if (isPendingPolicyResolution) {

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.cpp (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.cpp	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.cpp	2021-08-26 00:01:30 UTC (rev 281603)
@@ -5289,8 +5289,22 @@
 
     return RequestedGPU::Default;
 }
+
+bool Internals::requestedMetal(WebGLRenderingContext& context)
+{
+    UNUSED_PARAM(context);
+#if PLATFORM(COCOA)
+    if (auto optionalAttributes = context.getContextAttributes()) {
+        auto attributes = *optionalAttributes;
+
+        return attributes.useMetal;
+    }
 #endif
 
+    return false;
+}
+#endif
+
 void Internals::setPageVisibility(bool isVisible)
 {
     auto* document = contextDocument();
@@ -6508,4 +6522,11 @@
     return { };
 }
 
+#if ENABLE(WEBGL) && !PLATFORM(COCOA)
+bool Internals::platformSupportsMetal(bool)
+{
+    return false;
+}
+#endif
+
 } // namespace WebCore

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.h (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.h	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.h	2021-08-26 00:01:30 UTC (rev 281603)
@@ -825,6 +825,8 @@
         HighPerformance
     };
     RequestedGPU requestedGPU(WebGLRenderingContext&);
+    bool requestedMetal(WebGLRenderingContext&);
+    bool platformSupportsMetal(bool isWebGL2);
 #endif
 
     void setPageVisibility(bool isVisible);

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.idl (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.idl	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.idl	2021-08-26 00:01:30 UTC (rev 281603)
@@ -855,6 +855,8 @@
     [Conditional=WEBGL] undefined simulateEventForWebGLContext(SimulatedWebGLContextEvent event, WebGLRenderingContext context);
     [Conditional=WEBGL] boolean hasLowAndHighPowerGPUs();
     [Conditional=WEBGL] RequestedGPU requestedGPU(WebGLRenderingContext context);
+    [Conditional=WEBGL] boolean requestedMetal(WebGLRenderingContext context);
+    [Conditional=WEBGL] boolean platformSupportsMetal(boolean isWebGL2);
 
     undefined setPageVisibility(boolean isVisible);
     undefined setPageIsFocusedAndActive(boolean isFocused);

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.mm (281602 => 281603)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.mm	2021-08-26 00:00:38 UTC (rev 281602)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.mm	2021-08-26 00:01:30 UTC (rev 281603)
@@ -38,6 +38,9 @@
 #import "SimpleRange.h"
 #import "UTIUtilities.h"
 #import <AVFoundation/AVPlayer.h>
+#if PLATFORM(COCOA)
+#import <Metal/Metal.h>
+#endif
 #import <pal/spi/cocoa/NSAccessibilitySPI.h>
 #import <wtf/cocoa/NSURLExtras.h>
 #import <wtf/spi/darwin/SandboxSPI.h>
@@ -46,6 +49,8 @@
 #import <pal/ios/UIKitSoftLink.h>
 #endif
 
+
+
 namespace WebCore {
 
 String Internals::userVisibleString(const DOMURL& url)
@@ -146,4 +151,25 @@
     return !sandbox_check(pid, "iokit-open", static_cast<enum sandbox_filter_type>(SANDBOX_FILTER_IOKIT_CONNECTION | SANDBOX_CHECK_NO_REPORT), ioKitClass.utf8().data());
 }
 
+#if ENABLE(WEBGL) && PLATFORM(COCOA)
+bool Internals::platformSupportsMetal(bool isWebGL2)
+{
+    auto device = MTLCreateSystemDefaultDevice();
+
+    if (device) {
+#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR)
+        // A8 devices (iPad Mini 4, iPad Air 2) cannot use WebGL2 via Metal.
+        // This check can be removed once they are no longer supported.
+        if (isWebGL2)
+            return [device supportsFamily:MTLGPUFamilyApple3];
+#else
+        UNUSED_PARAM(isWebGL2);
+#endif
+        return true;
+    }
+
+    return false;
 }
+#endif
+
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to