Title: [248795] trunk
Revision
248795
Author
sbar...@apple.com
Date
2019-08-16 13:59:29 -0700 (Fri, 16 Aug 2019)

Log Message

[WHLSL] Make operator== native and add bool matrices
https://bugs.webkit.org/show_bug.cgi?id=200749

Reviewed by Myles C. Maxfield.

Source/WebCore:

This patch makes operator== native and implements them the right way
for vectors and matrices. Previously, we would just return a single
boolean indicating if all elements were equal. However, to be compatible
with HLSL, we should return a boolean vector or matrix, indicating which
elements are equal or not. This patch makes this change, and in the process,
adds a bool matrix.

This patch also:
- Lifts the requirement that all comparison operators in user code must return bool.
We no longer follow this in the standard library, and don't want to require user
code to do so. It seems reasonable to have a custom comparison operator
which returns an enum of the form { LessThan, Equal, GreaterThan, Incomparable }
- Changes the native operator inliner to no longer assume that operations on
matrices return the same type as the arguments. This was true for math, but
is not true for comparison operators.

Tests: webgpu/whlsl/bool-matrix.html
       webgpu/whlsl/operator-equal-equal.html

* Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
(WebCore::WHLSL::Metal::inlineNativeFunction):
* Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp:
(WebCore::WHLSL::Metal::writeNativeType):
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::checkOperatorOverload):
* Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:
(WebCore::WHLSL::Intrinsics::addMatrix):
* Modules/webgpu/WHLSL/WHLSLIntrinsics.h:
(WebCore::WHLSL::Intrinsics::WTF_ARRAY_LENGTH):
* Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt:

LayoutTests:

* webgpu/whlsl/bool-matrix-expected.txt: Added.
* webgpu/whlsl/bool-matrix.html: Added.
* webgpu/whlsl/builtin-vectors.html:
* webgpu/whlsl/matrices-spec-tests.html:
* webgpu/whlsl/operator-equal-equal-expected.txt: Added.
* webgpu/whlsl/operator-equal-equal.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (248794 => 248795)


--- trunk/LayoutTests/ChangeLog	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/LayoutTests/ChangeLog	2019-08-16 20:59:29 UTC (rev 248795)
@@ -1,3 +1,17 @@
+2019-08-16  Saam Barati  <sbar...@apple.com>
+
+        [WHLSL] Make operator== native and add bool matrices
+        https://bugs.webkit.org/show_bug.cgi?id=200749
+
+        Reviewed by Myles C. Maxfield.
+
+        * webgpu/whlsl/bool-matrix-expected.txt: Added.
+        * webgpu/whlsl/bool-matrix.html: Added.
+        * webgpu/whlsl/builtin-vectors.html:
+        * webgpu/whlsl/matrices-spec-tests.html:
+        * webgpu/whlsl/operator-equal-equal-expected.txt: Added.
+        * webgpu/whlsl/operator-equal-equal.html: Added.
+
 2019-08-16  Zalan Bujtas  <za...@apple.com>
 
         [ContentChangeObserver] Add ContentChangeObserver::elementDidBecomeHidden

Added: trunk/LayoutTests/webgpu/whlsl/bool-matrix-expected.txt (0 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/bool-matrix-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/bool-matrix-expected.txt	2019-08-16 20:59:29 UTC (rev 248795)
@@ -0,0 +1,11 @@
+
+PASS boolMatrix 
+PASS boolMatrix2 
+PASS boolMatrix3 
+PASS boolMatrix4 
+PASS boolMatrix5 
+PASS boolMatrixAny 
+PASS boolMatrixAny2 
+PASS boolMatrixAll 
+PASS boolMatrixAll2 
+

Added: trunk/LayoutTests/webgpu/whlsl/bool-matrix.html (0 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/bool-matrix.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/bool-matrix.html	2019-08-16 20:59:29 UTC (rev 248795)
@@ -0,0 +1,118 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>bool matrix.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.boolMatrix = async () => {
+    const program = `
+        int foo() {
+            bool2x2 m;
+            m[0] = bool2(true, false);
+            m[1] = bool2(true, true);
+            return int(m[0][0]) + int(m[0][1]) + int(m[1][0]) + int(m[1][1]);
+        }
+    `;
+
+    assert_equals(await callIntFunction(program,  "foo", []), 3);
+};
+
+whlslTests.boolMatrix2 = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(true, false, true, false);
+            return m[0][0] && !m[0][1] && m[1][0] && !m[1][1];
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrix3 = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(true, false, true, false);
+            return m[0][0] && !m[0][1] && m[1][0] && !m[1][1];
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrix4 = async () => {
+    const program = `
+        bool foo() {
+            bool2x3 m = bool2x3(true, true, true, false, false, false);
+            return m[0][0] && m[0][1] && m[0][2] && !m[1][0] && !m[1][1] && !m[1][2];
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrix5 = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m;
+            m[0] = bool2(true, false);
+            m[1] = bool2(true, false);
+            return m[0][0] && !m[0][1] && m[1][0] && !m[1][1];
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrixAny = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(false, false, false, false);
+            return !any(m);
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrixAny2 = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(false, false, true, false);
+            return any(m);
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrixAll = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(true, true, true, false);
+            return !all(m);
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.boolMatrixAll2 = async () => {
+    const program = `
+        bool foo() {
+            bool2x2 m = bool2x2(true, true, true, true);
+            return all(m);
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+runTests(whlslTests);
+</script>
+</html>

Modified: trunk/LayoutTests/webgpu/whlsl/builtin-vectors.html (248794 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/builtin-vectors.html	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/LayoutTests/webgpu/whlsl/builtin-vectors.html	2019-08-16 20:59:29 UTC (rev 248795)
@@ -79,7 +79,7 @@
             int4 a = int4(3, 4, 5, 6);
             int2 b = int2(4, 5);
             int4 c = int4(3, b, 6);
-            return a == c;
+            return all(a == c);
         }
         bool foo6()
         {
@@ -86,7 +86,7 @@
             int2 a = int2(4, 5);
             int3 b = int3(3, a);
             int3 c = int3(3, 4, 6);
-            return b == c;
+            return all(b == c);
         }
         uint foou()
         {
@@ -117,7 +117,7 @@
             uint4 a = uint4(3, 4, 5, 6);
             uint2 b = uint2(4, 5);
             uint4 c = uint4(3, b, 6);
-            return a == c;
+            return all(a == c);
         }
         bool foou6()
         {
@@ -124,7 +124,7 @@
             uint2 a = uint2(4, 5);
             uint3 b = uint3(3, a);
             uint3 c = uint3(3, 4, 6);
-            return b == c;
+            return all(b == c);
         }
         float foof()
         {
@@ -155,7 +155,7 @@
             float4 a = float4(3., 4., 5., 6.);
             float2 b = float2(4., 5.);
             float4 c = float4(3., b, 6.);
-            return a == c;
+            return all(a == c);
         }
         bool foof6()
         {
@@ -162,7 +162,7 @@
             float2 a = float2(4., 5.);
             float3 b = float3(3., a);
             float3 c = float3(3., 4., 6.);
-            return b == c;
+            return all(b == c);
         }
     `;
     assert_equals(await callIntFunction(program, "foo", []), 3);

Modified: trunk/LayoutTests/webgpu/whlsl/matrices-spec-tests.html (248794 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/matrices-spec-tests.html	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/LayoutTests/webgpu/whlsl/matrices-spec-tests.html	2019-08-16 20:59:29 UTC (rev 248795)
@@ -54,7 +54,7 @@
                     a[i][j] += 4;
                 }
             }
-            return a == b;
+            return all(a == b);
         }
         bool foo5()
         {
@@ -66,7 +66,7 @@
             b[0][1] = 2;
             b[1][0] = 3;
             b[1][1] = 4;
-            return a == b;
+            return all(a == b);
         }
         bool foo6()
         {
@@ -82,7 +82,7 @@
             b[1][1] = 24;
             a[0] *= 5;
             a[1] *= 6;
-            return a == b;
+            return all(a == b);
         }
         float foo7()
         {

Added: trunk/LayoutTests/webgpu/whlsl/operator-equal-equal-expected.txt (0 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/operator-equal-equal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/operator-equal-equal-expected.txt	2019-08-16 20:59:29 UTC (rev 248795)
@@ -0,0 +1,5 @@
+
+PASS matrixEqual 
+PASS vectorEquals 
+PASS scalarEquals 
+

Added: trunk/LayoutTests/webgpu/whlsl/operator-equal-equal.html (0 => 248795)


--- trunk/LayoutTests/webgpu/whlsl/operator-equal-equal.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/operator-equal-equal.html	2019-08-16 20:59:29 UTC (rev 248795)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>==.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+const epsilon = 0.0001;
+
+whlslTests.matrixEqual = async () => {
+    const program = `
+        bool foo() {
+            float2x2 m;
+            m[0] = float2(20, 30);
+            m[1] = float2(40, 50);
+            float2x2 m3 = m;
+            m3[0][1] += 10.0;
+
+            bool2x2 m2 = m == m3;
+
+            return m2[0][0] && !m2[0][1] && m2[1][0] && m2[1][1];
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.vectorEquals = async () => {
+    const program = `
+        bool foo() {
+            float2 v = float2(10.0, 20.0);
+            float2 v2 = v;
+
+            bool2 result = v2 == v;
+            return result.x && result.y;
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+whlslTests.scalarEquals = async () => {
+    const program = `
+        bool foo() {
+            float x = 10.0;
+            float y = x;
+            return x == y;
+        }
+    `;
+
+    assert_equals(await callBoolFunction(program,  "foo", []), true);
+};
+
+runTests(whlslTests);
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (248794 => 248795)


--- trunk/Source/WebCore/ChangeLog	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/ChangeLog	2019-08-16 20:59:29 UTC (rev 248795)
@@ -1,3 +1,41 @@
+2019-08-16  Saam Barati  <sbar...@apple.com>
+
+        [WHLSL] Make operator== native and add bool matrices
+        https://bugs.webkit.org/show_bug.cgi?id=200749
+
+        Reviewed by Myles C. Maxfield.
+
+        This patch makes operator== native and implements them the right way
+        for vectors and matrices. Previously, we would just return a single
+        boolean indicating if all elements were equal. However, to be compatible
+        with HLSL, we should return a boolean vector or matrix, indicating which
+        elements are equal or not. This patch makes this change, and in the process,
+        adds a bool matrix.
+
+        This patch also:
+        - Lifts the requirement that all comparison operators in user code must return bool.
+        We no longer follow this in the standard library, and don't want to require user
+        code to do so. It seems reasonable to have a custom comparison operator
+        which returns an enum of the form { LessThan, Equal, GreaterThan, Incomparable }
+        - Changes the native operator inliner to no longer assume that operations on
+        matrices return the same type as the arguments. This was true for math, but
+        is not true for comparison operators.
+
+        Tests: webgpu/whlsl/bool-matrix.html
+               webgpu/whlsl/operator-equal-equal.html
+
+        * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
+        (WebCore::WHLSL::Metal::inlineNativeFunction):
+        * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp:
+        (WebCore::WHLSL::Metal::writeNativeType):
+        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
+        (WebCore::WHLSL::checkOperatorOverload):
+        * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:
+        (WebCore::WHLSL::Intrinsics::addMatrix):
+        * Modules/webgpu/WHLSL/WHLSLIntrinsics.h:
+        (WebCore::WHLSL::Intrinsics::WTF_ARRAY_LENGTH):
+        * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt:
+
 2019-08-16  Zalan Bujtas  <za...@apple.com>
 
         [ContentChangeObserver] Add ContentChangeObserver::elementDidBecomeHidden

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-08-16 20:59:29 UTC (rev 248795)
@@ -375,16 +375,16 @@
 
     if (nativeFunctionDeclaration.isOperator()) {
         auto operatorName = nativeFunctionDeclaration.name().substring("operator"_str.length());
-        auto firstParameterType = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type());
+        auto metalReturnType = typeNamer.mangledNameForType(nativeFunctionDeclaration.type());
         if (nativeFunctionDeclaration.parameters().size() == 1) {
             if (auto* matrixType = asMatrixType(nativeFunctionDeclaration.type())) {
                 stringBuilder.flexibleAppend(
-                    "{\n", firstParameterType, " x = ", args[0], ";\n",
+                    "{\n", metalReturnType, " x = ", args[0], ";\n",
                     "for (size_t i = 0; i < x.size(); ++i) x[i] = ", operatorName, "x[i];\n",
                     returnName, " = x;\n}\n");
             } else {
                 stringBuilder.flexibleAppend(
-                    "{\n", firstParameterType, " x = ", args[0], ";\n", 
+                    "{\n", metalReturnType, " x = ", args[0], ";\n", 
                     returnName, " = ", operatorName, "x;\n}\n");
             }
             return;
@@ -391,18 +391,17 @@
         }
 
         ASSERT(nativeFunctionDeclaration.parameters().size() == 2);
-        auto secondParameterType = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type());
         if (auto* leftMatrix = asMatrixType(*nativeFunctionDeclaration.parameters()[0]->type())) {
             if (auto* rightMatrix = asMatrixType(*nativeFunctionDeclaration.parameters()[1]->type())) {
                 // matrix <op> matrix
                 stringBuilder.flexibleAppend(
-                    "{\n", firstParameterType, " x;\n",
+                    "{\n", metalReturnType, " x;\n",
                     "for (size_t i = 0; i < x.size(); ++i) x[i] = ", args[0], "[i] ", operatorName, ' ', args[1], "[i];\n",
                     returnName, " = x;\n}\n");
             } else {
                 // matrix <op> scalar
                 stringBuilder.flexibleAppend(
-                    "{\n", firstParameterType, " x;\n",
+                    "{\n", metalReturnType, " x;\n",
                     "for (size_t i = 0; i < x.size(); ++i) x[i] = ", args[0], "[i] ", operatorName, ' ', args[1], ";\n",
                     returnName, " = x;\n}\n");
             }
@@ -410,7 +409,7 @@
             ASSERT(!asMatrixType(*nativeFunctionDeclaration.parameters()[0]->type()));
             // scalar <op> matrix
             stringBuilder.flexibleAppend(
-                "{\n", secondParameterType, " x;\n",
+                "{\n", metalReturnType, " x;\n",
                 "for (size_t i = 0; i < x.size(); ++i) x[i] = ", args[0], ' ', operatorName, ' ', args[1], "[i];\n",
                 returnName, " = x;\n}\n");
         } else {

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp	2019-08-16 20:59:29 UTC (rev 248795)
@@ -97,7 +97,9 @@
         auto& namedType = downcast<AST::NamedType>(unifyNode);
         auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType);
         auto prefix = ([&]() -> String {
-            ASSERT_UNUSED(parameterType, parameterType.name() == "float");
+            if (parameterType.name() == "bool")
+                return "bool";
+            ASSERT(parameterType.name() == "float");
             return "float";
         })();
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp	2019-08-16 20:59:29 UTC (rev 248795)
@@ -427,7 +427,7 @@
     return true;
 }
 
-static bool checkOperatorOverload(const AST::FunctionDefinition& functionDefinition, const Intrinsics& intrinsics, NameContext& nameContext)
+static bool checkOperatorOverload(const AST::FunctionDefinition& functionDefinition, NameContext& nameContext)
 {
     enum class CheckKind {
         Index,
@@ -541,14 +541,6 @@
         return functionDefinition.parameters().size() == 2;
     if (functionDefinition.name() == "operator~")
         return functionDefinition.parameters().size() == 1;
-    if (functionDefinition.name() == "operator=="
-        || functionDefinition.name() == "operator<"
-        || functionDefinition.name() == "operator<="
-        || functionDefinition.name() == "operator>"
-        || functionDefinition.name() == "operator>=") {
-        return functionDefinition.parameters().size() == 2
-            && matches(functionDefinition.type(), intrinsics.boolType());
-    }
     if (functionDefinition.name() == "operator[]")
         return checkGetter(CheckKind::Index);
     if (functionDefinition.name() == "operator[]=")
@@ -759,7 +751,7 @@
             return;
         }
     }
-    if (!checkOperatorOverload(functionDefinition, m_intrinsics, m_program.nameContext())) {
+    if (!checkOperatorOverload(functionDefinition, m_program.nameContext())) {
         setError(Error("Operator does not match expected signature.", functionDefinition.codeLocation()));
         return;
     }

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp	2019-08-16 20:59:29 UTC (rev 248795)
@@ -187,22 +187,12 @@
     if (nativeTypeDeclaration.name() != "matrix")
         return false;
 
+    nativeTypeDeclaration.setIsMatrix();
+
     ASSERT(nativeTypeDeclaration.typeArguments().size() == 3);
     ASSERT(WTF::holds_alternative<Ref<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]));
     ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]));
     ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[2]));
-    auto& innerType = static_cast<AST::TypeReference&>(WTF::get<Ref<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0]));
-    auto& rowExpression = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]);
-    auto& columnExpression = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[2]);
-    ASSERT_UNUSED(innerType, !innerType.typeArguments().size());
-    ASSERT_UNUSED(innerType, innerType.name() == "float");
-    auto array = m_matrixFloat;
-    int row = rowExpression.integerLiteral().value();
-    ASSERT(row >= 2 && row <= 4);
-    int column = columnExpression.integerLiteral().value();
-    ASSERT(column >= 2 && column <= 4);
-    nativeTypeDeclaration.setIsMatrix();
-    array[row - 2][column - 2] = &nativeTypeDeclaration;
     return true;
 }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h	2019-08-16 20:59:29 UTC (rev 248795)
@@ -174,8 +174,6 @@
     AST::NativeTypeDeclaration* m_vectorInt[3] { 0 };
     AST::NativeTypeDeclaration* m_vectorFloat[3] { 0 };
 
-    AST::NativeTypeDeclaration* m_matrixFloat[3][3] {{ 0 }};
-
     static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture2D", "RWTexture2D", "Texture3D", "RWTexture3D", "TextureCube", "Texture1DArray", "RWTexture1DArray", "Texture2DArray", "RWTexture2DArray" };
 
     static constexpr const char* m_textureInnerTypeNames[] = { "uint", "int", "float" };

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt (248794 => 248795)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt	2019-08-16 20:56:00 UTC (rev 248794)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt	2019-08-16 20:59:29 UTC (rev 248795)
@@ -55,6 +55,26 @@
 typedef float4x3 = matrix<float, 4, 3>;
 native typedef matrix<float, 4, 4>;
 typedef float4x4 = matrix<float, 4, 4>;
+
+native typedef matrix<bool, 2, 2>;
+typedef bool2x2 = matrix<bool, 2, 2>;
+native typedef matrix<bool, 2, 3>;
+typedef bool2x3 = matrix<bool, 2, 3>;
+native typedef matrix<bool, 2, 4>;
+typedef bool2x4 = matrix<bool, 2, 4>;
+native typedef matrix<bool, 3, 2>;
+typedef bool3x2 = matrix<bool, 3, 2>;
+native typedef matrix<bool, 3, 3>;
+typedef bool3x3 = matrix<bool, 3, 3>;
+native typedef matrix<bool, 3, 4>;
+typedef bool3x4 = matrix<bool, 3, 4>;
+native typedef matrix<bool, 4, 2>;
+typedef bool4x2 = matrix<bool, 4, 2>;
+native typedef matrix<bool, 4, 3>;
+typedef bool4x3 = matrix<bool, 4, 3>;
+native typedef matrix<bool, 4, 4>;
+typedef bool4x4 = matrix<bool, 4, 4>;
+
 native typedef sampler;
 native typedef Texture1D<uint>;
 native typedef Texture1D<uint2>;
@@ -2469,6 +2489,15 @@
 native float4x2 operator[]=(float4x2, uint, float2);
 native float4x3 operator[]=(float4x3, uint, float3);
 native float4x4 operator[]=(float4x4, uint, float4);
+native bool2x2 operator[]=(bool2x2, uint, bool2);
+native bool2x3 operator[]=(bool2x3, uint, bool3);
+native bool2x4 operator[]=(bool2x4, uint, bool4);
+native bool3x2 operator[]=(bool3x2, uint, bool2);
+native bool3x3 operator[]=(bool3x3, uint, bool3);
+native bool3x4 operator[]=(bool3x4, uint, bool4);
+native bool4x2 operator[]=(bool4x2, uint, bool2);
+native bool4x3 operator[]=(bool4x3, uint, bool3);
+native bool4x4 operator[]=(bool4x4, uint, bool4);
 
 
 /* Functions named operator.yxyx */
@@ -11019,6 +11048,15 @@
 native float2 operator[](float4x2, uint);
 native float3 operator[](float4x3, uint);
 native float4 operator[](float4x4, uint);
+native bool2 operator[](bool2x2, uint);
+native bool3 operator[](bool2x3, uint);
+native bool4 operator[](bool2x4, uint);
+native bool2 operator[](bool3x2, uint);
+native bool3 operator[](bool3x3, uint);
+native bool4 operator[](bool3x4, uint);
+native bool2 operator[](bool4x2, uint);
+native bool3 operator[](bool4x3, uint);
+native bool4 operator[](bool4x4, uint);
 
 /* Functions named operator.yywz */
 bool4 operator.yywz(bool4 v) {
@@ -12183,6 +12221,123 @@
     result = result && (x[3][3] != 0);
     return result;
 }
+bool all(bool2x2 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    return result;
+}
+bool all(bool2x3 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    return result;
+}
+bool all(bool2x4 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[0][3];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    result = result && x[1][3];
+    return result;
+}
+bool all(bool3x2 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    return result;
+}
+bool all(bool3x3 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    result = result && x[2][2];
+    return result;
+}
+bool all(bool3x4 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[0][3];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    result = result && x[1][3];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    result = result && x[2][2];
+    result = result && x[2][3];
+    return result;
+}
+bool all(bool4x2 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    result = result && x[3][0];
+    result = result && x[3][1];
+    return result;
+}
+bool all(bool4x3 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    result = result && x[2][2];
+    result = result && x[3][0];
+    result = result && x[3][1];
+    result = result && x[3][2];
+    return result;
+}
+bool all(bool4x4 x) {
+    bool result = true;
+    result = result && x[0][0];
+    result = result && x[0][1];
+    result = result && x[0][2];
+    result = result && x[0][3];
+    result = result && x[1][0];
+    result = result && x[1][1];
+    result = result && x[1][2];
+    result = result && x[1][3];
+    result = result && x[2][0];
+    result = result && x[2][1];
+    result = result && x[2][2];
+    result = result && x[2][3];
+    result = result && x[3][0];
+    result = result && x[3][1];
+    result = result && x[3][2];
+    result = result && x[3][3];
+    return result;
+}
 
 
 /* Functions named operator.w= */
@@ -12304,8 +12459,97 @@
     result[3] = firstbitlow(x[3]);
     return result;
 }
+operator bool2x2(bool2 a, bool2 b) {
+    bool2x2 result;
+    result[0] = a;
+    result[1] = b;
+    return result;
+}
+operator bool2x3(bool3 a, bool3 b) {
+    bool2x3 result;
+    result[0] = a;
+    result[1] = b;
+    return result;
+}
+operator bool2x4(bool4 a, bool4 b) {
+    bool2x4 result;
+    result[0] = a;
+    result[1] = b;
+    return result;
+}
+operator bool3x2(bool2 a, bool2 b, bool2 c) {
+    bool3x2 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    return result;
+}
+operator bool3x3(bool3 a, bool3 b, bool3 c) {
+    bool3x3 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    return result;
+}
+operator bool3x4(bool4 a, bool4 b, bool4 c) {
+    bool3x4 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    return result;
+}
+operator bool4x2(bool2 a, bool2 b, bool2 c, bool2 d) {
+    bool4x2 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    result[3] = d;
+    return result;
+}
+operator bool4x3(bool3 a, bool3 b, bool3 c, bool3 d) {
+    bool4x3 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    result[3] = d;
+    return result;
+}
+operator bool4x4(bool4 a, bool4 b, bool4 c, bool4 d) {
+    bool4x4 result;
+    result[0] = a;
+    result[1] = b;
+    result[2] = c;
+    result[3] = d;
+    return result;
+}
+operator bool2x2(bool a, bool b, bool e, bool f) {
+    return bool2x2(bool2(a, b), bool2(e, f));
+}
+operator bool2x3(bool a, bool b, bool c, bool e, bool f, bool g) {
+    return bool2x3(bool3(a, b, c), bool3(e, f, g));
+}
+operator bool2x4(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h) {
+    return bool2x4(bool4(a, b, c, d), bool4(e, f, g, h));
+}
+operator bool3x2(bool a, bool b, bool e, bool f, bool i, bool j) {
+    return bool3x2(bool2(a, b), bool2(e, f), bool2(i, j));
+}
+operator bool3x3(bool a, bool b, bool c, bool e, bool f, bool g, bool i, bool j, bool k) {
+    return bool3x3(bool3(a, b, c), bool3(e, f, g), bool3(i, j, k));
+}
+operator bool3x4(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h, bool i, bool j, bool k, bool l) {
+    return bool3x4(bool4(a, b, c, d), bool4(e, f, g, h), bool4(i, j, k, l));
+}
+operator bool4x2(bool a, bool b, bool e, bool f, bool i, bool j, bool m, bool n) {
+    return bool4x2(bool2(a, b), bool2(e, f), bool2(i, j), bool2(m, n));
+}
+operator bool4x3(bool a, bool b, bool c, bool e, bool f, bool g, bool i, bool j, bool k, bool m, bool n, bool o) {
+    return bool4x3(bool3(a, b, c), bool3(e, f, g), bool3(i, j, k), bool3(m, n, o));
+}
+operator bool4x4(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h, bool i, bool j, bool k, bool l, bool m, bool n, bool o, bool p) {
+    return bool4x4(bool4(a, b, c, d), bool4(e, f, g, h), bool4(i, j, k, l), bool4(m, n, o, p));
+}
 
-
 /* Functions named operator.xwxy */
 bool4 operator.xwxy(bool4 v) {
     bool4 result;
@@ -16195,159 +16439,36 @@
 native bool operator==(int, int);
 native bool operator==(uint, uint);
 native bool operator==(float, float);
-bool operator==(bool2 a, bool2 b) {
-    return a.x == b.x && a.y == b.y;
-}
-bool operator==(bool3 a, bool3 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z;
-}
-bool operator==(bool4 a, bool4 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
-}
-bool operator==(uint2 a, uint2 b) {
-    return a.x == b.x && a.y == b.y;
-}
-bool operator==(uint3 a, uint3 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z;
-}
-bool operator==(uint4 a, uint4 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
-}
-bool operator==(int2 a, int2 b) {
-    return a.x == b.x && a.y == b.y;
-}
-bool operator==(int3 a, int3 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z;
-}
-bool operator==(int4 a, int4 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
-}
-bool operator==(float2 a, float2 b) {
-    return a.x == b.x && a.y == b.y;
-}
-bool operator==(float3 a, float3 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z;
-}
-bool operator==(float4 a, float4 b) {
-    return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
-}
-bool operator==(float2x2 a, float2x2 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-    true;
-}
-bool operator==(float2x3 a, float2x3 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-    true;
-}
-bool operator==(float2x4 a, float2x4 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[0][3] == b[0][3] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-        a[1][3] == b[1][3] &&
-    true;
-}
-bool operator==(float3x2 a, float3x2 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-    true;
-}
-bool operator==(float3x3 a, float3x3 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-        a[2][2] == b[2][2] &&
-    true;
-}
-bool operator==(float3x4 a, float3x4 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[0][3] == b[0][3] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-        a[1][3] == b[1][3] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-        a[2][2] == b[2][2] &&
-        a[2][3] == b[2][3] &&
-    true;
-}
-bool operator==(float4x2 a, float4x2 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-        a[3][0] == b[3][0] &&
-        a[3][1] == b[3][1] &&
-    true;
-}
-bool operator==(float4x3 a, float4x3 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-        a[2][2] == b[2][2] &&
-        a[3][0] == b[3][0] &&
-        a[3][1] == b[3][1] &&
-        a[3][2] == b[3][2] &&
-    true;
-}
-bool operator==(float4x4 a, float4x4 b) {
-    return
-        a[0][0] == b[0][0] &&
-        a[0][1] == b[0][1] &&
-        a[0][2] == b[0][2] &&
-        a[0][3] == b[0][3] &&
-        a[1][0] == b[1][0] &&
-        a[1][1] == b[1][1] &&
-        a[1][2] == b[1][2] &&
-        a[1][3] == b[1][3] &&
-        a[2][0] == b[2][0] &&
-        a[2][1] == b[2][1] &&
-        a[2][2] == b[2][2] &&
-        a[2][3] == b[2][3] &&
-        a[3][0] == b[3][0] &&
-        a[3][1] == b[3][1] &&
-        a[3][2] == b[3][2] &&
-        a[3][3] == b[3][3] &&
-    true;
-}
+native bool2 operator==(bool2, bool2);
+native bool3 operator==(bool3, bool3);
+native bool4 operator==(bool4, bool4);
+native bool2 operator==(uint2, uint2);
+native bool3 operator==(uint3, uint3);
+native bool4 operator==(uint4, uint4);
+native bool2 operator==(int2, int2);
+native bool3 operator==(int3, int3);
+native bool4 operator==(int4, int4);
+native bool2 operator==(float2, float2);
+native bool3 operator==(float3, float3);
+native bool4 operator==(float4, float4);
+native bool2x2 operator==(float2x2, float2x2);
+native bool2x3 operator==(float2x3, float2x3);
+native bool2x4 operator==(float2x4, float2x4);
+native bool3x2 operator==(float3x2, float3x2);
+native bool3x3 operator==(float3x3, float3x3);
+native bool3x4 operator==(float3x4, float3x4);
+native bool4x2 operator==(float4x2, float4x2);
+native bool4x3 operator==(float4x3, float4x3);
+native bool4x4 operator==(float4x4, float4x4);
+native bool2x2 operator==(bool2x2, bool2x2);
+native bool2x3 operator==(bool2x3, bool2x3);
+native bool2x4 operator==(bool2x4, bool2x4);
+native bool3x2 operator==(bool3x2, bool3x2);
+native bool3x3 operator==(bool3x3, bool3x3);
+native bool3x4 operator==(bool3x4, bool3x4);
+native bool4x2 operator==(bool4x2, bool4x2);
+native bool4x3 operator==(bool4x3, bool4x3);
+native bool4x4 operator==(bool4x4, bool4x4);
 
 /* Functions named operator>> */
 native int operator>>(int, uint);
@@ -34561,8 +34682,124 @@
     result = result || (x[3][3] != 0);
     return result;
 }
+bool any(bool2x2 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    return result;
+}
+bool any(bool2x3 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    return result;
+}
+bool any(bool2x4 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[0][3];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    result = result || x[1][3];
+    return result;
+}
+bool any(bool3x2 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    return result;
+}
+bool any(bool3x3 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    result = result || x[2][2];
+    return result;
+}
+bool any(bool3x4 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[0][3];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    result = result || x[1][3];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    result = result || x[2][2];
+    result = result || x[2][3];
+    return result;
+}
+bool any(bool4x2 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    result = result || x[3][0];
+    result = result || x[3][1];
+    return result;
+}
+bool any(bool4x3 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    result = result || x[2][2];
+    result = result || x[3][0];
+    result = result || x[3][1];
+    result = result || x[3][2];
+    return result;
+}
+bool any(bool4x4 x) {
+    bool result = false;
+    result = result || x[0][0];
+    result = result || x[0][1];
+    result = result || x[0][2];
+    result = result || x[0][3];
+    result = result || x[1][0];
+    result = result || x[1][1];
+    result = result || x[1][2];
+    result = result || x[1][3];
+    result = result || x[2][0];
+    result = result || x[2][1];
+    result = result || x[2][2];
+    result = result || x[2][3];
+    result = result || x[3][0];
+    result = result || x[3][1];
+    result = result || x[3][2];
+    result = result || x[3][3];
+    return result;
+}
 
-
 /* Functions named operator.yxww */
 bool4 operator.yxww(bool4 v) {
     bool4 result;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to