Title: [290643] trunk
Revision
290643
Author
[email protected]
Date
2022-03-01 06:32:12 -0800 (Tue, 01 Mar 2022)

Log Message

WebGL GPUP OpenGL context is not used even if WebGL via Metal is deselected
https://bugs.webkit.org/show_bug.cgi?id=236505

Patch by Kimmo Kinnunen <[email protected]> on 2022-03-01
Reviewed by Myles C. Maxfield.

Source/WebCore:

Encode, decode also `useMetal` property.

Tests: webgl/webgl-via-metal-flag-off.html
       webgl/webgl-via-metal-flag-on.html

* platform/graphics/GraphicsContextGLAttributes.h:
(WebCore::GraphicsContextGLAttributes::encode const):
(WebCore::GraphicsContextGLAttributes::decode):

Source/WebKit:

* Shared/WebCoreArgumentCoders.cpp:
* Shared/WebCoreArgumentCoders.h:

LayoutTests:

* webgl/resources/test-shader-implementation-language.js: Added.
(runTest):
* webgl/webgl-via-metal-flag-off-expected.txt: Added.
* webgl/webgl-via-metal-flag-off.html: Added.
* webgl/webgl-via-metal-flag-on-expected.txt: Added.
* webgl/webgl-via-metal-flag-on.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290642 => 290643)


--- trunk/LayoutTests/ChangeLog	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/LayoutTests/ChangeLog	2022-03-01 14:32:12 UTC (rev 290643)
@@ -1,3 +1,17 @@
+2022-03-01  Kimmo Kinnunen  <[email protected]>
+
+        WebGL GPUP OpenGL context is not used even if WebGL via Metal is deselected
+        https://bugs.webkit.org/show_bug.cgi?id=236505
+
+        Reviewed by Myles C. Maxfield.
+
+        * webgl/resources/test-shader-implementation-language.js: Added.
+        (runTest):
+        * webgl/webgl-via-metal-flag-off-expected.txt: Added.
+        * webgl/webgl-via-metal-flag-off.html: Added.
+        * webgl/webgl-via-metal-flag-on-expected.txt: Added.
+        * webgl/webgl-via-metal-flag-on.html: Added.
+
 2022-03-01  Cameron McCormack  <[email protected]>
 
         Make input element UA shadow tree creation lazy

Modified: trunk/LayoutTests/platform/glib/TestExpectations (290642 => 290643)


--- trunk/LayoutTests/platform/glib/TestExpectations	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/LayoutTests/platform/glib/TestExpectations	2022-03-01 14:32:12 UTC (rev 290643)
@@ -1421,6 +1421,9 @@
 webkit.org/b/169917 webgl/1.0.3/conformance/rendering/point-no-attributes.html [ Failure ]
 webkit.org/b/169917 webgl/1.0.3/conformance/textures/texture-copying-feedback-loops.html [ Failure ]
 
+# Not applicable.
+webgl/webgl-via-metal-flag-on.html [ Skip ]
+webgl/webgl-via-metal-flag-off.html [ Skip ]
 
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of WebGL-related bugs

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (290642 => 290643)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2022-03-01 14:32:12 UTC (rev 290643)
@@ -2109,3 +2109,7 @@
 fast/text/kerning-with-TextLayout.html [ ImageOnlyFailure ]
 http/tests/lists/list-new-parent-no-sibling-append.html [ Failure ]
 fast/js-promise/js-promise-invalid-context-access.html [ Failure ]
+
+# Not applicable.
+webgl/webgl-via-metal-flag-on.html [ Skip ]
+webgl/webgl-via-metal-flag-off.html [ Skip ]

Added: trunk/LayoutTests/webgl/resources/test-shader-implementation-language.js (0 => 290643)


--- trunk/LayoutTests/webgl/resources/test-shader-implementation-language.js	                        (rev 0)
+++ trunk/LayoutTests/webgl/resources/test-shader-implementation-language.js	2022-03-01 14:32:12 UTC (rev 290643)
@@ -0,0 +1,27 @@
+"use strict";
+
+let subcases = [];
+for (let contextType of [ "webgl", "webgl2" ]) {
+    subcases.push({ contextType });
+}
+
+function runTest() {
+    for (const subcase of subcases) {
+        const canvas = document.createElement("canvas");
+        const gl = canvas.getContext(subcase.contextType);
+        if (!gl) {
+            testPassed(`${subcase.contextType}: Not supported.`);
+            continue;
+        }
+        const shader = gl.createShader(gl.FRAGMENT_SHADER);
+        gl.shaderSource(shader, "void main() { gl_FragColor = vec4(gl_FragCoord.x, 0.0, 0.0, 1.0); }");
+        gl.compileShader(shader);
+        const src = ""
+        let type = "Unknown";
+        if (src.search(/^fragment ANGLE_FragmentOut main/m) >= 0)
+            type = "Metal";
+        if (src.search(/^void main()/m) >= 0)
+            type = "OpenGL";
+        testPassed(`${subcase.contextType}: Detected shader implementation language: ${type}`);
+    }
+}
\ No newline at end of file

Added: trunk/LayoutTests/webgl/webgl-via-metal-flag-off-expected.txt (0 => 290643)


--- trunk/LayoutTests/webgl/webgl-via-metal-flag-off-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgl/webgl-via-metal-flag-off-expected.txt	2022-03-01 14:32:12 UTC (rev 290643)
@@ -0,0 +1,13 @@
+This test outputs WebGL GLSL implementation language when using WebGLUsingMetal=false.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+TEST COMPLETE: 3 PASS, 0 FAIL
+
+
+PASS webgl: Detected shader implementation language: OpenGL
+PASS webgl2: Detected shader implementation language: OpenGL
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webgl/webgl-via-metal-flag-off.html (0 => 290643)


--- trunk/LayoutTests/webgl/webgl-via-metal-flag-off.html	                        (rev 0)
+++ trunk/LayoutTests/webgl/webgl-via-metal-flag-off.html	2022-03-01 14:32:12 UTC (rev 290643)
@@ -0,0 +1,25 @@
+<!DOCTYPE html><!-- webkit-test-runner [ WebGLUsingMetal=false runSingly=true ] -->
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebKit test WebGLUsingMetal=false</title>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("This test outputs WebGL GLSL implementation language when using WebGLUsingMetal=false.");
+
+debug("");
+runTest();
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/webgl/webgl-via-metal-flag-on-expected.txt (0 => 290643)


--- trunk/LayoutTests/webgl/webgl-via-metal-flag-on-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgl/webgl-via-metal-flag-on-expected.txt	2022-03-01 14:32:12 UTC (rev 290643)
@@ -0,0 +1,13 @@
+This test outputs WebGL GLSL implementation language when using WebGLUsingMetal=true.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+TEST COMPLETE: 3 PASS, 0 FAIL
+
+
+PASS webgl: Detected shader implementation language: Metal
+PASS webgl2: Detected shader implementation language: Metal
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webgl/webgl-via-metal-flag-on.html (0 => 290643)


--- trunk/LayoutTests/webgl/webgl-via-metal-flag-on.html	                        (rev 0)
+++ trunk/LayoutTests/webgl/webgl-via-metal-flag-on.html	2022-03-01 14:32:12 UTC (rev 290643)
@@ -0,0 +1,25 @@
+<!DOCTYPE html><!-- webkit-test-runner [ WebGLUsingMetal=true runSingly=true ] -->
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebKit test WebGLUsingMetal=true</title>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("This test outputs WebGL GLSL implementation language when using WebGLUsingMetal=true.");
+
+debug("");
+runTest();
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (290642 => 290643)


--- trunk/Source/WebCore/ChangeLog	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/Source/WebCore/ChangeLog	2022-03-01 14:32:12 UTC (rev 290643)
@@ -1,5 +1,21 @@
 2022-03-01  Kimmo Kinnunen  <[email protected]>
 
+        WebGL GPUP OpenGL context is not used even if WebGL via Metal is deselected
+        https://bugs.webkit.org/show_bug.cgi?id=236505
+
+        Reviewed by Myles C. Maxfield.
+
+        Encode, decode also `useMetal` property.
+
+        Tests: webgl/webgl-via-metal-flag-off.html
+               webgl/webgl-via-metal-flag-on.html
+
+        * platform/graphics/GraphicsContextGLAttributes.h:
+        (WebCore::GraphicsContextGLAttributes::encode const):
+        (WebCore::GraphicsContextGLAttributes::decode):
+
+2022-03-01  Kimmo Kinnunen  <[email protected]>
+
         GraphicsContextGL related includes are inconsistent, slowing the build
         https://bugs.webkit.org/show_bug.cgi?id=237270
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h (290642 => 290643)


--- trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h	2022-03-01 14:32:12 UTC (rev 290643)
@@ -26,6 +26,8 @@
 #pragma once
 
 #if ENABLE(WEBGL)
+#include <optional>
+#include <wtf/EnumTraits.h>
 
 namespace WebCore {
 
@@ -74,8 +76,117 @@
             return PowerPreference::HighPerformance;
         return powerPreference;
     }
+
+#if ENABLE(GPU_PROCESS)
+    template<typename Encoder> void encode(Encoder&) const;
+    template<typename Decoder> static std::optional<GraphicsContextGLAttributes> decode(Decoder&);
+#endif
 };
 
+#if ENABLE(GPU_PROCESS)
+
+template<typename Encoder>
+void GraphicsContextGLAttributes::encode(Encoder& encoder) const
+{
+    encoder << alpha
+        << depth
+        << stencil
+        << antialias
+        << premultipliedAlpha
+        << preserveDrawingBuffer
+        << failIfMajorPerformanceCaveat
+        << powerPreference
+        << shareResources
+        << noExtensions
+        << devicePixelRatio
+        << initialPowerPreference
+        << webGLVersion
+        << forceRequestForHighPerformanceGPU;
+#if PLATFORM(COCOA)
+    encoder << useMetal;
+#endif
+#if ENABLE(WEBXR)
+    encoder << xrCompatible;
+#endif
 }
 
+template<typename Decoder>
+std::optional<WebCore::GraphicsContextGLAttributes> GraphicsContextGLAttributes::decode(Decoder& decoder)
+{
+    auto alpha = decoder.template decode<bool>();
+    auto depth = decoder.template decode<bool>();
+    auto stencil = decoder.template decode<bool>();
+    auto antialias = decoder.template decode<bool>();
+    auto premultipliedAlpha = decoder.template decode<bool>();
+    auto preserveDrawingBuffer = decoder.template decode<bool>();
+    auto failIfMajorPerformanceCaveat = decoder.template decode<bool>();
+    auto powerPreference = decoder.template decode<PowerPreference>();
+    auto shareResources = decoder.template decode<bool>();
+    auto noExtensions = decoder.template decode<bool>();
+    auto devicePixelRatio = decoder.template decode<float>();
+    auto initialPowerPreference = decoder.template decode<PowerPreference>();
+    auto webGLVersion = decoder.template decode<WebGLVersion>();
+    auto forceRequestForHighPerformanceGPU = decoder.template decode<bool>();
+#if PLATFORM(COCOA)
+    auto useMetal = decoder.template decode<bool>();
+#endif
+#if ENABLE(WEBXR)
+    auto xrCompatible = decoder.template decode<bool>();
+#endif
+    if (!decoder.isValid())
+        return std::nullopt;
+    return GraphicsContextGLAttributes {
+        *alpha,
+        *depth,
+        *stencil,
+        *antialias,
+        *premultipliedAlpha,
+        *preserveDrawingBuffer,
+        *failIfMajorPerformanceCaveat,
+        *powerPreference,
+        *shareResources,
+        *noExtensions,
+        *devicePixelRatio,
+        *initialPowerPreference,
+        *webGLVersion,
+        *forceRequestForHighPerformanceGPU,
+#if PLATFORM(COCOA)
+        *useMetal,
+#endif
+#if ENABLE(WEBXR)
+        *xrCompatible
+#endif
+    };
+}
+
+#endif
+
+}
+
+#if ENABLE(GPU_PROCESS)
+namespace WTF {
+
+template <> struct EnumTraits<WebCore::GraphicsContextGLPowerPreference> {
+    using values = EnumValues<
+    WebCore::GraphicsContextGLPowerPreference,
+    WebCore::GraphicsContextGLPowerPreference::Default,
+    WebCore::GraphicsContextGLPowerPreference::LowPower,
+    WebCore::GraphicsContextGLPowerPreference::HighPerformance
+    >;
+};
+
+template <> struct EnumTraits<WebCore::GraphicsContextGLWebGLVersion> {
+    using values = EnumValues<
+    WebCore::GraphicsContextGLWebGLVersion,
+    WebCore::GraphicsContextGLWebGLVersion::WebGL1
+#if ENABLE(WEBGL2)
+    , WebCore::GraphicsContextGLWebGLVersion::WebGL2
+#endif
+    >;
+};
+
+}
+
+#endif
+
 #endif // ENABLE(WEBGL)

Modified: trunk/Source/WebKit/ChangeLog (290642 => 290643)


--- trunk/Source/WebKit/ChangeLog	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/Source/WebKit/ChangeLog	2022-03-01 14:32:12 UTC (rev 290643)
@@ -1,5 +1,15 @@
 2022-03-01  Kimmo Kinnunen  <[email protected]>
 
+        WebGL GPUP OpenGL context is not used even if WebGL via Metal is deselected
+        https://bugs.webkit.org/show_bug.cgi?id=236505
+
+        Reviewed by Myles C. Maxfield.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        * Shared/WebCoreArgumentCoders.h:
+
+2022-03-01  Kimmo Kinnunen  <[email protected]>
+
         GraphicsContextGL related includes are inconsistent, slowing the build
         https://bugs.webkit.org/show_bug.cgi?id=237270
 

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (290642 => 290643)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2022-03-01 14:32:12 UTC (rev 290643)
@@ -3199,62 +3199,7 @@
 #endif // ENABLE(ENCRYPTED_MEDIA)
 
 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
-void ArgumentCoder<WebCore::GraphicsContextGLAttributes>::encode(Encoder& encoder, const WebCore::GraphicsContextGLAttributes& attributes)
-{
-    encoder << attributes.alpha;
-    encoder << attributes.depth;
-    encoder << attributes.stencil;
-    encoder << attributes.antialias;
-    encoder << attributes.premultipliedAlpha;
-    encoder << attributes.preserveDrawingBuffer;
-    encoder << attributes.failIfMajorPerformanceCaveat;
-    encoder << attributes.powerPreference;
-    encoder << attributes.shareResources;
-    encoder << attributes.webGLVersion;
-    encoder << attributes.noExtensions;
-    encoder << attributes.devicePixelRatio;
-    encoder << attributes.initialPowerPreference;
-#if ENABLE(WEBXR)
-    encoder << attributes.xrCompatible;
-#endif
-}
 
-std::optional<WebCore::GraphicsContextGLAttributes> ArgumentCoder<WebCore::GraphicsContextGLAttributes>::decode(Decoder& decoder)
-{
-    GraphicsContextGLAttributes attributes;
-    if (!decoder.decode(attributes.alpha))
-        return std::nullopt;
-    if (!decoder.decode(attributes.depth))
-        return std::nullopt;
-    if (!decoder.decode(attributes.stencil))
-        return std::nullopt;
-    if (!decoder.decode(attributes.antialias))
-        return std::nullopt;
-    if (!decoder.decode(attributes.premultipliedAlpha))
-        return std::nullopt;
-    if (!decoder.decode(attributes.preserveDrawingBuffer))
-        return std::nullopt;
-    if (!decoder.decode(attributes.failIfMajorPerformanceCaveat))
-        return std::nullopt;
-    if (!decoder.decode(attributes.powerPreference))
-        return std::nullopt;
-    if (!decoder.decode(attributes.shareResources))
-        return std::nullopt;
-    if (!decoder.decode(attributes.webGLVersion))
-        return std::nullopt;
-    if (!decoder.decode(attributes.noExtensions))
-        return std::nullopt;
-    if (!decoder.decode(attributes.devicePixelRatio))
-        return std::nullopt;
-    if (!decoder.decode(attributes.initialPowerPreference))
-        return std::nullopt;
-#if ENABLE(WEBXR)
-    if (!decoder.decode(attributes.xrCompatible))
-        return std::nullopt;
-#endif
-    return attributes;
-}
-
 template<typename Encoder>
 void ArgumentCoder<WebCore::GraphicsContextGL::ActiveInfo>::encode(Encoder& encoder, const WebCore::GraphicsContextGL::ActiveInfo& activeInfo)
 {

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (290642 => 290643)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2022-03-01 14:23:28 UTC (rev 290642)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2022-03-01 14:32:12 UTC (rev 290643)
@@ -87,7 +87,6 @@
 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
 #include "ArrayReference.h"
 #include <WebCore/GraphicsContextGL.h>
-#include <WebCore/GraphicsContextGLAttributes.h>
 #include <WebCore/GraphicsTypesGL.h>
 #endif
 
@@ -218,10 +217,6 @@
 struct SerializedAttachmentData;
 #endif
 
-#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
-struct GraphicsContextGLAttributes;
-#endif
-
 namespace DOMCacheEngine {
 struct CacheInfo;
 struct Record;
@@ -802,11 +797,6 @@
 
 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
 
-template<> struct ArgumentCoder<WebCore::GraphicsContextGLAttributes> {
-    static void encode(Encoder&, const WebCore::GraphicsContextGLAttributes&);
-    static std::optional<WebCore::GraphicsContextGLAttributes> decode(Decoder&);
-};
-
 template<> struct ArgumentCoder<WebCore::GraphicsContextGL::ActiveInfo> {
     template<typename Encoder>
     static void encode(Encoder&, const WebCore::GraphicsContextGL::ActiveInfo&);
@@ -992,25 +982,6 @@
 
 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
 
-template <> struct EnumTraits<WebCore::GraphicsContextGLPowerPreference> {
-    using values = EnumValues <
-    WebCore::GraphicsContextGLPowerPreference,
-    WebCore::GraphicsContextGLPowerPreference::Default,
-    WebCore::GraphicsContextGLPowerPreference::LowPower,
-    WebCore::GraphicsContextGLPowerPreference::HighPerformance
-    >;
-};
-
-template <> struct EnumTraits<WebCore::GraphicsContextGLWebGLVersion> {
-    using values = EnumValues <
-    WebCore::GraphicsContextGLWebGLVersion,
-    WebCore::GraphicsContextGLWebGLVersion::WebGL1
-#if ENABLE(WEBGL2)
-    , WebCore::GraphicsContextGLWebGLVersion::WebGL2
-#endif
-    >;
-};
-
 template <> struct EnumTraits<WebCore::GraphicsContextGL::SimulatedEventForTesting> {
     using values = EnumValues<
     WebCore::GraphicsContextGL::SimulatedEventForTesting,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to