Title: [282800] trunk
Revision
282800
Author
[email protected]
Date
2021-09-20 22:27:09 -0700 (Mon, 20 Sep 2021)

Log Message

ANGLE Metal: single-component swizzles do not compile
https://bugs.webkit.org/show_bug.cgi?id=230472
<rdar://problem/83310780>

Patch by Kimmo Kinnunen <[email protected]> on 2021-09-20
Reviewed by Dean Jackson.

Source/ThirdParty/ANGLE:

Fix metal compiler compile errors when using
single value swizles (glslvariable.r) in position where lvalues would
be needed. Use the variable instead of single element array
(copy-paste typo).

* src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp:

LayoutTests:

Add a test for testing the swizzles as lvalues.

* webgl/pending/conformance/glsl/misc/swizzle-as-lvalue-expected.txt: Added.
* webgl/pending/conformance/glsl/misc/swizzle-as-lvalue.html: Added.
* webgl/pending/resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html: Added.
* webgl/pending/resources/webgl_test_files/resources/glsl-feature-tests.css: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282799 => 282800)


--- trunk/LayoutTests/ChangeLog	2021-09-21 05:15:04 UTC (rev 282799)
+++ trunk/LayoutTests/ChangeLog	2021-09-21 05:27:09 UTC (rev 282800)
@@ -1,3 +1,18 @@
+2021-09-20  Kimmo Kinnunen  <[email protected]>
+
+        ANGLE Metal: single-component swizzles do not compile
+        https://bugs.webkit.org/show_bug.cgi?id=230472
+        <rdar://problem/83310780>
+
+        Reviewed by Dean Jackson.
+
+        Add a test for testing the swizzles as lvalues.
+
+        * webgl/pending/conformance/glsl/misc/swizzle-as-lvalue-expected.txt: Added.
+        * webgl/pending/conformance/glsl/misc/swizzle-as-lvalue.html: Added.
+        * webgl/pending/resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html: Added.
+        * webgl/pending/resources/webgl_test_files/resources/glsl-feature-tests.css: Added.
+
 2021-09-20  Ayumi Kojima  <[email protected]>
 
         [ iOS ] http/tests/websocket/tests/hybi/alert-in-event-handler.html is a flaky crash.

Added: trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue-expected.txt (0 => 282800)


--- trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue-expected.txt	2021-09-21 05:27:09 UTC (rev 282800)
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../../resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html
+
+

Added: trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue.html (0 => 282800)


--- trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue.html	                        (rev 0)
+++ trunk/LayoutTests/webgl/pending/conformance/glsl/misc/swizzle-as-lvalue.html	2021-09-21 05:27:09 UTC (rev 282800)
@@ -0,0 +1,18 @@
+<!-- This file is manually edited and should be deleted once the test is merged in WebGL conformance tests and imported back to LayoutTests. -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for context-attributes-alpha-depth-stencil-antialias.html</title>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href=""
+<div id="iframe">
+<iframe src="" width="800" height="600"></iframe>
+</div>
+<div id="result"></div>
+</body>
+</html>

Added: trunk/LayoutTests/webgl/pending/resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html (0 => 282800)


--- trunk/LayoutTests/webgl/pending/resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html	                        (rev 0)
+++ trunk/LayoutTests/webgl/pending/resources/webgl_test_files/conformance/glsl/misc/swizzle-as-lvalue.html	2021-09-21 05:27:09 UTC (rev 282800)
@@ -0,0 +1,146 @@
+<!--
+Copyright (c) 2021 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL GLSL Conformance Tests - Swizzle as lvalue</title>
+<link rel="stylesheet" href=""
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<!--
+Tests swizzle lvalues with out and inout function parameters.
+6.1.1 Function Calling Conventions
+Evaluation of an inout parameter results in both a value and an l-value; the value is copied to
+the formal parameter at call time and the l- value is used to copy out a value when the function
+returns.
+-->
+<script id="fs0" type="text/something-not-_javascript_">
+precision mediump float;
+void f(out $dim v) {
+    v = $ref;
+}
+void main()
+{
+    vec4 i = vec4(10., 11., 12., 13.);
+    f(i.$components);
+    bool correct = false;
+    if (i == $result)
+        correct = true;
+    gl_FragColor = vec4(0, correct ? 1. : 0., 0., 1.);
+}
+</script>
+<script id="fs1" type="text/something-not-_javascript_">
+precision mediump float;
+void f(inout $dim v) {
+    v += $ref;
+}
+void main()
+{
+    vec4 i = vec4(10., 11., 12., 13.);
+    f(i.$components);
+    bool correct = false;
+    if (i == $resultInOut)
+        correct = true;
+    gl_FragColor = vec4(0, correct ? 1. : 0., 0., 1.);
+}
+</script>
+<script>
+"use strict";
+
+description();
+
+// GLSL ES 3.00.6 5.5 Vector Components
+// To form an l-value, swizzling must be applied to an l-value of vector type, contain no duplicate
+// components, and it results in an l-value of scalar or vector type, depending on number of
+// components specified.
+function computeLValueSwizzles() {
+    let results = [];
+    function f(components, swizzle) {
+        for (let c of components) {
+            results.push(swizzle.concat([c]));
+            let rest = components.filter((e) => { return e != c; });
+            if (rest)
+                f(rest, swizzle.concat([c]));
+        }
+    }
+    f([0, 1, 2, 3], []);
+    return results;
+}
+
+var swizzles = computeLValueSwizzles();
+
+// Sanity check that computing the swizzles produces something to test.
+shouldBe("swizzles.length", "64");
+shouldBe("components(swizzles[0])", "'r'");
+shouldBe("components(swizzles[swizzles.length - 1])", "'abgr'");
+
+var refValue = [ "1.", "2.", "3.", "4." ];
+
+var init = [ "10.", "11.", "12.", "13." ];
+
+function dim(swizzle) {
+  if (swizzle.length == 1)
+    return 'float'
+  return `vec${swizzle.length}`;
+}
+
+function result(swizzle) {
+  let a = init.map((e, c) => {
+      if (swizzle.includes(c))
+        return refValue[c];
+      return e;
+  });
+  return `vec4(${a.join(', ')})`;
+}
+
+function resultInOut(swizzle) {
+  let a = init.map((e, c) => {
+      if (swizzle.includes(c))
+        return `${e} + ${refValue[c]}`;
+      return e;
+  });
+  return `vec4(${a.join(', ')})`;
+}
+
+function ref(swizzle) {
+  let a = swizzle.map((c) => { return refValue[c]; });
+  return `${dim(swizzle)}(${a.join(', ')})`;
+}
+
+function components(swizzle) {
+  return swizzle.map((e) => { return 'rgba'[e]; }).join('');
+}
+
+var tests = [];
+for (var swizzle of swizzles) {
+  for (var ii = 0; ii < 2; ++ii) {
+    var fsrc = document.getElementById("fs" + ii).text;
+    fsrc = fsrc.replace(/\$dim/g, dim(swizzle))
+               .replace(/\$resultInOut/g, resultInOut(swizzle))
+               .replace(/\$result/g, result(swizzle))
+               .replace(/\$ref/g, ref(swizzle))
+               .replace(/\$components/g, components(swizzle));
+    tests.push({
+        fShaderSource: fsrc,
+        fShaderSuccess: true,
+        linkSuccess: true,
+        passMsg: `Swizzle as lvalue works, func: ${ii}, swizzle: ${components(swizzle)}`
+    });
+  }
+}
+
+GLSLConformanceTester.runRenderTests(tests);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgl/pending/resources/webgl_test_files/resources/glsl-feature-tests.css (0 => 282800)


--- trunk/LayoutTests/webgl/pending/resources/webgl_test_files/resources/glsl-feature-tests.css	                        (rev 0)
+++ trunk/LayoutTests/webgl/pending/resources/webgl_test_files/resources/glsl-feature-tests.css	2021-09-21 05:27:09 UTC (rev 282800)
@@ -0,0 +1,29 @@
+canvas {
+  background-color: white;
+  background-image: linear-gradient(0, rgba(200, 200, 200, .5) 50%, transparent 50%), linear-gradient(rgba(200, 200, 200, .5) 50%, transparent 50%);
+  background-size: 8px 8px;
+}
+
+.shader-source {
+  border: 1px dashed black;
+  padding: 1em;
+}
+
+.shader-source li:nth-child(odd) { background: #f8f8f8; }
+.shader-source li:nth-child(even) { background: #f0f0f0; }
+
+.testimages {
+}
+
+.testimages br {
+  clear: both;
+}
+
+.testimages > div {
+  float: left;
+  margin: 1em;
+}
+
+IMG {
+  border: 1px solid black;
+}

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (282799 => 282800)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-09-21 05:15:04 UTC (rev 282799)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-09-21 05:27:09 UTC (rev 282800)
@@ -1,3 +1,18 @@
+2021-09-20  Kimmo Kinnunen  <[email protected]>
+
+        ANGLE Metal: single-component swizzles do not compile
+        https://bugs.webkit.org/show_bug.cgi?id=230472
+        <rdar://problem/83310780>
+
+        Reviewed by Dean Jackson.
+
+        Fix metal compiler compile errors when using 
+        single value swizles (glslvariable.r) in position where lvalues would
+        be needed. Use the variable instead of single element array 
+        (copy-paste typo).
+
+        * src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp:
+
 2021-09-16  Kyle Piddington  <[email protected]>
 
         webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp (282799 => 282800)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp	2021-09-21 05:15:04 UTC (rev 282799)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp	2021-09-21 05:27:09 UTC (rev 282800)
@@ -1224,8 +1224,7 @@
 template <typename T, int N>
 ANGLE_ALWAYS_INLINE ANGLE_VectorElemRef<T, N> ANGLE_swizzle_ref(thread metal::vec<T, N> &vec, int i0)
 {
-    const int is[] = { i0 };
-    return ANGLE_VectorElemRef<T, N>(vec, is);
+    return ANGLE_VectorElemRef<T, N>(vec, i0);
 }
 template <typename T, int N>
 ANGLE_ALWAYS_INLINE ANGLE_SwizzleRef<T, N, 2> ANGLE_swizzle_ref(thread metal::vec<T, N> &vec, int i0, int i1)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to