WebKit Bugzilla
Attachment 347895 Details for
Bug 188873
: [WHLSL] Add more functions to the standard library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-188873-20180822194555.patch (text/plain), 217.90 KB, created by
Myles C. Maxfield
on 2018-08-22 19:45:56 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-08-22 19:45:56 PDT
Size:
217.90 KB
patch
obsolete
>Subversion Revision: 235183 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index b2294c8a931da62400dcff9282b105acd627a750..35b30f41b121289d01977c648fe82c2a416910dc 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,158 @@ >+2018-08-22 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Add more functions to the standard library >+ https://bugs.webkit.org/show_bug.cgi?id=188873 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebGPUShadingLanguageRI/All.js: >+ * WebGPUShadingLanguageRI/BuiltinVectorConstructors.js: >+ (BuiltinVectorConstructors): >+ * WebGPUShadingLanguageRI/CallExpression.js: >+ (CallExpression.prototype.resolve): >+ * WebGPUShadingLanguageRI/CheckTypesWithArguments.js: Copied from Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js. >+ (checkTypesWithArguments.TypeWithArgumentsChecker.prototype.visitTypeRef): >+ (checkTypesWithArguments.TypeWithArgumentsChecker): >+ (checkTypesWithArguments): >+ * WebGPUShadingLanguageRI/Checker.js: >+ (Checker.prototype.visitProgram): >+ (Checker.prototype.visitTypeRef): >+ (Checker.prototype.visitVectorType): >+ (Checker.prototype.visitMatrixType): >+ * WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js: >+ (FlattenedStructOffsetGatherer.prototype.visitMatrixType): >+ (FlattenedStructOffsetGatherer): >+ * WebGPUShadingLanguageRI/InferTypesForCall.js: >+ (inferTypesForCall): >+ (inferTypesForTypeArguments): >+ * WebGPUShadingLanguageRI/Intrinsics.js: >+ (Intrinsics.cast): >+ (Intrinsics.bitwiseCast): >+ (Intrinsics.castToHalf): >+ (Intrinsics.): >+ (Intrinsics): >+ * WebGPUShadingLanguageRI/MatrixType.js: Renamed from Tools/WebGPUShadingLanguageRI/OperatorBool.js. >+ (MatrixType): >+ (MatrixType.prototype.get elementType): >+ (MatrixType.prototype.get numRows): >+ (MatrixType.prototype.get numColumns): >+ (MatrixType.prototype.get numRowsValue): >+ (MatrixType.prototype.get numColumnsValue): >+ (MatrixType.prototype.get size): >+ (MatrixType.prototype.unifyImpl): >+ (MatrixType.prototype.populateDefaultValue): >+ (MatrixType.prototype.toString): >+ * WebGPUShadingLanguageRI/NameContext.js: >+ (NameContext.prototype.add): >+ (NameContext.prototype.get let): >+ (NameContext.underlyingThings.prototype.else): >+ (NameContext.prototype.Symbol.iterator): >+ (NameContext): >+ * WebGPUShadingLanguageRI/NameResolver.js: >+ (NameResolver.prototype.visitTypeRef): >+ (NameResolver.prototype.visitCallExpression): >+ (NameResolver): >+ (NameResolver.prototype.visitVectorType): Deleted. >+ * WebGPUShadingLanguageRI/NativeType.js: >+ (NativeType): >+ (NativeType.prototype.get typeArguments): >+ (NativeType.prototype.toString): >+ (NativeType.create): >+ * WebGPUShadingLanguageRI/OperatorAnderIndexer.js: Renamed from Tools/WebGPUShadingLanguageRI/OperatorAnderIndex.js. >+ (OperatorAnderIndexer.functions): >+ (OperatorAnderIndexer): >+ * WebGPUShadingLanguageRI/Prepare.js: >+ (let.prepare): >+ * WebGPUShadingLanguageRI/Program.js: >+ (Program.prototype.add): >+ (Program.prototype.toString): >+ (Program): >+ * WebGPUShadingLanguageRI/RemoveTypeArguments.js: Removed. >+ * WebGPUShadingLanguageRI/ResolveNames.js: >+ (resolveNamesInTypes): >+ * WebGPUShadingLanguageRI/ResolveOverloadImpl.js: >+ * WebGPUShadingLanguageRI/ResolveTypeDefs.js: >+ (resolveTypeDefsInTypes): >+ * WebGPUShadingLanguageRI/Rewriter.js: >+ (Rewriter.prototype.visitTypeRef): >+ (Rewriter.prototype.visitVectorType): >+ (Rewriter.prototype.visitMatrixType): >+ (Rewriter): >+ * WebGPUShadingLanguageRI/SPIRV.html: >+ * WebGPUShadingLanguageRI/StandardLibrary.js: >+ (operator.bool): >+ (bool.operator): >+ (uchar.operator): >+ (ushort.operator): >+ (char.operator): >+ (short.operator): >+ (uint.operator): >+ (int.operator): >+ (half.operator): >+ (float.operator): >+ (uchar2.operator): >+ (uchar3.operator): >+ (uchar4.operator): >+ (ushort2.operator): >+ (ushort3.operator): >+ (ushort4.operator): >+ (uint2.operator): >+ (uint3.operator): >+ (uint4.operator): >+ (char2.operator): >+ (char3.operator): >+ (char4.operator): >+ (short2.operator): >+ (short3.operator): >+ (short4.operator): >+ (int2.operator): >+ (int3.operator): >+ (int4.operator): >+ (half2.operator): >+ (half3.operator): >+ (half4.operator): >+ (float2.operator): >+ (float3.operator): >+ (float4.operator): >+ (half2x2.operator): >+ * WebGPUShadingLanguageRI/StatementCloner.js: >+ (StatementCloner.prototype.visitNativeType): >+ * WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js: >+ (synthesizeDefaultConstructorOperator.FindAllTypes.prototype.visitVectorType): >+ (synthesizeDefaultConstructorOperator.FindAllTypes.prototype.visitMatrixType): >+ (synthesizeDefaultConstructorOperator.FindAllTypes): >+ (synthesizeDefaultConstructorOperator): >+ * WebGPUShadingLanguageRI/SynthesizeStructAccessors.js: >+ (synthesizeStructAccessors.createTypeRef): >+ * WebGPUShadingLanguageRI/Test.html: >+ * WebGPUShadingLanguageRI/Test.js: >+ * WebGPUShadingLanguageRI/TypeOverloadResolutionFailure.js: Renamed from Tools/WebGPUShadingLanguageRI/SynthesizeOperatorBool.js. >+ (TypeOverloadResolutionFailure): >+ (TypeOverloadResolutionFailure.prototype.get type): >+ (TypeOverloadResolutionFailure.prototype.get reason): >+ (TypeOverloadResolutionFailure.prototype.toString): >+ * WebGPUShadingLanguageRI/TypeRef.js: >+ (TypeRef.wrap): >+ (TypeRef.prototype.resolve): >+ (TypeRef.prototype.toString): >+ (TypeRef): >+ (TypeRef.instantiate): Deleted. >+ * WebGPUShadingLanguageRI/UnificationContext.js: >+ (UnificationContext.prototype.verify): >+ * WebGPUShadingLanguageRI/VectorType.js: >+ (VectorType): >+ (VectorType.prototype.get elementType): >+ (VectorType.prototype.get numElements): >+ (VectorType.prototype.get numElementsValue): >+ (VectorType.prototype.toString): >+ * WebGPUShadingLanguageRI/Visitor.js: >+ (Visitor.prototype.visitTypeRef): >+ (Visitor.prototype.visitNativeType): >+ (Visitor.prototype.visitVectorType): >+ (Visitor.prototype.visitMatrixType): >+ (Visitor): >+ * WebGPUShadingLanguageRI/index.html: >+ > 2018-08-21 Alex Christensen <achristensen@webkit.org> > > Roll out r235139 and r235146 >diff --git a/Tools/WebGPUShadingLanguageRI/All.js b/Tools/WebGPUShadingLanguageRI/All.js >index 81525273ae65a14865964a13da45ce94ef10684a..ac94671f06dc106656fbf6fa24b0df7c03117563 100644 >--- a/Tools/WebGPUShadingLanguageRI/All.js >+++ b/Tools/WebGPUShadingLanguageRI/All.js >@@ -49,8 +49,6 @@ load("Break.js"); > load("BuiltinVectorConstructors.js"); > load("BuiltinVectorGetter.js"); > load("BuiltinVectorSetter.js"); >-load("BuiltinVectorIndexGetter.js"); >-load("BuiltinVectorIndexSetter.js"); > load("BuiltinVectorEqualityOperator.js"); > load("CallExpression.js"); > load("CallFunction.js"); >@@ -60,6 +58,7 @@ load("CheckLoops.js"); > load("CheckRecursion.js"); > load("CheckRecursiveTypes.js"); > load("CheckReturns.js"); >+load("CheckTypesWithArguments.js"); > load("CheckUnreachableCode.js"); > load("CheckWrapped.js"); > load("Checker.js"); >@@ -112,6 +111,7 @@ load("LogicalNot.js"); > load("LoopChecker.js"); > load("MakeArrayRefExpression.js"); > load("MakePtrExpression.js"); >+load("MatrixType.js"); > load("NameContext.js"); > load("NameFinder.js"); > load("NameResolver.js"); >@@ -119,9 +119,8 @@ load("NativeFunc.js"); > load("NormalUsePropertyResolver.js"); > load("NullLiteral.js"); > load("NullType.js"); >-load("OperatorAnderIndex.js"); >+load("OperatorAnderIndexer.js"); > load("OperatorArrayRefLength.js"); >-load("OperatorBool.js"); > load("OriginKind.js"); > load("OverloadResolutionFailure.js"); > load("Parse.js"); >@@ -133,7 +132,6 @@ load("PtrType.js"); > load("ReadModifyWriteExpression.js"); > load("RecursionChecker.js"); > load("RecursiveTypeChecker.js"); >-load("RemoveTypeArguments.js"); > load("ResolveNames.js"); > load("ResolveOverloadImpl.js"); > load("ResolveProperties.js"); >@@ -150,13 +148,13 @@ load("SwitchStatement.js"); > load("SynthesizeArrayOperatorLength.js"); > load("SynthesizeEnumFunctions.js"); > load("SynthesizeStructAccessors.js"); >-load("SynthesizeOperatorBool.js"); > load("SynthesizeCopyConstructorOperator.js"); > load("SynthesizeDefaultConstructorOperator.js"); > load("TrapStatement.js"); > load("TypeDef.js"); > load("TypeDefResolver.js"); > load("TypeRef.js"); >+load("TypeOverloadResolutionFailure.js"); > load("TypedValue.js"); > load("UintLiteral.js"); > load("UintLiteralType.js"); >@@ -170,4 +168,4 @@ load("WSyntaxError.js"); > load("WTrapError.js"); > load("WTypeError.js"); > load("WhileLoop.js"); >-load("WrapChecker.js"); >\ No newline at end of file >+load("WrapChecker.js"); >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js >index 2704b43a06c2faed9dfa73dead33bb0c5c955985..748df0c94c32d07bbc00a5e75ca9a77e3667a8e1 100644 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js >@@ -81,4 +81,4 @@ class BuiltinVectorConstructors { > }; > func.implementationData = this; > } >-} >\ No newline at end of file >+} >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >index c253f7630ee9dc47cd1e1945bc87f42eaa3ccb28..e04c3cd687865c7e19154160fa4a3d2020378b2a 100644 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >@@ -43,23 +43,6 @@ class BuiltinVectorGetter { > return `native ${this.baseTypeName} operator.${this.elementName}(${this.baseTypeName}${this.size})`; > } > >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- const elements = [ "x", "y", "z", "w" ]; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) { >- for (let i = 0; i < size; i++) >- this._functions.push(new BuiltinVectorGetter(typeName, size, elements[i], i)); >- } >- } >- } >- return this._functions; >- } >- > instantiateImplementation(func) > { > func.implementation = ([vec], node) => { >@@ -67,4 +50,4 @@ class BuiltinVectorGetter { > }; > func.implementationData = this; > } >-} >\ No newline at end of file >+} >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexGetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexGetter.js >deleted file mode 100644 >index f7262fc9ce2730f087d61455876b335fe024ac3a..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexGetter.js >+++ /dev/null >@@ -1,66 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-class BuiltinVectorIndexGetter { >- constructor(baseTypeName, size) >- { >- this._baseTypeName = baseTypeName; >- this._size = size; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- get size() { return this._size; } >- >- toString() >- { >- return `native ${this.baseTypeName} operator[](${this.baseTypeName}${this.size},uint)`; >- } >- >- static functions() >- { >- if (!this._allIndexGetters) { >- this._allIndexGetters = []; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) >- this._allIndexGetters.push(new BuiltinVectorIndexGetter(typeName, size)); >- } >- } >- return this._allIndexGetters; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([vec, index], node) => { >- const indexValue = index.loadValue(); >- if (indexValue >= 0 && indexValue < this.size) >- return EPtr.box(vec.get(index.loadValue())); >- else >- throw new Error(`${indexValue} out of bounds for vector of size ${this.size}`); >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexSetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexSetter.js >deleted file mode 100644 >index 2fe5d678ab705fe40b7d68e9693dd8afc4adee94..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexSetter.js >+++ /dev/null >@@ -1,71 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-class BuiltinVectorIndexSetter { >- constructor(baseTypeName, size) >- { >- this._baseTypeName = baseTypeName; >- this._size = size; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- get size() { return this._size; } >- get elementName() { return this._elementName; } >- get index() { return this._index; } >- >- toString() >- { >- return `native ${this.baseTypeName}${this.size} operator[]=(${this.baseTypeName}${this.size},uint,${this.baseTypeName})`; >- } >- >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) >- this._functions.push(new BuiltinVectorIndexSetter(typeName, size)); >- } >- } >- return this._functions; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([base, index, value], node) => { >- const indexValue = index.loadValue(); >- if (indexValue >= 0 && indexValue < this.size) { >- let result = new EPtr(new EBuffer(this.size), 0); >- result.copyFrom(base, this.size); >- result.plus(indexValue).copyFrom(value, 1); >- return result; >- } else >- throw new Error(`${indexValue} out of bounds for vector of size ${this.size}`); >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js >index a2d763b7509997b2410c24b801314c34a3c487a0..6577866d60e7284d00a220a52638359f6a9a884e 100644 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js >@@ -43,23 +43,6 @@ class BuiltinVectorSetter { > return `native ${this.baseTypeName}${this.size} operator.${this.elementName}=(${this.baseTypeName}${this.size},${this.baseTypeName})`; > } > >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- const elements = [ "x", "y", "z", "w" ]; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) { >- for (let i = 0; i < size; i++) >- this._functions.push(new BuiltinVectorSetter(typeName, size, elements[i], i)); >- } >- } >- } >- return this._functions; >- } >- > instantiateImplementation(func) > { > func.implementation = ([base, value], node) => { >@@ -70,4 +53,4 @@ class BuiltinVectorSetter { > }; > func.implementationData = this; > } >-} >\ No newline at end of file >+} >diff --git a/Tools/WebGPUShadingLanguageRI/CallExpression.js b/Tools/WebGPUShadingLanguageRI/CallExpression.js >index b25398f0b1b6eade1b79ac90e6a762525f819bd7..3b15455992e64e2677ba0b03ab6568ef43d5d865 100644 >--- a/Tools/WebGPUShadingLanguageRI/CallExpression.js >+++ b/Tools/WebGPUShadingLanguageRI/CallExpression.js >@@ -64,7 +64,6 @@ class CallExpression extends Expression { > overload.func = func; > } > >- > if (!overload.func) { > failures.push(...overload.failures); > let message = "Did not find function named " + this.name + " for call with "; >diff --git a/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js b/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js >new file mode 100644 >index 0000000000000000000000000000000000000000..2f69142a3517d294900530c0cf066c9bfd2277af >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+"use strict"; >+ >+function checkTypesWithArguments(program) >+{ >+ class TypeWithArgumentsChecker extends Visitor { >+ visitTypeRef(node) >+ { >+ if ((node.name == "vector" && node.typeArguments.length != 2) >+ || (node.name == "matrix" && node.typeArguments.length != 3) >+ || (node.name == "Texture1D" && node.typeArguments.length != 1) >+ || (node.name == "RWTexture1D" && node.typeArguments.length != 1) >+ || (node.name == "Texture1DArray" && node.typeArguments.length != 1) >+ || (node.name == "RWTexture1DArray" && node.typeArguments.length != 1) >+ || (node.name == "Texture2D" && node.typeArguments.length != 1) >+ || (node.name == "RWTexture2D" && node.typeArguments.length != 1) >+ || (node.name == "Texture2DArray" && node.typeArguments.length != 1) >+ || (node.name == "RWTexture2DArray" && node.typeArguments.length != 1) >+ || (node.name == "Texture3D" && node.typeArguments.length != 1) >+ || (node.name == "RWTexture3D" && node.typeArguments.length != 1) >+ || (node.name == "TextureCube" && node.typeArguments.length != 1)) >+ throw new Error(`Builtin type ${node.name} should always have type arguments.`); >+ } >+ } >+ program.visit(new TypeWithArgumentsChecker()); >+} >+ >diff --git a/Tools/WebGPUShadingLanguageRI/Checker.js b/Tools/WebGPUShadingLanguageRI/Checker.js >index 1a14c866aced4112b180f69156c06d2b664d87e2..00188d70ebb1a6bc3450f46362d1f96ae387cba2 100644 >--- a/Tools/WebGPUShadingLanguageRI/Checker.js >+++ b/Tools/WebGPUShadingLanguageRI/Checker.js >@@ -41,8 +41,13 @@ class Checker extends Visitor { > statement.visit(this); > } > >- for (let type of node.types.values()) >- doStatement(type); >+ for (let type of node.types.values()) { >+ if (type instanceof Array) { >+ for (let constituentType of type) >+ doStatement(constituentType); >+ } else >+ doStatement(type); >+ } > for (let funcs of node.functions.values()) { > for (let func of funcs) { > this.visitFunc(func); >@@ -247,6 +252,10 @@ class Checker extends Visitor { > { > if (!node.type) > throw new Error("Type reference without a type in checker: " + node + " at " + node.origin); >+ // All the structs will be visited by visitProgram() iterating through each top-level type. >+ // We don't want to recurse here because the contents of structs can refer to themselves (e.g. a linked list), >+ // and this would can an infinite loop. >+ // Typedefs can't refer to themselves because we check that in TypeDefResolver. > if (!(node.type instanceof StructType)) > node.type.visit(this); > } >@@ -254,6 +263,7 @@ class Checker extends Visitor { > visitVectorType(node) > { > node.elementType.visit(this); >+ node.numElements.visit(this); > > let isKnownAllowedVectorElementType = false; > for (let vectorElementTypeName of VectorElementTypes) { >@@ -268,6 +278,33 @@ class Checker extends Visitor { > > if (!isKnownAllowedVectorElementType) > throw new WTypeError(`${node.elementType} is not a permitted vector element type.`); >+ if (node.numElementsValue != 2 && node.numElementsValue != 3 && node.numElementsValue != 4) >+ throw new WTypeError(`${node.toString()}: ${node.numElementsValue} is not 2, 3, or 4.`); >+ } >+ >+ visitMatrixType(node) >+ { >+ node.elementType.visit(this); >+ node.numRows.visit(this); >+ node.numColumns.visit(this); >+ >+ let isKnownAllowedVectorElementType = false; >+ for (let elementTypeName of ["half", "float"]) { >+ const elementType = this._program.globalNameContext.get(Type, elementTypeName); >+ if (!elementType) >+ throw new WTypeError(`${elementTypeName} is not a known native type in the standard library or intrinsics.`); >+ if (elementType.equals(node.elementType)) { >+ isKnownAllowedVectorElementType = true; >+ break; >+ } >+ } >+ >+ if (!isKnownAllowedVectorElementType) >+ throw new WTypeError(`${node.elementType} is not a permitted vector element type.`); >+ if (node.numRowsValue != 2 && node.numRowsValue != 3 && node.numRowsValue != 4) >+ throw new WTypeError(`${node.toString()}: ${node.numRowsValue} is not 2, 3, or 4.`); >+ if (node.numColumnsValue != 2 && node.numColumnsValue != 3 && node.numColumnsValue != 4) >+ throw new WTypeError(`${node.toString()}: ${node.numColumnsValue} is not 2, 3, or 4.`); > } > > visitArrayType(node) >diff --git a/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js b/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >index 1970f8ed932cd3530a48dc31af8c9c4240dde8d0..e0e161ff10ccd3c0992b9a92649f4e3a00ba1117 100644 >--- a/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >+++ b/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >@@ -74,5 +74,17 @@ class FlattenedStructOffsetGatherer extends Visitor { > }); > } > } >+ >+ visitMatrixType(node) >+ { >+ const fieldNames = [ "row0", "row1", "row2", "row3" ]; >+ for (let i = 0; i < node.numRowsValue; i++) { >+ this._result.push({ >+ name: this._name.join(".") + "." + fieldNames[i], >+ offset: this._offset + i * node.elementType.size * node.numColumnsValue, >+ type: node.elementType.name + node.numColumnsValue.toString() >+ }); >+ } >+ } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js b/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >index 5f32ed1c490a7df8941e919c130cf65eaa8b6a4d..bcfeb986caff49f0287a83678bf11562847f0389 100644 >--- a/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >+++ b/Tools/WebGPUShadingLanguageRI/InferTypesForCall.js >@@ -36,12 +36,8 @@ function inferTypesForCall(func, argumentTypes, returnType) > if (!argumentTypes[i].unify(unificationContext, func.parameters[i].type)) > return {failure: new OverloadResolutionFailure(func, "Argument #" + (i + 1) + " " + (func.parameters[i].name ? "for parameter " + func.parameters[i].name + " " : "") + "does not match (passed " + argumentTypes[i] + ", require " + func.parameters[i].type + ")")}; > } >- if (returnType && !returnType.unify(unificationContext, func.returnType)) { >- if (func.returnType.toString() == "vector") { >- returnType.unify(unificationContext, func.returnType) >- } >+ if (returnType && !returnType.unify(unificationContext, func.returnType)) > return {failure: new OverloadResolutionFailure(func, "Return type " + func.returnType + " does not match " + returnType)}; >- } > let verificationResult = unificationContext.verify(); > if (!verificationResult.result) > return {failure: new OverloadResolutionFailure(func, verificationResult.reason)}; >@@ -49,3 +45,21 @@ function inferTypesForCall(func, argumentTypes, returnType) > return {func, unificationContext}; > } > >+function inferTypesForTypeArguments(type, typeArguments) >+{ >+ if (typeArguments.length != type.typeArguments.length) >+ return {failure: new TypeOverloadResolutionFailure(type, "Wrong number of arguments (passed " + typeArguments.length + ", require " + type.typeArguments.length + ")")}; >+ let unificationContext = new UnificationContext(); >+ >+ for (let i = 0; i < typeArguments.length; ++i) { >+ if (!typeArguments[i]) >+ throw new Error("Null type argument at i = " + i); >+ if (!typeArguments[i].unify(unificationContext, type.typeArguments[i])) >+ return {failure: new TypeOverloadResolutionFailure(type, "Argument #" + (i + 1) + " " + (type.typeArguments[i].name ? "for parameter " + type.typeArguments[i].name + " " : "") + "does not match (passed " + typeArguments[i] + ", require " + type.typeArguments[i].type + ")")}; >+ } >+ let verificationResult = unificationContext.verify(); >+ if (!verificationResult.result) >+ return {failure: new TypeOverloadResolutionFailure(type, verificationResult.reason)}; >+ >+ return {type, unificationContext}; >+} >diff --git a/Tools/WebGPUShadingLanguageRI/Intrinsics.js b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >index 50d40c0c0e47e112bc74ccfccb7049427116b0fb..4be0b203c505aa3670f58fc6c1cf439eb373586d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Intrinsics.js >+++ b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >@@ -33,15 +33,7 @@ class Intrinsics { > // to catch the intrinsics must be based on the type names that StandardLibrary.js uses. > // For example, if a native function is declared using "int" rather than "int", then we must > // use "int" here, since we don't yet know that they are the same type. >- >- this._map.set( >- "native typedef void", >- type => { >- this.void = type; >- type.size = 0; >- type.populateDefaultValue = () => { }; >- }); >- >+ > function isBitwiseEquivalent(left, right) > { > let doubleArray = new Float64Array(1); >@@ -56,58 +48,83 @@ class Intrinsics { > return true; > } > >+ function cast(typedArrayConstructor, number) >+ { >+ var array = new typedArrayConstructor(1); >+ array[0] = number; >+ return array[0]; >+ } >+ >+ function bitwiseCast(typedArrayConstructor1, typedArrayConstructor2, value) >+ { >+ let typedArray1 = new typedArrayConstructor1(1); >+ let typedArray2 = new typedArrayConstructor2(typedArray1.buffer); >+ typedArray1[0] = value; >+ return typedArray2[0]; >+ } >+ >+ function castToHalf(number) >+ { >+ // FIXME: Make this math obey IEEE 754. >+ if (Number.isNaN(number)) >+ return number >+ if (number > 65504) >+ return Number.POSITIVE_INFINITY; >+ if (number < -65504) >+ return Number.NEGATIVE_INFINITY; >+ if (number > 0 && number < Math.pow(2, -24)) >+ return 0; >+ if (number < 0 && number > -Math.pow(2, -24)) >+ return -0; >+ let doubleArray = new Float64Array(1); >+ let uintArray = new Uint8Array(doubleArray.buffer); >+ doubleArray[0] = number; >+ let sign = uintArray[7] & 0x80; >+ let exponent = ((uintArray[7] & 0x7f) << 4) | ((uintArray[6] & 0xf0) >>> 4); >+ let significand = ((uintArray[6] & 0x0f) << 6) | ((uintArray[5] & 0xfc) >>> 2); >+ >+ if ((exponent - 1023) < -14) { >+ exponent = 0; >+ significand = (Math.abs(number) * Math.pow(2, 24)) >>> 0; >+ let value = Math.pow(2, -14) * significand / 1024; >+ if (sign != 0) >+ value *= -1; >+ return value; >+ } >+ >+ doubleArray[0] = 0; >+ >+ uintArray[7] |= sign; >+ uintArray[7] |= (exponent >>> 4); >+ uintArray[6] |= ((exponent << 4) & 0xf0); >+ uintArray[6] |= (significand >>> 6); >+ uintArray[5] |= ((significand << 2) & 0xfc); >+ >+ return doubleArray[0]; >+ } >+ > this._map.set( >- "native typedef int", >+ "native typedef void", > type => { >- this.int = type; >- type.isPrimitive = true; >- type.isInt = true; >- type.isNumber = true; >- type.isSigned = true; >- type.canRepresent = value => isBitwiseEquivalent(value | 0, value); >- type.size = 1; >- type.defaultValue = 0; >- type.createLiteral = (origin, value) => IntLiteral.withType(origin, value | 0, type); >- type.successorValue = value => (value + 1) | 0; >- type.valuesEqual = (a, b) => a === b; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value | 0; >- type.formatValueFromUintLiteral = value => value | 0; >- type.allValues = function*() { >- for (let i = 0; i <= 0xffffffff; ++i) { >- let value = i | 0; >- yield {value: value, name: value}; >- } >- }; >+ this.void = type; >+ type.size = 0; >+ type.populateDefaultValue = () => { }; > }); > > this._map.set( >- "native typedef uint", >+ "native typedef bool", > type => { >- this.uint = type; >+ this.bool = type; > type.isPrimitive = true; >- type.isInt = true; >- type.isNumber = true; >- type.isSigned = false; >- type.canRepresent = value => isBitwiseEquivalent(value >>> 0, value); > type.size = 1; >- type.defaultValue = 0; >- type.createLiteral = (origin, value) => IntLiteral.withType(origin, value >>> 0, type); >- type.successorValue = value => (value + 1) >>> 0; >- type.valuesEqual = (a, b) => a === b; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value >>> 0; >- type.formatValueFromUintLiteral = value => value >>> 0; >- type.allValues = function*() { >- for (let i = 0; i <= 0xffffffff; ++i) >- yield {value: i, name: i}; >- }; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, false); > }); > > this._map.set( > "native typedef uchar", > type => { > this.uchar = type; >+ type.isPrimitive = true; > type.isInt = true; > type.isNumber = true; > type.isSigned = false; >@@ -126,419 +143,850 @@ class Intrinsics { > }; > }); > >+ >+ this._map.set( >+ "native typedef ushort", >+ type => { >+ this.ushort = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = false; >+ type.canRepresent = value => isBitwiseEquivalent(value & 0xffff, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value & 0xffff, type); >+ type.successorValue = value => (value + 1) & 0xffff; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value & 0xffff; >+ type.formatValueFromUintLiteral = value => value & 0xffff; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffff; ++i) >+ yield {value: i, name: i}; >+ }; >+ }); >+ > this._map.set( >- "native typedef float", >- type => { >- this.float = type; >- type.isPrimitive = true; >- type.size = 1; >- type.isFloating = true; >- type.isNumber = true; >- type.canRepresent = value => isBitwiseEquivalent(Math.fround(value), value); >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >- type.formatValueFromIntLiteral = value => value; >- type.formatValueFromUintLiteral = value => value; >- type.formatValueFromFloatLiteral = value => Math.fround(value); >- }); >+ "native typedef uint", >+ type => { >+ this.uint = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = false; >+ type.canRepresent = value => isBitwiseEquivalent(value >>> 0, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value >>> 0, type); >+ type.successorValue = value => (value + 1) >>> 0; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value >>> 0; >+ type.formatValueFromUintLiteral = value => value >>> 0; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffffffff; ++i) >+ yield {value: i, name: i}; >+ }; >+ }); > > this._map.set( >- "native typedef bool", >- type => { >- this.bool = type; >- type.isPrimitive = true; >- type.size = 1; >- type.populateDefaultValue = (buffer, offset) => buffer.set(offset, false); >- }); >+ "native typedef char", >+ type => { >+ this.char = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(cast(Int8Array, value), value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, cast(Int8Array, value), type); >+ type.successorValue = value => cast(Int8Array, value + 1); >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => cast(Int8Array, value); >+ type.formatValueFromUintLiteral = value => cast(Int8Array, value); >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xff; ++i) { >+ let value = cast(Int8Array, i); >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ >+ this._map.set( >+ "native typedef short", >+ type => { >+ this.short = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(cast(Int16Array, value), value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, cast(Int16Array, value), type); >+ type.successorValue = value => cast(Int16Array, value + 1); >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => cast(Int16Array, value); >+ type.formatValueFromUintLiteral = value => cast(Int16Array, value); >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffff; ++i) { >+ let value = cast(Int16Array, i); >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ >+ this._map.set( >+ "native typedef int", >+ type => { >+ this.int = type; >+ type.isPrimitive = true; >+ type.isInt = true; >+ type.isNumber = true; >+ type.isSigned = true; >+ type.canRepresent = value => isBitwiseEquivalent(value | 0, value); >+ type.size = 1; >+ type.defaultValue = 0; >+ type.createLiteral = (origin, value) => IntLiteral.withType(origin, value | 0, type); >+ type.successorValue = value => (value + 1) | 0; >+ type.valuesEqual = (a, b) => a === b; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value | 0; >+ type.formatValueFromUintLiteral = value => value | 0; >+ type.allValues = function*() { >+ for (let i = 0; i <= 0xffffffff; ++i) { >+ let value = i | 0; >+ yield {value: value, name: value}; >+ } >+ }; >+ }); >+ >+ this._map.set( >+ "native typedef half", >+ type => { >+ this.half = type; >+ type.isPrimitive = true; >+ type.size = 1; >+ type.isFloating = true; >+ type.isNumber = true; >+ type.canRepresent = value => isBitwiseEquivalent(castToHalf(value), value); >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value; >+ type.formatValueFromUintLiteral = value => value; >+ type.formatValueFromFloatLiteral = value => castToHalf(value); >+ }); >+ >+ this._map.set( >+ "native typedef float", >+ type => { >+ this.float = type; >+ type.isPrimitive = true; >+ type.size = 1; >+ type.isFloating = true; >+ type.isNumber = true; >+ type.canRepresent = value => isBitwiseEquivalent(Math.fround(value), value); >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, 0); >+ type.formatValueFromIntLiteral = value => value; >+ type.formatValueFromUintLiteral = value => value; >+ type.formatValueFromFloatLiteral = value => Math.fround(value); >+ }); >+ >+ this._map.set( >+ "native typedef atomic_int", >+ type => { >+ this.atomic_int = type; >+ }); >+ >+ this._map.set( >+ "native typedef atomic_uint", >+ type => { >+ this.atomic_uint = type; >+ }); > > for (let vectorType of VectorElementTypes) { >- for (let vectorSize of VectorElementSizes) >- this._map.set(`native typedef vector<${vectorType}, ${vectorSize}>`, type => {}); >+ for (let vectorSize of VectorElementSizes) { >+ this._map.set(`native typedef vector<${vectorType}, ${vectorSize}>`, type => { >+ this[`vector<${vectorType}, ${vectorSize}>`] = type; >+ }); >+ } > } >- >+ >+ for (let type of ["half", "float"]) { >+ for (let height = 2; height <= 4; ++height) { >+ for (let width = 2; width <= 4; ++width) { >+ this._map.set(`native typedef matrix<${type}, ${height}, ${width}>`, type => { >+ this[`matrix<${type}, ${height}, ${width}>`] = type; >+ }); >+ } >+ } >+ } >+ > this._map.set( >- "native operator int(uint)", >- func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >+ "native typedef sampler", >+ type => { >+ this.sampler = type; >+ // FIXME: Figure out what to put here. > }); >- >+ >+ for (let textureType of ["Texture1D", "RWTexture1D", "Texture1DArray", "RWTexture1DArray", "Texture2D", "RWTexture2D", "Texture2DArray", "RWTexture2DArray", "Texture3D", "RWTexture3D", "TextureCube"]) { >+ for (let typeArgument of ["bool", "uchar", "ushort", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}>`, >+ type => { >+ this[`${textureType}<${typeArgument}>`] = type; >+ }); >+ for (let i = 2; i <= 4; ++i) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}${i}>`, >+ type => { >+ this[`${textureType}<${typeArgument}${i}>`] = type; >+ }); >+ } >+ } >+ } >+ >+ for (let textureType of ["TextureDepth2D", "RWTextureDepth2D", "TextureDepth2DArray", "RWTextureDepth2DArray", "TextureDepthCube"]) { >+ for (let typeArgument of ["float", "half"]) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}>`, >+ type => { >+ this[`${textureType}<${typeArgument}>`] = type; >+ }); >+ } >+ } >+ >+ for (let primitiveType of ["ushort", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator uchar(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator ushort(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xffff); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator uint(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native operator char(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int8Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "int", "half", "float"]) { >+ this._map.set( >+ `native operator short(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int16Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "half", "float"]) { >+ this._map.set( >+ `native operator int(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(cast(Int32Array, value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "int", "float"]) { >+ this._map.set( >+ `native operator half(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(castToHalf(value.loadValue())); >+ }); >+ } >+ >+ for (let primitiveType of ["uchar", "ushort", "uint", "char", "short", "int", "half"]) { >+ this._map.set( >+ `native operator float(${primitiveType})`, >+ func => { >+ func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ }); >+ } >+ > this._map.set( >- "native operator int(uchar)", >+ `native operator int(atomic_int)`, > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >+ func.implementation = ([value]) => EPtr.box(value.loadValue()); > }); >- >+ > this._map.set( >- "native operator int(float)", >+ `native operator uint(atomic_uint)`, > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() | 0); >+ func.implementation = ([value]) => EPtr.box(value.loadValue()); > }); >- >+ > this._map.set( >- "native operator uint(int)", >+ "native bool operator==(bool,bool)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() == right.loadValue()); > }); >- >+ >+ for (let primitiveType of ["uint", "int", "float"]) { >+ this._map.set( >+ `native bool operator==(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() == right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator<(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() < right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator<=(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() <= right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator>(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() > right.loadValue()); >+ }); >+ >+ this._map.set( >+ `native bool operator>=(${primitiveType},${primitiveType})`, >+ func => { >+ func.implementation = ([left, right]) => >+ EPtr.box(left.loadValue() >= right.loadValue()); >+ }); >+ } >+ > this._map.set( >- "native operator uint(uchar)", >+ "native int operator-(int)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >+ func.implementation = ([value]) => >+ EPtr.box((-value.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native operator uint(float)", >+ "native float operator-(float)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() >>> 0); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(-value.loadValue())); > }); >- >+ > this._map.set( >- "native operator uchar(int)", >+ "native int operator+(int,int)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() + right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native operator uchar(uint)", >+ "native int operator-(int,int)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() - right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native operator uchar(float)", >+ "native int operator*(int,int)", > func => { >- func.implementation = ([value]) => EPtr.box(value.loadValue() & 0xff); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() * right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native operator float(int)", >+ "native int operator/(int,int)", > func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() / right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native operator float(uint)", >+ "native uint operator+(uint,uint)", > func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() + right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native operator float(uchar)", >+ "native uint operator-(uint,uint)", > func => { >- func.implementation = ([value]) => EPtr.box(Math.fround(value.loadValue())); >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() - right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native int operator+(int,int)", >+ "native uint operator*(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() + right.loadValue()) | 0); >+ EPtr.box((left.loadValue() * right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native uint operator+(uint,uint)", >+ "native uint operator/(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() + right.loadValue()) >>> 0); >+ EPtr.box((left.loadValue() / right.loadValue()) >>> 0); > }); >- >+ > this._map.set( > "native float operator+(float,float)", > func => { > func.implementation = ([left, right]) => > EPtr.box(Math.fround(left.loadValue() + right.loadValue())); > }); >- >+ > this._map.set( >- "native int operator-(int,int)", >+ "native float operator-(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() - right.loadValue()) | 0); >+ EPtr.box(Math.fround(left.loadValue() - right.loadValue())); > }); >- >+ > this._map.set( >- "native uint operator-(uint,uint)", >+ "native float operator*(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() - right.loadValue()) >>> 0); >+ EPtr.box(Math.fround(left.loadValue() * right.loadValue())); > }); >- >+ > this._map.set( >- "native float operator-(float,float)", >+ "native float operator/(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() - right.loadValue())); >+ EPtr.box(Math.fround(left.loadValue() / right.loadValue())); > }); >- >+ > this._map.set( >- "native int operator*(int,int)", >+ "native int operator&(int,int)", > func => { >- func.implementation = ([left, right]) => { >- return EPtr.box((left.loadValue() * right.loadValue()) | 0); >- }; >+ func.implementation = ([left, right]) => >+ EPtr.box((left.loadValue() & right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native uint operator*(uint,uint)", >+ "native int operator|(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() * right.loadValue()) >>> 0); >+ EPtr.box((left.loadValue() | right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native float operator*(float,float)", >+ "native int operator^(int,int)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() * right.loadValue())); >+ EPtr.box((left.loadValue() ^ right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native int operator/(int,int)", >+ "native int operator~(int)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() / right.loadValue()) | 0); >+ func.implementation = ([value]) => EPtr.box((~value.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native uint operator/(uint,uint)", >+ "native int operator<<(int,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box((left.loadValue() / right.loadValue()) >>> 0); >+ EPtr.box((left.loadValue() << right.loadValue()) | 0); > }); >- >+ > this._map.set( >- "native int operator&(int,int)", >+ "native int operator>>(int,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() & right.loadValue()); >+ EPtr.box((left.loadValue() >> right.loadValue()) | 0); > }); >- >+ > this._map.set( > "native uint operator&(uint,uint)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() & right.loadValue()) >>> 0); > }); >- >- this._map.set( >- "native int operator|(int,int)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() | right.loadValue()); >- }); >- >+ > this._map.set( > "native uint operator|(uint,uint)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() | right.loadValue()) >>> 0); > }); >- >- this._map.set( >- "native int operator^(int,int)", >- func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() ^ right.loadValue()); >- }); >- >+ > this._map.set( > "native uint operator^(uint,uint)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() ^ right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native int operator<<(int,uint)", >+ "native uint operator~(uint)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() << right.loadValue()); >+ func.implementation = ([value]) => EPtr.box((~value.loadValue()) >>> 0); > }); >- >+ > this._map.set( > "native uint operator<<(uint,uint)", > func => { > func.implementation = ([left, right]) => > EPtr.box((left.loadValue() << right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native int operator>>(int,uint)", >+ "native uint operator>>(uint,uint)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >> right.loadValue()); >+ EPtr.box((left.loadValue() >>> right.loadValue()) >>> 0); > }); >- >+ > this._map.set( >- "native uint operator>>(uint,uint)", >+ "native float cos(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >>> right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.cos(value.loadValue()))); > }); >- >+ > this._map.set( >- "native int operator~(int)", >+ "native float sin(float)", > func => { >- func.implementation = ([value]) => EPtr.box(~value.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.sin(value.loadValue()))); > }); >- >+ > this._map.set( >- "native uint operator~(uint)", >+ "native float tan(float)", > func => { >- func.implementation = ([value]) => EPtr.box((~value.loadValue()) >>> 0); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.tan(value.loadValue()))); > }); >- >+ > this._map.set( >- "native float operator/(float,float)", >+ "native float acos(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() / right.loadValue())); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.acos(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator==(int,int)", >+ "native float asin(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.asin(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator==(uint,uint)", >+ "native float atan(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.atan(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator==(bool,bool)", >+ "native float cosh(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.cosh(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator==(float,float)", >+ "native float sinh(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() == right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.sinh(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<(int,int)", >+ "native float tanh(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.tanh(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<(uint,uint)", >+ "native float ceil(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.ceil(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<(float,float)", >+ "native float exp(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() < right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.exp(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<=(int,int)", >+ "native float floor(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.floor(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<=(uint,uint)", >+ "native float log(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.log(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator<=(float,float)", >+ "native float round(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() <= right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.round(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator>(int,int)", >+ "native float sqrt(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.sqrt(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator>(uint,uint)", >+ "native float trunc(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.trunc(value.loadValue()))); > }); >- >+ > this._map.set( >- "native bool operator>(float,float)", >+ "native float ddx(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() > right.loadValue()); >+ func.implementation = ([value]) => EPtr.box(0); > }); >- >+ > this._map.set( >- "native bool operator>=(int,int)", >+ "native float ddy(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ func.implementation = ([value]) => EPtr.box(0); > }); >- >+ > this._map.set( >- "native bool operator>=(uint,uint)", >+ "native float pow(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ EPtr.box(Math.fround(Math.pow(left.loadValue(), right.loadValue()))); >+ }); >+ >+ this._map.set( >+ "native bool isfinite(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(Number.isFinite(value.loadValue())); >+ }); >+ >+ this._map.set( >+ "native bool isinf(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box((value.loadValue() == Number.POSITIVE_INFINITY) || (value.loadValue() == Number.NEGATIVE_INFINITY)); >+ }); >+ >+ this._map.set( >+ "native bool isnan(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(Number.isNaN(value.loadValue())); >+ }); >+ >+ // FIXME: Implement this. >+ this._map.set( >+ "native bool isnormal(half)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(isNaN(value.loadValue())); >+ }); >+ >+ // FIXME: Implement this. >+ this._map.set( >+ "native bool isnormal(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(isNaN(value.loadValue())); > }); >- >+ > this._map.set( >- "native bool operator>=(float,float)", >+ "native float atan2(float,float)", > func => { > func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ EPtr.box(Math.fround(Math.atan2(left.loadValue(), right.loadValue()))); > }); > >- for (let nativeVectorTypeName of allVectorTypeNames()) >+ this._map.set( >+ "native int asint(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Float32Array, Int32Array, value.loadValue())); >+ }); >+ >+ this._map.set( >+ "native uint asuint(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Float32Array, Uint32Array, value.loadValue())); >+ }); >+ >+ this._map.set( >+ "native float asfloat(int)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Int32Array, Float32Array, value.loadValue())); >+ }); >+ >+ this._map.set( >+ "native float asfloat(uint)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Uint32Array, Float32Array, value.loadValue())); >+ }); >+ >+ // FIXME: Implement this. >+ this._map.set( >+ "native float f16tof32(uint)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(0); >+ }); >+ >+ // FIXME: Implement this. >+ this._map.set( >+ "native uint f32tof16(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(0); >+ }); >+ >+ this._map.set( >+ "native void AllMemoryBarrierWithGroupSync()", >+ func => { >+ func.implementation = function() {}; >+ }); >+ >+ this._map.set( >+ "native void DeviceMemoryBarrierWithGroupSync()", >+ func => { >+ func.implementation = function() {}; >+ }); >+ >+ this._map.set( >+ "native void GroupMemoryBarrierWithGroupSync()", >+ func => { >+ func.implementation = function() {}; >+ }); >+ >+ for (let nativeVectorTypeName of allVectorTypeNames()) { > this._map.set(`native typedef ${nativeVectorTypeName}`, type => { > type.isPrimitive = true; > }); >+ } > >- for (let swizzle of SwizzleOp.functions()) >- this._map.set(swizzle.toString(), func => swizzle.instantiateImplementation(func)); > >- for (let boolOp of OperatorBool.functions()) >- this._map.set(boolOp.toString(), func => boolOp.instantiateImplementation(func)); >+ for (let vectorType of VectorElementTypes) { >+ this._map.set( >+ `native ${vectorType} operator.x(${vectorType}2)`, >+ func => (new BuiltinVectorGetter(vectorType, 2, "x", 0)).instantiateImplementation(func)); > >- for (let anderIndex of OperatorAnderIndexer.functions()) >- this._map.set(anderIndex.toString(), func => anderIndex.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.y(${vectorType}2)`, >+ func => (new BuiltinVectorGetter(vectorType, 2, "y", 1)).instantiateImplementation(func)); > >- for (let cast of BuiltinVectorConstructors.functions()) >- this._map.set(cast.toString(), func => cast.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.x(${vectorType}3)`, >+ func => (new BuiltinVectorGetter(vectorType, 3, "x", 0)).instantiateImplementation(func)); > >- for (let getter of BuiltinVectorIndexGetter.functions()) >- this._map.set(getter.toString(), func => getter.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.y(${vectorType}3)`, >+ func => (new BuiltinVectorGetter(vectorType, 3, "y", 1)).instantiateImplementation(func)); > >- for (let setter of BuiltinVectorIndexSetter.functions()) >- this._map.set(setter.toString(), func => setter.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.z(${vectorType}3)`, >+ func => (new BuiltinVectorGetter(vectorType, 3, "z", 2)).instantiateImplementation(func)); > >- for (let equalityOperator of BuiltinVectorEqualityOperator.functions()) >- this._map.set(equalityOperator.toString(), func => equalityOperator.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.x(${vectorType}4)`, >+ func => (new BuiltinVectorGetter(vectorType, 4, "x", 0)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType} operator.y(${vectorType}4)`, >+ func => (new BuiltinVectorGetter(vectorType, 4, "y", 1)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType} operator.z(${vectorType}4)`, >+ func => (new BuiltinVectorGetter(vectorType, 4, "z", 2)).instantiateImplementation(func)); > >- for (let getter of BuiltinVectorGetter.functions()) >- this._map.set(getter.toString(), func => getter.instantiateImplementation(func)); >+ this._map.set( >+ `native ${vectorType} operator.w(${vectorType}4)`, >+ func => (new BuiltinVectorGetter(vectorType, 4, "w", 3)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}2 operator.x=(${vectorType}2,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 2, "x", 0)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}2 operator.y=(${vectorType}2,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 2, "y", 1)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}3 operator.x=(${vectorType}3,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 3, "x", 0)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}3 operator.y=(${vectorType}3,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 3, "y", 1)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}3 operator.z=(${vectorType}3,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 3, "z", 2)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}4 operator.x=(${vectorType}4,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 4, "x", 0)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}4 operator.y=(${vectorType}4,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 4, "y", 1)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}4 operator.z=(${vectorType}4,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 4, "z", 2)).instantiateImplementation(func)); >+ >+ this._map.set( >+ `native ${vectorType}4 operator.w=(${vectorType}4,${vectorType})`, >+ func => (new BuiltinVectorSetter(vectorType, 4, "w", 3)).instantiateImplementation(func)); >+ } >+ >+ for (let swizzle of SwizzleOp.functions()) >+ this._map.set(swizzle.toString(), func => swizzle.instantiateImplementation(func)); >+ >+ for (let cast of BuiltinVectorConstructors.functions()) >+ this._map.set(cast.toString(), func => cast.instantiateImplementation(func)); > >- for (let setter of BuiltinVectorSetter.functions()) >- this._map.set(setter.toString(), func => setter.instantiateImplementation(func)); >+ for (let equalityOperator of BuiltinVectorEqualityOperator.functions()) >+ this._map.set(equalityOperator.toString(), func => equalityOperator.instantiateImplementation(func)); > } >- >+ > add(thing) > { > let intrinsic = this._map.get(thing.toString()); >diff --git a/Tools/WebGPUShadingLanguageRI/MatrixType.js b/Tools/WebGPUShadingLanguageRI/MatrixType.js >new file mode 100644 >index 0000000000000000000000000000000000000000..3d1ef6403c07926f1113ee68e4f5b30e9bc37040 >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/MatrixType.js >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+"use strict"; >+ >+class MatrixType extends NativeType { >+ constructor(origin, name, typeArguments) >+ { >+ super(origin, name, typeArguments); >+ } >+ >+ get elementType() { return this.typeArguments[0]; } >+ get numRows() { return this.typeArguments[1]; } >+ get numColumns() { return this.typeArguments[2]; } >+ get numRowsValue() { return this.numRows.value; } >+ get numColumnsValue() { return this.numColumns.value; } >+ get size() { return this.elementType.size * this.numRowsValue * this.numColumnsValue; } >+ >+ unifyImpl(unificationContext, other) >+ { >+ if (!(other instanceof MatrixType)) >+ return false; >+ >+ if (this.numRowsValue !== other.numRowsValue || this.runColumnsValue !== other.numColumnsValue) >+ return false; >+ >+ return this.elementType.unify(unificationContext, other.elementType); >+ } >+ >+ populateDefaultValue(buffer, offset) >+ { >+ for (let i = 0; i < this.numRowsValue * this.runColumnsValue; ++i) >+ this.elementType.populateDefaultValue(buffer, offset + i * this.elementType.size); >+ } >+ >+ toString() >+ { >+ return `native typedef matrix<${this.elementType}, ${this.numRowsValue}, ${this.numColumnsValue}>`; >+ } >+} >+ >diff --git a/Tools/WebGPUShadingLanguageRI/NameContext.js b/Tools/WebGPUShadingLanguageRI/NameContext.js >index 1bab3fc5602601077b3fa885a6054ab860b0a193..c89968c779607b7cabcc6a5f969b4ab913e7263e 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameContext.js >+++ b/Tools/WebGPUShadingLanguageRI/NameContext.js >@@ -69,11 +69,33 @@ class NameContext { > return; > } > >+ if (thing.kind == Type) { >+ this._set.add(thing); >+ if (thing.typeArguments && thing.typeArguments.length != 0) { >+ let array = this._map.get(thing.name); >+ if (!array) { >+ array = []; >+ array.kind = Type; >+ this._map.set(thing.name, array); >+ } >+ if (array.kind != Type) >+ throw new WTypeError(thing.origin.originString, "Cannot reuse type name for function: " + thing.name); >+ array.push(thing); >+ return; >+ } else { >+ if (this._map.has(thing.name)) >+ throw new WTypeError(thing.origin.originString, "Duplicate name: " + thing.name); >+ this._map.set(thing.name, thing); >+ } >+ return; >+ } >+ > if (this._map.has(thing.name)) > throw new WTypeError(thing.origin.originString, "Duplicate name: " + thing.name); > > this._set.add(thing); > this._map.set(thing.name, thing); >+ > } > > get(kind, name) >@@ -102,6 +124,10 @@ class NameContext { > for (let func of thing) > yield func; > return; >+ } else if (thing.kind === Type && (thing instanceof Array)) { >+ for (let type of thing) >+ yield type; >+ return; > } > yield thing; > } >@@ -163,8 +189,8 @@ class NameContext { > { > for (let value of this._map.values()) { > if (value instanceof Array) { >- for (let func of value) >- yield func; >+ for (let thing of value) >+ yield thing; > continue; > } > yield value; >diff --git a/Tools/WebGPUShadingLanguageRI/NameResolver.js b/Tools/WebGPUShadingLanguageRI/NameResolver.js >index f615a2fb4e87dc1deb7b01b572fb7af626abd095..9a099f485e6e927e16437bbf82641f61e4525cf1 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameResolver.js >+++ b/Tools/WebGPUShadingLanguageRI/NameResolver.js >@@ -120,12 +120,19 @@ class NameResolver extends Visitor { > > visitTypeRef(node) > { >+ super.visitTypeRef(node); > let type = node.type; > if (!type) { > type = this._nameContext.get(Type, node.name); > if (!type) > throw new WTypeError(node.origin.originString, "Could not find type named " + node.name); >- node.type = type; >+ if (type instanceof Array) { >+ // Type unification requires the .type value to be set already, so we can eagerly set it now. >+ for (let overload of type) >+ Node.visit(overload, this); >+ node.resolve(type); >+ } else >+ node.type = type; > } > } > >@@ -208,9 +215,4 @@ class NameResolver extends Visitor { > > super.visitCallExpression(node); > } >- >- visitVectorType(node) >- { >- node.elementType.visit(this); >- } > } >diff --git a/Tools/WebGPUShadingLanguageRI/NativeType.js b/Tools/WebGPUShadingLanguageRI/NativeType.js >index e2d851cbccba3a97234c7bd392907829ca9e05f2..b368a2e8b24f548eab88a2824b495be23c87cb85 100644 >--- a/Tools/WebGPUShadingLanguageRI/NativeType.js >+++ b/Tools/WebGPUShadingLanguageRI/NativeType.js >@@ -25,11 +25,14 @@ > "use strict"; > > class NativeType extends Type { >- constructor(origin, name) >+ constructor(origin, name, typeArguments) > { >+ if (!(typeArguments instanceof Array)) >+ throw new Error("type parameters not array: " + typeArguments); > super(); > this._origin = origin; > this._name = name; >+ this._typeArguments = typeArguments; > this._isNumber = false; > this._isInt = false; > this._isFloating = false; >@@ -38,6 +41,7 @@ class NativeType extends Type { > > get origin() { return this._origin; } > get name() { return this._name; } >+ get typeArguments() { return this._typeArguments; } > get isNative() { return true; } > > // We let Intrinsics.js set these as it likes. >@@ -52,19 +56,20 @@ class NativeType extends Type { > > toString() > { >- return `native typedef ${this.name}`; >+ let result = `native typedef ${this.name}`; >+ if (this.typeArguments.length) >+ result += "<" + this.typeArguments.join(",") + ">"; >+ return result; > } > > static create(origin, name, typeArguments) > { >- // FIXME: For native types like Texture1D this should resolve the type to something concrete by changing the type name. >- if (typeArguments.length) >- throw new WTypeError(origin.originString, `${name}<${typeArguments.join(",")}>: Support for native types with type arguments is currently unimplemented.`); >+ if (name == "vector") >+ return new VectorType(origin, name, typeArguments); >+ if (name == "matrix") >+ return new MatrixType(origin, name, typeArguments); > >- if (allVectorTypeNames().indexOf(name) > -1) >- return new VectorType(origin, name); >- >- return new NativeType(origin, name); >+ return new NativeType(origin, name, typeArguments); > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/OperatorAnderIndex.js b/Tools/WebGPUShadingLanguageRI/OperatorAnderIndex.js >deleted file mode 100644 >index 670371fb90f2a1fd15c2ddf6c4a396c0f239cebf..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/OperatorAnderIndex.js >+++ /dev/null >@@ -1,71 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-class OperatorAnderIndexer { >- constructor(baseTypeName, addressSpace) >- { >- this._baseTypeName = baseTypeName; >- this._addressSpace = addressSpace; >- } >- >- get addressSpace() { return this._addressSpace; } >- get baseTypeName() { return this._baseTypeName; } >- >- toString() >- { >- return `native ${this.baseTypeName}* ${this.addressSpace} operator&[](${this.baseTypeName}[] ${this.addressSpace},uint)`; >- } >- >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- const typeNames = [ "uint", "int", "float", "bool" ].concat(allVectorTypeNames()); >- const addressSpaces = [ "thread", "threadgroup", "device", "constant" ]; >- >- for (let addressSpace of addressSpaces) { >- for (let typeName of typeNames) >- this._functions.push(new OperatorAnderIndexer(typeName, addressSpace)); >- } >- } >- return this._functions; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([ref, index], node) => { >- ref = ref.loadValue(); >- if (!ref) >- throw new WTrapError(node.origin.originString, "Null dereference"); >- index = index.loadValue(); >- if (index > ref.length) >- throw new WTrapError(node.origin.originString, "Array index " + index + " is out of bounds of " + ref); >- return EPtr.box(ref.ptr.plus(index * node.argumentTypes[0].elementType.size)); >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/OperatorAnderIndexer.js b/Tools/WebGPUShadingLanguageRI/OperatorAnderIndexer.js >new file mode 100644 >index 0000000000000000000000000000000000000000..012f06780f7ad9322d6c7be4790cd446181f89b4 >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/OperatorAnderIndexer.js >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+"use strict"; >+ >+class OperatorAnderIndexer { >+ constructor(baseTypeName, addressSpace) >+ { >+ this._baseTypeName = baseTypeName; >+ this._addressSpace = addressSpace; >+ } >+ >+ get addressSpace() { return this._addressSpace; } >+ get baseTypeName() { return this._baseTypeName; } >+ >+ toString() >+ { >+ return `native ${this.baseTypeName}* ${this.addressSpace} operator&[](${this.baseTypeName}[] ${this.addressSpace},uint)`; >+ } >+ >+ instantiateImplementation(func) >+ { >+ func.implementation = ([ref, index], node) => { >+ ref = ref.loadValue(); >+ if (!ref) >+ throw new WTrapError(node.origin.originString, "Null dereference"); >+ index = index.loadValue(); >+ if (index > ref.length) >+ throw new WTrapError(node.origin.originString, "Array index " + index + " is out of bounds of " + ref); >+ return EPtr.box(ref.ptr.plus(index * node.argumentTypes[0].elementType.size)); >+ }; >+ func.implementationData = this; >+ } >+} >diff --git a/Tools/WebGPUShadingLanguageRI/OperatorBool.js b/Tools/WebGPUShadingLanguageRI/OperatorBool.js >deleted file mode 100644 >index 58bb0e09b80bee107089b1c9d200cbc68a5cb9d3..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/OperatorBool.js >+++ /dev/null >@@ -1,68 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-class OperatorBool { >- constructor(baseTypeName) >- { >- this._baseTypeName = baseTypeName; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- >- toString() >- { >- return `native operator bool(${this.baseTypeName})`; >- } >- >- static functions() >- { >- // FIXME: These operators should be in the standard library where possible. >- if (!OperatorBool._functions) { >- OperatorBool._functions = []; >- >- // bool is not included because this is generated by the copy constructor. >- // FIXME: Include all native types. >- const typeNames = [ "uchar", "uint", "int", "float" ].concat(allVectorTypeNames()); >- >- for (let typeName of typeNames) >- OperatorBool._functions.push(new OperatorBool(typeName)); >- } >- return OperatorBool._functions; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([ref], node) => { >- const size = node.argumentTypes[0].size; >- for (let i = 0; i < size; ++i) { >- if (!!ref.get(i)) >- return EPtr.box(true); >- } >- return EPtr.box(false); >- } >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/Prepare.js b/Tools/WebGPUShadingLanguageRI/Prepare.js >index 7b16139e95b81e2e8da8354bd8c179b190baefa0..834592d36f3457dfa86b5751bb7262472a3f0a2d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Prepare.js >+++ b/Tools/WebGPUShadingLanguageRI/Prepare.js >@@ -40,20 +40,19 @@ let prepare = (() => { > } > > foldConstexprs(program); >- removeTypeArguments(program); > > let nameResolver = createNameResolver(program); > resolveNamesInTypes(program, nameResolver); > resolveTypeDefsInTypes(program); > checkRecursiveTypes(program); > synthesizeStructAccessors(program); >- synthesizeOperatorBool(program); > synthesizeEnumFunctions(program); > synthesizeArrayOperatorLength(program); > synthesizeCopyConstructorOperator(program); > synthesizeDefaultConstructorOperator(program); > resolveNamesInFunctions(program, nameResolver); > resolveTypeDefsInFunctions(program); >+ checkTypesWithArguments(program); > > check(program); > checkLiteralTypes(program); >@@ -66,6 +65,7 @@ let prepare = (() => { > checkLoops(program); > checkRecursion(program); > checkProgramWrapped(program); >+ checkTypesWithArguments(program); > findHighZombies(program); > program.visit(new StructLayoutBuilder()); > inline(program); >diff --git a/Tools/WebGPUShadingLanguageRI/Program.js b/Tools/WebGPUShadingLanguageRI/Program.js >index 06625d98fc41e74c93dece80b70ce55c7af74dd5..ac1defb4fbaaa6e8e13429734ccf4915339ba539 100644 >--- a/Tools/WebGPUShadingLanguageRI/Program.js >+++ b/Tools/WebGPUShadingLanguageRI/Program.js >@@ -48,19 +48,25 @@ class Program extends Node { > if (statement instanceof Func) { > let array = this._functions.get(statement.name); > if (!array) >- this._functions.set(statement.name, array = []); >+ this.functions.set(statement.name, array = []); > array.push(statement); >- } else if (statement instanceof Type) >- this._types.set(statement.name, statement); >- else >+ } else if (statement instanceof Type) { >+ if (statement.isNative && statement.typeArguments.length != 0) { >+ let array = this.types.get(statement.name); >+ if (!array) >+ this.types.set(statement.name, array = []); >+ array.push(statement); >+ } else >+ this.types.set(statement.name, statement); >+ } else > throw new Error("Statement is not a function or type: " + statement); >- this._topLevelStatements.push(statement); >- this._globalNameContext.add(statement); >+ this.topLevelStatements.push(statement); >+ this.globalNameContext.add(statement); > } > > toString() > { >- if (!this._topLevelStatements.length) >+ if (!this.topLevelStatements.length) > return ""; > return this._topLevelStatements.join(";") + ";"; > } >diff --git a/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js b/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js >deleted file mode 100644 >index 93db9e647c921c954e8998ce1675de7cb61f142b..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/RemoveTypeArguments.js >+++ /dev/null >@@ -1,65 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-function removeTypeArguments(program) >-{ >- class RemoveTypeArguments extends Visitor { >- static resolveNameAndArguments(node) >- { >- if (!node.typeArguments) >- return node.name; >- >- switch (node.name) { >- case "vector": >- if (node.typeArguments.length != 2) >- throw new WSyntaxError(node.originString, `${node.name} should have 2 type arguments, got ${node.typeArguments.length}.`); >- >- const elementTypeName = node.typeArguments[0].name; >- const lengthValue = node.typeArguments[1].value; >- >- if (VectorElementTypes.indexOf(elementTypeName) < 0) >- throw new WSyntaxError(node.originString, `${elementTypeName} is not a valid vector element type.`); >- if (VectorElementSizes.indexOf(lengthValue) < 0) >- throw new WSyntaxError(node.originString, `${lengthValue} is not a valid size for vectors with element type ${elementTypeName}.`); >- >- return `${elementTypeName}${lengthValue}`; >- // FIXME: Further cases for matrices, textures, etc. >- default: >- if (node.typeArguments.length) >- throw new WSyntaxError(`${node.name}${arguments.join(", ")} is not a permitted generic type or function`); >- return node.name; >- } >- } >- >- visitTypeRef(node) >- { >- node._name = RemoveTypeArguments.resolveNameAndArguments(node); >- node._typeArguments = null; >- } >- } >- >- program.visit(new RemoveTypeArguments()); >-} >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveNames.js b/Tools/WebGPUShadingLanguageRI/ResolveNames.js >index 2e402c8d6c0a36098561e0275ee53e778fd384b8..b8b53342459ae839acf7f07c2bbaea96e8a54cdf 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveNames.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveNames.js >@@ -31,8 +31,13 @@ function createNameResolver(program) > > function resolveNamesInTypes(program, nameResolver) > { >- for (let type of program.types.values()) >- nameResolver.doStatement(type); >+ for (let type of program.types.values()) { >+ if (type instanceof Array) { >+ for (let constituentType of type) >+ nameResolver.doStatement(constituentType); >+ } else >+ nameResolver.doStatement(type); >+ } > } > > function resolveNamesInFunctions(program, nameResolver) >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js b/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >index d0f1e34d617ea27266467c161707154664a449ad..7a097bca470ecb56a6ee3def52aaf5f78b506511 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js >@@ -100,3 +100,28 @@ function resolveOverloadImpl(functions, argumentTypes, returnType, allowEntryPoi > > return {failures: ambiguityList.map(overload => new OverloadResolutionFailure(overload.func, message))}; > } >+ >+function resolveTypeOverloadImpl(types, typeArguments) >+{ >+ if (!types) >+ throw new Error("Null types; that should have been caught by the caller."); >+ >+ let failures = []; >+ let successes = []; >+ for (let type of types) { >+ let overload = inferTypesForTypeArguments(type, typeArguments); >+ if (overload.failure) >+ failures.push(overload.failure); >+ else >+ successes.push(overload); >+ } >+ >+ if (!successes.length) >+ return {failures: failures}; >+ >+ if (successes.length == 1) >+ return successes[0]; >+ >+ let message = "Ambiguous overload - types mutually applicable"; >+ return {failures: successes.map(overload => new TypeOverloadResolutionFailure(overload.type, message))}; >+} >diff --git a/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js b/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >index 9143f8e1e00a049814b90a345c5af451459d8574..0574becd5531509478a2defdc2fe7c68e61c3d35 100644 >--- a/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >+++ b/Tools/WebGPUShadingLanguageRI/ResolveTypeDefs.js >@@ -27,8 +27,13 @@ > function resolveTypeDefsInTypes(program) > { > let resolver = new TypeDefResolver(); >- for (let type of program.types.values()) >- type.visit(resolver); >+ for (let type of program.types.values()) { >+ if (type instanceof Array) { >+ for (let constituentType of type) >+ constituentType.visit(resolver); >+ } else >+ type.visit(resolver); >+ } > } > > function resolveTypeDefsInFunctions(program) >diff --git a/Tools/WebGPUShadingLanguageRI/Rewriter.js b/Tools/WebGPUShadingLanguageRI/Rewriter.js >index d547d203f0dbf8cabee4377803bd5b084e9807bc..bd83c37d9c477717e3523728d15df42790da1b2f 100644 >--- a/Tools/WebGPUShadingLanguageRI/Rewriter.js >+++ b/Tools/WebGPUShadingLanguageRI/Rewriter.js >@@ -97,7 +97,7 @@ class Rewriter { > > visitTypeRef(node) > { >- let result = new TypeRef(node.origin, node.name); >+ let result = new TypeRef(node.origin, node.name, node.typeArguments.map(argument => argument.visit(this))); > if (node.type) > result.type = Node.visit(node.type, this); > return result; >@@ -382,9 +382,14 @@ class Rewriter { > > visitVectorType(node) > { >- const vecType = new VectorType(node.origin, node.name); >- vecType._elementType = node.elementType.visit(this); >+ const vecType = new VectorType(node.origin, node.name, node.typeArguments.map(argument => argument.visit(this))); > return vecType; > } >+ >+ visitMatrixType(node) >+ { >+ const matType = new MatrixType(node.origin, node.name, node.typeArguments.map(argument => argument.visit(this))); >+ return matType; >+ } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/SPIRV.html b/Tools/WebGPUShadingLanguageRI/SPIRV.html >index c7b3940f2b11bd89614f14a9b52c47a56166ab14..352e5f80757ced7cd0395e88890416d56237a477 100644 >--- a/Tools/WebGPUShadingLanguageRI/SPIRV.html >+++ b/Tools/WebGPUShadingLanguageRI/SPIRV.html >@@ -32,8 +32,6 @@ td { > <script src="BuiltinVectorConstructors.js"></script> > <script src="BuiltinVectorGetter.js"></script> > <script src="BuiltinVectorSetter.js"></script> >- <script src="BuiltinVectorIndexGetter.js"></script> >- <script src="BuiltinVectorIndexSetter.js"></script> > <script src="BuiltinVectorEqualityOperator.js"></script> > <script src="CallExpression.js"></script> > <script src="CallFunction.js"></script> >@@ -43,6 +41,7 @@ td { > <script src="CheckRecursion.js"></script> > <script src="CheckRecursiveTypes.js"></script> > <script src="CheckReturns.js"></script> >+ <script src="CheckTypesWithArguments.js"></script> > <script src="CheckUnreachableCode.js"></script> > <script src="CheckWrapped.js"></script> > <script src="Checker.js"></script> >@@ -95,6 +94,7 @@ td { > <script src="LoopChecker.js"></script> > <script src="MakeArrayRefExpression.js"></script> > <script src="MakePtrExpression.js"></script> >+ <script src="MatrixType.js"></script> > <script src="NameContext.js"></script> > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> >@@ -102,9 +102,8 @@ td { > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >- <script src="OperatorAnderIndex.js"></script> >+ <script src="OperatorAnderIndexer.js"></script> > <script src="OperatorArrayRefLength.js"></script> >- <script src="OperatorBool.js"></script> > <script src="OriginKind.js"></script> > <script src="OverloadResolutionFailure.js"></script> > <script src="Parse.js"></script> >@@ -116,7 +115,6 @@ td { > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> > <script src="RecursiveTypeChecker.js"></script> >- <script src="RemoveTypeArguments.js"></script> > <script src="ResolveNames.js"></script> > <script src="ResolveOverloadImpl.js"></script> > <script src="ResolveProperties.js"></script> >@@ -133,13 +131,13 @@ td { > <script src="SynthesizeArrayOperatorLength.js"></script> > <script src="SynthesizeEnumFunctions.js"></script> > <script src="SynthesizeStructAccessors.js"></script> >- <script src="SynthesizeOperatorBool.js"></script> > <script src="SynthesizeCopyConstructorOperator.js"></script> > <script src="SynthesizeDefaultConstructorOperator.js"></script> > <script src="TrapStatement.js"></script> > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeRef.js"></script> >+ <script src="TypeOverloadResolutionFailure.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script> >diff --git a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >index 06b251cf0a24819cab5065ef5445e1489d5eaafc..2ba460c0c5689c583dc708487deebeb0dfa348cd 100644 >--- a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >+++ b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >@@ -33,52 +33,643 @@ let standardLibrary = ` > native typedef void; > native typedef bool; > native typedef uchar; >+native typedef ushort; > native typedef uint; >+native typedef char; >+native typedef short; > native typedef int; >+native typedef half; > native typedef float; >+native typedef atomic_int; >+native typedef atomic_uint; > >-// FIXME: Add support for these types to Intrinsics.js >-// native typedef ushort; >-// native typedef char; >-// native typedef short; >-// native typedef half; >-// native typedef atomic_int; >-// native typedef atomic_uint; >+native typedef vector<bool, 2>; >+typedef bool2 = vector<bool, 2>; >+native typedef vector<bool, 3>; >+typedef bool3 = vector<bool, 3>; >+native typedef vector<bool, 4>; >+typedef bool4 = vector<bool, 4>; >+native typedef vector<uchar, 2>; >+typedef uchar2 = vector<uchar, 2>; >+native typedef vector<uchar, 3>; >+typedef uchar3 = vector<uchar, 3>; >+native typedef vector<uchar, 4>; >+typedef uchar4 = vector<uchar, 4>; >+native typedef vector<ushort, 2>; >+typedef ushort2 = vector<ushort, 2>; >+native typedef vector<ushort, 3>; >+typedef ushort3 = vector<ushort, 3>; >+native typedef vector<ushort, 4>; >+typedef ushort4 = vector<ushort, 4>; >+native typedef vector<uint, 2>; >+typedef uint2 = vector<uint, 2>; >+native typedef vector<uint, 3>; >+typedef uint3 = vector<uint, 3>; >+native typedef vector<uint, 4>; >+typedef uint4 = vector<uint, 4>; >+native typedef vector<char, 2>; >+typedef char2 = vector<char, 2>; >+native typedef vector<char, 3>; >+typedef char3 = vector<char, 3>; >+native typedef vector<char, 4>; >+typedef char4 = vector<char, 4>; >+native typedef vector<short, 2>; >+typedef short2 = vector<short, 2>; >+native typedef vector<short, 3>; >+typedef short3 = vector<short, 3>; >+native typedef vector<short, 4>; >+typedef short4 = vector<short, 4>; >+native typedef vector<int, 2>; >+typedef int2 = vector<int, 2>; >+native typedef vector<int, 3>; >+typedef int3 = vector<int, 3>; >+native typedef vector<int, 4>; >+typedef int4 = vector<int, 4>; >+native typedef vector<half, 2>; >+typedef half2 = vector<half, 2>; >+native typedef vector<half, 3>; >+typedef half3 = vector<half, 3>; >+native typedef vector<half, 4>; >+typedef half4 = vector<half, 4>; >+native typedef vector<float, 2>; >+typedef float2 = vector<float, 2>; >+native typedef vector<float, 3>; >+typedef float3 = vector<float, 3>; >+native typedef vector<float, 4>; >+typedef float4 = vector<float, 4>; > >-native operator int(uint); >-native operator int(uchar); >-native operator int(float); >-native operator uint(int); >-native operator uint(uchar); >-native operator uint(float); >-native operator uchar(int); >+native typedef matrix<half, 2, 2>; >+typedef half2x2 = matrix<half, 2, 2>; >+native typedef matrix<half, 2, 3>; >+typedef half2x3 = matrix<half, 2, 3>; >+native typedef matrix<half, 2, 4>; >+typedef half2x4 = matrix<half, 2, 4>; >+native typedef matrix<half, 3, 2>; >+typedef half3x2 = matrix<half, 3, 2>; >+native typedef matrix<half, 3, 3>; >+typedef half3x3 = matrix<half, 3, 3>; >+native typedef matrix<half, 3, 4>; >+typedef half3x4 = matrix<half, 3, 4>; >+native typedef matrix<half, 4, 2>; >+typedef half4x2 = matrix<half, 4, 2>; >+native typedef matrix<half, 4, 3>; >+typedef half4x3 = matrix<half, 4, 3>; >+native typedef matrix<half, 4, 4>; >+typedef half4x4 = matrix<half, 4, 4>; >+native typedef matrix<float, 2, 2>; >+typedef float2x2 = matrix<float, 2, 2>; >+native typedef matrix<float, 2, 3>; >+typedef float2x3 = matrix<float, 2, 3>; >+native typedef matrix<float, 2, 4>; >+typedef float2x4 = matrix<float, 2, 4>; >+native typedef matrix<float, 3, 2>; >+typedef float3x2 = matrix<float, 3, 2>; >+native typedef matrix<float, 3, 3>; >+typedef float3x3 = matrix<float, 3, 3>; >+native typedef matrix<float, 3, 4>; >+typedef float3x4 = matrix<float, 3, 4>; >+native typedef matrix<float, 4, 2>; >+typedef float4x2 = matrix<float, 4, 2>; >+native typedef matrix<float, 4, 3>; >+typedef float4x3 = matrix<float, 4, 3>; >+native typedef matrix<float, 4, 4>; >+typedef float4x4 = matrix<float, 4, 4>; >+ >+native typedef sampler; >+native typedef Texture1D<bool>; >+native typedef Texture1D<bool2>; >+native typedef Texture1D<bool3>; >+native typedef Texture1D<bool4>; >+native typedef Texture1D<uchar>; >+native typedef Texture1D<uchar2>; >+native typedef Texture1D<uchar3>; >+native typedef Texture1D<uchar4>; >+native typedef Texture1D<ushort>; >+native typedef Texture1D<ushort2>; >+native typedef Texture1D<ushort3>; >+native typedef Texture1D<ushort4>; >+native typedef Texture1D<uint>; >+native typedef Texture1D<uint2>; >+native typedef Texture1D<uint3>; >+native typedef Texture1D<uint4>; >+native typedef Texture1D<char>; >+native typedef Texture1D<char2>; >+native typedef Texture1D<char3>; >+native typedef Texture1D<char4>; >+native typedef Texture1D<short>; >+native typedef Texture1D<short2>; >+native typedef Texture1D<short3>; >+native typedef Texture1D<short4>; >+native typedef Texture1D<int>; >+native typedef Texture1D<int2>; >+native typedef Texture1D<int3>; >+native typedef Texture1D<int4>; >+native typedef Texture1D<half>; >+native typedef Texture1D<half2>; >+native typedef Texture1D<half3>; >+native typedef Texture1D<half4>; >+native typedef Texture1D<float>; >+native typedef Texture1D<float2>; >+native typedef Texture1D<float3>; >+native typedef Texture1D<float4>; >+native typedef RWTexture1D<bool>; >+native typedef RWTexture1D<bool2>; >+native typedef RWTexture1D<bool3>; >+native typedef RWTexture1D<bool4>; >+native typedef RWTexture1D<uchar>; >+native typedef RWTexture1D<uchar2>; >+native typedef RWTexture1D<uchar3>; >+native typedef RWTexture1D<uchar4>; >+native typedef RWTexture1D<ushort>; >+native typedef RWTexture1D<ushort2>; >+native typedef RWTexture1D<ushort3>; >+native typedef RWTexture1D<ushort4>; >+native typedef RWTexture1D<uint>; >+native typedef RWTexture1D<uint2>; >+native typedef RWTexture1D<uint3>; >+native typedef RWTexture1D<uint4>; >+native typedef RWTexture1D<char>; >+native typedef RWTexture1D<char2>; >+native typedef RWTexture1D<char3>; >+native typedef RWTexture1D<char4>; >+native typedef RWTexture1D<short>; >+native typedef RWTexture1D<short2>; >+native typedef RWTexture1D<short3>; >+native typedef RWTexture1D<short4>; >+native typedef RWTexture1D<int>; >+native typedef RWTexture1D<int2>; >+native typedef RWTexture1D<int3>; >+native typedef RWTexture1D<int4>; >+native typedef RWTexture1D<half>; >+native typedef RWTexture1D<half2>; >+native typedef RWTexture1D<half3>; >+native typedef RWTexture1D<half4>; >+native typedef RWTexture1D<float>; >+native typedef RWTexture1D<float2>; >+native typedef RWTexture1D<float3>; >+native typedef RWTexture1D<float4>; >+native typedef Texture1DArray<bool>; >+native typedef Texture1DArray<bool2>; >+native typedef Texture1DArray<bool3>; >+native typedef Texture1DArray<bool4>; >+native typedef Texture1DArray<uchar>; >+native typedef Texture1DArray<uchar2>; >+native typedef Texture1DArray<uchar3>; >+native typedef Texture1DArray<uchar4>; >+native typedef Texture1DArray<ushort>; >+native typedef Texture1DArray<ushort2>; >+native typedef Texture1DArray<ushort3>; >+native typedef Texture1DArray<ushort4>; >+native typedef Texture1DArray<uint>; >+native typedef Texture1DArray<uint2>; >+native typedef Texture1DArray<uint3>; >+native typedef Texture1DArray<uint4>; >+native typedef Texture1DArray<char>; >+native typedef Texture1DArray<char2>; >+native typedef Texture1DArray<char3>; >+native typedef Texture1DArray<char4>; >+native typedef Texture1DArray<short>; >+native typedef Texture1DArray<short2>; >+native typedef Texture1DArray<short3>; >+native typedef Texture1DArray<short4>; >+native typedef Texture1DArray<int>; >+native typedef Texture1DArray<int2>; >+native typedef Texture1DArray<int3>; >+native typedef Texture1DArray<int4>; >+native typedef Texture1DArray<half>; >+native typedef Texture1DArray<half2>; >+native typedef Texture1DArray<half3>; >+native typedef Texture1DArray<half4>; >+native typedef Texture1DArray<float>; >+native typedef Texture1DArray<float2>; >+native typedef Texture1DArray<float3>; >+native typedef Texture1DArray<float4>; >+native typedef RWTexture1DArray<bool>; >+native typedef RWTexture1DArray<bool2>; >+native typedef RWTexture1DArray<bool3>; >+native typedef RWTexture1DArray<bool4>; >+native typedef RWTexture1DArray<uchar>; >+native typedef RWTexture1DArray<uchar2>; >+native typedef RWTexture1DArray<uchar3>; >+native typedef RWTexture1DArray<uchar4>; >+native typedef RWTexture1DArray<ushort>; >+native typedef RWTexture1DArray<ushort2>; >+native typedef RWTexture1DArray<ushort3>; >+native typedef RWTexture1DArray<ushort4>; >+native typedef RWTexture1DArray<uint>; >+native typedef RWTexture1DArray<uint2>; >+native typedef RWTexture1DArray<uint3>; >+native typedef RWTexture1DArray<uint4>; >+native typedef RWTexture1DArray<char>; >+native typedef RWTexture1DArray<char2>; >+native typedef RWTexture1DArray<char3>; >+native typedef RWTexture1DArray<char4>; >+native typedef RWTexture1DArray<short>; >+native typedef RWTexture1DArray<short2>; >+native typedef RWTexture1DArray<short3>; >+native typedef RWTexture1DArray<short4>; >+native typedef RWTexture1DArray<int>; >+native typedef RWTexture1DArray<int2>; >+native typedef RWTexture1DArray<int3>; >+native typedef RWTexture1DArray<int4>; >+native typedef RWTexture1DArray<half>; >+native typedef RWTexture1DArray<half2>; >+native typedef RWTexture1DArray<half3>; >+native typedef RWTexture1DArray<half4>; >+native typedef RWTexture1DArray<float>; >+native typedef RWTexture1DArray<float2>; >+native typedef RWTexture1DArray<float3>; >+native typedef RWTexture1DArray<float4>; >+native typedef Texture2D<bool>; >+native typedef Texture2D<bool2>; >+native typedef Texture2D<bool3>; >+native typedef Texture2D<bool4>; >+native typedef Texture2D<uchar>; >+native typedef Texture2D<uchar2>; >+native typedef Texture2D<uchar3>; >+native typedef Texture2D<uchar4>; >+native typedef Texture2D<ushort>; >+native typedef Texture2D<ushort2>; >+native typedef Texture2D<ushort3>; >+native typedef Texture2D<ushort4>; >+native typedef Texture2D<uint>; >+native typedef Texture2D<uint2>; >+native typedef Texture2D<uint3>; >+native typedef Texture2D<uint4>; >+native typedef Texture2D<char>; >+native typedef Texture2D<char2>; >+native typedef Texture2D<char3>; >+native typedef Texture2D<char4>; >+native typedef Texture2D<short>; >+native typedef Texture2D<short2>; >+native typedef Texture2D<short3>; >+native typedef Texture2D<short4>; >+native typedef Texture2D<int>; >+native typedef Texture2D<int2>; >+native typedef Texture2D<int3>; >+native typedef Texture2D<int4>; >+native typedef Texture2D<half>; >+native typedef Texture2D<half2>; >+native typedef Texture2D<half3>; >+native typedef Texture2D<half4>; >+native typedef Texture2D<float>; >+native typedef Texture2D<float2>; >+native typedef Texture2D<float3>; >+native typedef Texture2D<float4>; >+native typedef RWTexture2D<bool>; >+native typedef RWTexture2D<bool2>; >+native typedef RWTexture2D<bool3>; >+native typedef RWTexture2D<bool4>; >+native typedef RWTexture2D<uchar>; >+native typedef RWTexture2D<uchar2>; >+native typedef RWTexture2D<uchar3>; >+native typedef RWTexture2D<uchar4>; >+native typedef RWTexture2D<ushort>; >+native typedef RWTexture2D<ushort2>; >+native typedef RWTexture2D<ushort3>; >+native typedef RWTexture2D<ushort4>; >+native typedef RWTexture2D<uint>; >+native typedef RWTexture2D<uint2>; >+native typedef RWTexture2D<uint3>; >+native typedef RWTexture2D<uint4>; >+native typedef RWTexture2D<char>; >+native typedef RWTexture2D<char2>; >+native typedef RWTexture2D<char3>; >+native typedef RWTexture2D<char4>; >+native typedef RWTexture2D<short>; >+native typedef RWTexture2D<short2>; >+native typedef RWTexture2D<short3>; >+native typedef RWTexture2D<short4>; >+native typedef RWTexture2D<int>; >+native typedef RWTexture2D<int2>; >+native typedef RWTexture2D<int3>; >+native typedef RWTexture2D<int4>; >+native typedef RWTexture2D<half>; >+native typedef RWTexture2D<half2>; >+native typedef RWTexture2D<half3>; >+native typedef RWTexture2D<half4>; >+native typedef RWTexture2D<float>; >+native typedef RWTexture2D<float2>; >+native typedef RWTexture2D<float3>; >+native typedef RWTexture2D<float4>; >+native typedef Texture2DArray<bool>; >+native typedef Texture2DArray<bool2>; >+native typedef Texture2DArray<bool3>; >+native typedef Texture2DArray<bool4>; >+native typedef Texture2DArray<uchar>; >+native typedef Texture2DArray<uchar2>; >+native typedef Texture2DArray<uchar3>; >+native typedef Texture2DArray<uchar4>; >+native typedef Texture2DArray<ushort>; >+native typedef Texture2DArray<ushort2>; >+native typedef Texture2DArray<ushort3>; >+native typedef Texture2DArray<ushort4>; >+native typedef Texture2DArray<uint>; >+native typedef Texture2DArray<uint2>; >+native typedef Texture2DArray<uint3>; >+native typedef Texture2DArray<uint4>; >+native typedef Texture2DArray<char>; >+native typedef Texture2DArray<char2>; >+native typedef Texture2DArray<char3>; >+native typedef Texture2DArray<char4>; >+native typedef Texture2DArray<short>; >+native typedef Texture2DArray<short2>; >+native typedef Texture2DArray<short3>; >+native typedef Texture2DArray<short4>; >+native typedef Texture2DArray<int>; >+native typedef Texture2DArray<int2>; >+native typedef Texture2DArray<int3>; >+native typedef Texture2DArray<int4>; >+native typedef Texture2DArray<half>; >+native typedef Texture2DArray<half2>; >+native typedef Texture2DArray<half3>; >+native typedef Texture2DArray<half4>; >+native typedef Texture2DArray<float>; >+native typedef Texture2DArray<float2>; >+native typedef Texture2DArray<float3>; >+native typedef Texture2DArray<float4>; >+native typedef RWTexture2DArray<bool>; >+native typedef RWTexture2DArray<bool2>; >+native typedef RWTexture2DArray<bool3>; >+native typedef RWTexture2DArray<bool4>; >+native typedef RWTexture2DArray<uchar>; >+native typedef RWTexture2DArray<uchar2>; >+native typedef RWTexture2DArray<uchar3>; >+native typedef RWTexture2DArray<uchar4>; >+native typedef RWTexture2DArray<ushort>; >+native typedef RWTexture2DArray<ushort2>; >+native typedef RWTexture2DArray<ushort3>; >+native typedef RWTexture2DArray<ushort4>; >+native typedef RWTexture2DArray<uint>; >+native typedef RWTexture2DArray<uint2>; >+native typedef RWTexture2DArray<uint3>; >+native typedef RWTexture2DArray<uint4>; >+native typedef RWTexture2DArray<char>; >+native typedef RWTexture2DArray<char2>; >+native typedef RWTexture2DArray<char3>; >+native typedef RWTexture2DArray<char4>; >+native typedef RWTexture2DArray<short>; >+native typedef RWTexture2DArray<short2>; >+native typedef RWTexture2DArray<short3>; >+native typedef RWTexture2DArray<short4>; >+native typedef RWTexture2DArray<int>; >+native typedef RWTexture2DArray<int2>; >+native typedef RWTexture2DArray<int3>; >+native typedef RWTexture2DArray<int4>; >+native typedef RWTexture2DArray<half>; >+native typedef RWTexture2DArray<half2>; >+native typedef RWTexture2DArray<half3>; >+native typedef RWTexture2DArray<half4>; >+native typedef RWTexture2DArray<float>; >+native typedef RWTexture2DArray<float2>; >+native typedef RWTexture2DArray<float3>; >+native typedef RWTexture2DArray<float4>; >+native typedef Texture3D<bool>; >+native typedef Texture3D<bool2>; >+native typedef Texture3D<bool3>; >+native typedef Texture3D<bool4>; >+native typedef Texture3D<uchar>; >+native typedef Texture3D<uchar2>; >+native typedef Texture3D<uchar3>; >+native typedef Texture3D<uchar4>; >+native typedef Texture3D<ushort>; >+native typedef Texture3D<ushort2>; >+native typedef Texture3D<ushort3>; >+native typedef Texture3D<ushort4>; >+native typedef Texture3D<uint>; >+native typedef Texture3D<uint2>; >+native typedef Texture3D<uint3>; >+native typedef Texture3D<uint4>; >+native typedef Texture3D<char>; >+native typedef Texture3D<char2>; >+native typedef Texture3D<char3>; >+native typedef Texture3D<char4>; >+native typedef Texture3D<short>; >+native typedef Texture3D<short2>; >+native typedef Texture3D<short3>; >+native typedef Texture3D<short4>; >+native typedef Texture3D<int>; >+native typedef Texture3D<int2>; >+native typedef Texture3D<int3>; >+native typedef Texture3D<int4>; >+native typedef Texture3D<half>; >+native typedef Texture3D<half2>; >+native typedef Texture3D<half3>; >+native typedef Texture3D<half4>; >+native typedef Texture3D<float>; >+native typedef Texture3D<float2>; >+native typedef Texture3D<float3>; >+native typedef Texture3D<float4>; >+native typedef RWTexture3D<bool>; >+native typedef RWTexture3D<bool2>; >+native typedef RWTexture3D<bool3>; >+native typedef RWTexture3D<bool4>; >+native typedef RWTexture3D<uchar>; >+native typedef RWTexture3D<uchar2>; >+native typedef RWTexture3D<uchar3>; >+native typedef RWTexture3D<uchar4>; >+native typedef RWTexture3D<ushort>; >+native typedef RWTexture3D<ushort2>; >+native typedef RWTexture3D<ushort3>; >+native typedef RWTexture3D<ushort4>; >+native typedef RWTexture3D<uint>; >+native typedef RWTexture3D<uint2>; >+native typedef RWTexture3D<uint3>; >+native typedef RWTexture3D<uint4>; >+native typedef RWTexture3D<char>; >+native typedef RWTexture3D<char2>; >+native typedef RWTexture3D<char3>; >+native typedef RWTexture3D<char4>; >+native typedef RWTexture3D<short>; >+native typedef RWTexture3D<short2>; >+native typedef RWTexture3D<short3>; >+native typedef RWTexture3D<short4>; >+native typedef RWTexture3D<int>; >+native typedef RWTexture3D<int2>; >+native typedef RWTexture3D<int3>; >+native typedef RWTexture3D<int4>; >+native typedef RWTexture3D<half>; >+native typedef RWTexture3D<half2>; >+native typedef RWTexture3D<half3>; >+native typedef RWTexture3D<half4>; >+native typedef RWTexture3D<float>; >+native typedef RWTexture3D<float2>; >+native typedef RWTexture3D<float3>; >+native typedef RWTexture3D<float4>; >+native typedef TextureCube<bool>; >+native typedef TextureCube<bool2>; >+native typedef TextureCube<bool3>; >+native typedef TextureCube<bool4>; >+native typedef TextureCube<uchar>; >+native typedef TextureCube<uchar2>; >+native typedef TextureCube<uchar3>; >+native typedef TextureCube<uchar4>; >+native typedef TextureCube<ushort>; >+native typedef TextureCube<ushort2>; >+native typedef TextureCube<ushort3>; >+native typedef TextureCube<ushort4>; >+native typedef TextureCube<uint>; >+native typedef TextureCube<uint2>; >+native typedef TextureCube<uint3>; >+native typedef TextureCube<uint4>; >+native typedef TextureCube<char>; >+native typedef TextureCube<char2>; >+native typedef TextureCube<char3>; >+native typedef TextureCube<char4>; >+native typedef TextureCube<short>; >+native typedef TextureCube<short2>; >+native typedef TextureCube<short3>; >+native typedef TextureCube<short4>; >+native typedef TextureCube<int>; >+native typedef TextureCube<int2>; >+native typedef TextureCube<int3>; >+native typedef TextureCube<int4>; >+native typedef TextureCube<half>; >+native typedef TextureCube<half2>; >+native typedef TextureCube<half3>; >+native typedef TextureCube<half4>; >+native typedef TextureCube<float>; >+native typedef TextureCube<float2>; >+native typedef TextureCube<float3>; >+native typedef TextureCube<float4>; >+native typedef TextureDepth2D<float>; >+native typedef TextureDepth2D<half>; >+native typedef RWTextureDepth2D<float>; >+native typedef RWTextureDepth2D<half>; >+native typedef TextureDepth2DArray<float>; >+native typedef TextureDepth2DArray<half>; >+native typedef RWTextureDepth2DArray<float>; >+native typedef RWTextureDepth2DArray<half>; >+native typedef TextureDepthCube<float>; >+native typedef TextureDepthCube<half>; >+ >+native operator uchar(ushort); > native operator uchar(uint); >+native operator uchar(char); >+native operator uchar(short); >+native operator uchar(int); >+native operator uchar(half); > native operator uchar(float); >-native operator float(int); >-native operator float(uint); >+native operator ushort(uchar); >+native operator ushort(uint); >+native operator ushort(char); >+native operator ushort(short); >+native operator ushort(int); >+native operator ushort(half); >+native operator ushort(float); >+native operator uint(uchar); >+native operator uint(ushort); >+native operator uint(char); >+native operator uint(short); >+native operator uint(int); >+native operator uint(half); >+native operator uint(float); >+native operator char(uchar); >+native operator char(ushort); >+native operator char(uint); >+native operator char(short); >+native operator char(int); >+native operator char(half); >+native operator char(float); >+native operator short(uchar); >+native operator short(ushort); >+native operator short(uint); >+native operator short(char); >+native operator short(int); >+native operator short(half); >+native operator short(float); >+native operator int(uchar); >+native operator int(ushort); >+native operator int(uint); >+native operator int(char); >+native operator int(short); >+native operator int(half); >+native operator int(float); >+native operator half(uchar); >+native operator half(ushort); >+native operator half(uint); >+native operator half(char); >+native operator half(short); >+native operator half(int); >+native operator half(float); > native operator float(uchar); >+native operator float(ushort); >+native operator float(uint); >+native operator float(char); >+native operator float(short); >+native operator float(int); >+native operator float(half); >+ >+operator bool(uchar x) { >+ return x != 0; >+} >+operator bool(ushort x) { >+ return x != 0; >+} >+operator bool(uint x) { >+ return x != 0; >+} >+operator bool(char x) { >+ return x != 0; >+} >+operator bool(short x) { >+ return x != 0; >+} >+operator bool(int x) { >+ return x != 0; >+} >+operator bool(half x) { >+ return x != 0; >+} >+operator bool(float x) { >+ return x != 0; >+} >+ >+native operator int(atomic_int); >+native operator uint(atomic_uint); > >+native bool operator==(bool, bool); >+bool operator&(bool a, bool b) { >+ return a && b; >+} >+bool operator|(bool a, bool b) { >+ return a || b; >+} >+bool operator^(bool a, bool b) { >+ if (a) >+ return !b; >+ return b; >+} >+bool operator~(bool value) { >+ return !value; >+} > native int operator+(int, int); >-native uint operator+(uint, uint); >-uchar operator+(uchar a, uchar b) { return uchar(uint(a) + uint(b)); } >-native float operator+(float, float); >-int operator++(int value) { return value + 1; } >-uint operator++(uint value) { return value + 1; } >-uchar operator++(uchar value) { return value + 1; } > native int operator-(int, int); >-native uint operator-(uint, uint); >-uchar operator-(uchar a, uchar b) { return uchar(uint(a) - uint(b)); } >-native float operator-(float, float); >-int operator--(int value) { return value - 1; } >-uint operator--(uint value) { return value - 1; } >-uchar operator--(uchar value) { return value - 1; } > native int operator*(int, int); >-native uint operator*(uint, uint); >-uchar operator*(uchar a, uchar b) { return uchar(uint(a) * uint(b)); } >-native float operator*(float, float); > native int operator/(int, int); >+native bool operator==(int, int); >+native bool operator<(int, int); >+native bool operator<=(int, int); >+native bool operator>(int, int); >+native bool operator>=(int, int); >+native uint operator+(uint, uint); >+native uint operator-(uint, uint); >+native uint operator*(uint, uint); > native uint operator/(uint, uint); >-uchar operator/(uchar a, uchar b) { return uchar(uint(a) / uint(b)); } >+native bool operator==(uint, uint); >+native bool operator<(uint, uint); >+native bool operator<=(uint, uint); >+native bool operator>(uint, uint); >+native bool operator>=(uint, uint); >+native float operator+(float, float); >+native float operator-(float, float); >+native float operator*(float, float); >+native float operator/(float, float); >+native bool operator==(float, float); >+native bool operator<(float, float); >+native bool operator<=(float, float); >+native bool operator>(float, float); >+native bool operator>=(float, float); > native int operator&(int, int); > native int operator|(int, int); > native int operator^(int, int); >@@ -91,84 +682,2575 @@ native uint operator^(uint, uint); > native uint operator~(uint); > native uint operator<<(uint, uint); > native uint operator>>(uint, uint); >-uchar operator&(uchar a, uchar b) { return uchar(uint(a) & uint(b)); } >-uchar operator|(uchar a, uchar b) { return uchar(uint(a) | uint(b)); } >-uchar operator^(uchar a, uchar b) { return uchar(uint(a) ^ uint(b)); } >-uchar operator~(uchar value) { return uchar(~uint(value)); } >-uchar operator<<(uchar a, uint b) { return uchar(uint(a) << (b & 7)); } >-uchar operator>>(uchar a, uint b) { return uchar(uint(a) >> (b & 7)); } >-native float operator/(float, float); >-native bool operator==(int, int); >-native bool operator==(uint, uint); >-bool operator==(uchar a, uchar b) { return uint(a) == uint(b); } >-native bool operator==(bool, bool); >-native bool operator==(float, float); >-native bool operator<(int, int); >-native bool operator<(uint, uint); >-bool operator<(uchar a, uchar b) { return uint(a) < uint(b); } >-native bool operator<(float, float); >-native bool operator<=(int, int); >-native bool operator<=(uint, uint); >-bool operator<=(uchar a, uchar b) { return uint(a) <= uint(b); } >-native bool operator<=(float, float); >-native bool operator>(int, int); >-native bool operator>(uint, uint); >-bool operator>(uchar a, uchar b) { return uint(a) > uint(b); } >-native bool operator>(float, float); >-native bool operator>=(int, int); >-native bool operator>=(uint, uint); >-bool operator>=(uchar a, uchar b) { return uint(a) >= uint(b); } >-native bool operator>=(float, float); >- >-bool operator&(bool a, bool b) >-{ >- if (a) >- return b; >- return false; >+uchar operator+(uchar a, uchar b) { >+ return uchar(uint(a) + uint(b)); > } >- >-bool operator|(bool a, bool b) >-{ >- if (a) >- return true; >- if (b) >- return true; >- return false; >+uchar operator-(uchar a, uchar b) { >+ return uchar(uint(a) - uint(b)); > } >- >-bool operator^(bool a, bool b) >-{ >- if (a) >- return !b; >- return b; >+uchar operator*(uchar a, uchar b) { >+ return uchar(uint(a) * uint(b)); > } >- >-bool operator~(bool value) >-{ >- return !value; >+uchar operator/(uchar a, uchar b) { >+ return uchar(uint(a) / uint(b)); > } >+uchar operator&(uchar a, uchar b) { >+ return uchar(uint(a) & uint(b)); >+} >+uchar operator|(uchar a, uchar b) { >+ return uchar(uint(a) | uint(b)); >+} >+uchar operator^(uchar a, uchar b) { >+ return uchar(uint(a) ^ uint(b)); >+} >+uchar operator~(uchar a) { >+ return uchar(~uint(a)); >+} >+bool operator==(uchar a, uchar b) { >+ return uint(a) == uint(b); >+} >+bool operator<(uchar a, uchar b) { >+ return uint(a) < uint(b); >+} >+bool operator<=(uchar a, uchar b) { >+ return uint(a) <= uint(b); >+} >+bool operator>(uchar a, uchar b) { >+ return uint(a) > uint(b); >+} >+bool operator>=(uchar a, uchar b) { >+ return uint(a) >= uint(b); >+} >+ushort operator+(ushort a, ushort b) { >+ return ushort(uint(a) + uint(b)); >+} >+ushort operator-(ushort a, ushort b) { >+ return ushort(uint(a) - uint(b)); >+} >+ushort operator*(ushort a, ushort b) { >+ return ushort(uint(a) * uint(b)); >+} >+ushort operator/(ushort a, ushort b) { >+ return ushort(uint(a) / uint(b)); >+} >+ushort operator&(ushort a, ushort b) { >+ return ushort(uint(a) & uint(b)); >+} >+ushort operator|(ushort a, ushort b) { >+ return ushort(uint(a) | uint(b)); >+} >+ushort operator^(ushort a, ushort b) { >+ return ushort(uint(a) ^ uint(b)); >+} >+ushort operator~(ushort a) { >+ return ushort(~uint(a)); >+} >+bool operator==(ushort a, ushort b) { >+ return uint(a) == uint(b); >+} >+bool operator<(ushort a, ushort b) { >+ return uint(a) < uint(b); >+} >+bool operator<=(ushort a, ushort b) { >+ return uint(a) <= uint(b); >+} >+bool operator>(ushort a, ushort b) { >+ return uint(a) > uint(b); >+} >+bool operator>=(ushort a, ushort b) { >+ return uint(a) >= uint(b); >+} >+uchar operator<<(uchar a, uint b) { >+ return uchar(uint(a) << (b & 255)); >+} >+ushort operator<<(ushort a, uint b) { >+ return ushort(uint(a) << (b & 65535)); >+} >+uchar operator>>(uchar a, uint b) { >+ return uchar(uint(a) >> (b & 255)); >+} >+ushort operator>>(ushort a, uint b) { >+ return ushort(uint(a) >> (b & 65535)); >+} >+char operator+(char a, char b) { >+ return char(int(a) + int(b)); >+} >+char operator-(char a, char b) { >+ return char(int(a) - int(b)); >+} >+char operator*(char a, char b) { >+ return char(int(a) * int(b)); >+} >+char operator/(char a, char b) { >+ return char(int(a) / int(b)); >+} >+char operator&(char a, char b) { >+ return char(int(a) & int(b)); >+} >+char operator|(char a, char b) { >+ return char(int(a) | int(b)); >+} >+char operator^(char a, char b) { >+ return char(int(a) ^ int(b)); >+} >+char operator~(char a) { >+ return char(~int(a)); >+} >+bool operator==(char a, char b) { >+ return int(a) == int(b); >+} >+bool operator>(char a, char b) { >+ return int(a) > int(b); >+} >+bool operator>=(char a, char b) { >+ return int(a) >= int(b); >+} >+bool operator<(char a, char b) { >+ return int(a) < int(b); >+} >+bool operator<=(char a, char b) { >+ return int(a) <= int(b); >+} >+short operator+(short a, short b) { >+ return short(int(a) + int(b)); >+} >+short operator-(short a, short b) { >+ return short(int(a) - int(b)); >+} >+short operator*(short a, short b) { >+ return short(int(a) * int(b)); >+} >+short operator/(short a, short b) { >+ return short(int(a) / int(b)); >+} >+short operator&(short a, short b) { >+ return short(int(a) & int(b)); >+} >+short operator|(short a, short b) { >+ return short(int(a) | int(b)); >+} >+short operator^(short a, short b) { >+ return short(int(a) ^ int(b)); >+} >+short operator~(short a) { >+ return short(~int(a)); >+} >+bool operator==(short a, short b) { >+ return int(a) == int(b); >+} >+bool operator>(short a, short b) { >+ return int(a) > int(b); >+} >+bool operator>=(short a, short b) { >+ return int(a) >= int(b); >+} >+bool operator<(short a, short b) { >+ return int(a) < int(b); >+} >+bool operator<=(short a, short b) { >+ return int(a) <= int(b); >+} >+char operator<<(char a, uint b) { >+ return char(int(a) << (b & 255)); >+} >+short operator<<(short a, uint b) { >+ return short(int(a) << (b & 65535)); >+} >+char operator>>(char a, uint b) { >+ return char(int(a) >> (b & 255)); >+} >+short operator>>(short a, uint b) { >+ return short(int(a) >> (b & 65535)); >+} >+uchar operator++(uchar value) { >+ return value + 1; >+} >+uchar operator--(uchar value) { >+ return value - 1; >+} >+ushort operator++(ushort value) { >+ return value + 1; >+} >+ushort operator--(ushort value) { >+ return value - 1; >+} >+uint operator++(uint value) { >+ return value + 1; >+} >+uint operator--(uint value) { >+ return value - 1; >+} >+char operator++(char value) { >+ return value + 1; >+} >+char operator--(char value) { >+ return value - 1; >+} >+short operator++(short value) { >+ return value + 1; >+} >+short operator--(short value) { >+ return value - 1; >+} >+int operator++(int value) { >+ return value + 1; >+} >+int operator--(int value) { >+ return value - 1; >+} >+half operator++(half value) { >+ return value + 1; >+} >+half operator--(half value) { >+ return value - 1; >+} >+float operator++(float value) { >+ return value + 1; >+} >+float operator--(float value) { >+ return value - 1; >+} >+half operator+(half a, half b) { >+ return half(float(a) + float(b)); >+} >+half operator-(half a, half b) { >+ return half(float(a) - float(b)); >+} >+half operator*(half a, half b) { >+ return half(float(a) * float(b)); >+} >+half operator/(half a, half b) { >+ return half(float(a) / float(b)); >+} >+bool operator==(half a, half b) { >+ return float(a) == float(b); >+} >+bool operator<(half a, half b) { >+ return float(a) < float(b); >+} >+bool operator<=(half a, half b) { >+ return float(a) <= float(b); >+} >+bool operator>(half a, half b) { >+ return float(a) < float(b); >+} >+bool operator>=(half a, half b) { >+ return float(a) <= float(b); >+} >+char operator-(char x) { >+ return char(-int(x)); >+} >+short operator-(short x) { >+ return short(-int(x)); >+} >+half operator-(half x) { >+ return half(-float(x)); >+} >+native int operator-(int); >+native float operator-(float); > >-native typedef uchar2; >-native typedef uchar3; >-native typedef uchar4; >- >-native typedef uint2; >-native typedef uint3; >-native typedef uint4; >+uchar2 operator+(uchar2 a, uchar2 b) { >+ uchar2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+uchar2 operator-(uchar2 a, uchar2 b) { >+ uchar2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+uchar2 operator*(uchar2 a, uchar2 b) { >+ uchar2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+uchar2 operator*(uchar2 a, uchar b) { >+ uchar2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+uchar2 operator*(uchar a, uchar2 b) { >+ uchar2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+uchar2 operator/(uchar2 a, uchar2 b) { >+ uchar2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+uchar2 operator/(uchar2 a, uchar b) { >+ uchar2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+uchar2 operator/(uchar a, uchar2 b) { >+ uchar2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+uchar3 operator+(uchar3 a, uchar3 b) { >+ uchar3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+uchar3 operator-(uchar3 a, uchar3 b) { >+ uchar3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+uchar3 operator*(uchar3 a, uchar3 b) { >+ uchar3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+uchar3 operator*(uchar3 a, uchar b) { >+ uchar3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+uchar3 operator*(uchar a, uchar3 b) { >+ uchar3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+uchar3 operator/(uchar3 a, uchar3 b) { >+ uchar3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+uchar3 operator/(uchar3 a, uchar b) { >+ uchar3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+uchar3 operator/(uchar a, uchar3 b) { >+ uchar3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+uchar4 operator+(uchar4 a, uchar4 b) { >+ uchar4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+uchar4 operator-(uchar4 a, uchar4 b) { >+ uchar4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+uchar4 operator*(uchar4 a, uchar4 b) { >+ uchar4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+uchar4 operator*(uchar4 a, uchar b) { >+ uchar4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+uchar4 operator*(uchar a, uchar4 b) { >+ uchar4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+uchar4 operator/(uchar4 a, uchar4 b) { >+ uchar4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+uchar4 operator/(uchar4 a, uchar b) { >+ uchar4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+uchar4 operator/(uchar a, uchar4 b) { >+ uchar4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+ushort2 operator+(ushort2 a, ushort2 b) { >+ ushort2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+ushort2 operator-(ushort2 a, ushort2 b) { >+ ushort2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+ushort2 operator*(ushort2 a, ushort2 b) { >+ ushort2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+ushort2 operator*(ushort2 a, ushort b) { >+ ushort2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+ushort2 operator*(ushort a, ushort2 b) { >+ ushort2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+ushort2 operator/(ushort2 a, ushort2 b) { >+ ushort2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+ushort2 operator/(ushort2 a, ushort b) { >+ ushort2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+ushort2 operator/(ushort a, ushort2 b) { >+ ushort2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+ushort3 operator+(ushort3 a, ushort3 b) { >+ ushort3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+ushort3 operator-(ushort3 a, ushort3 b) { >+ ushort3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+ushort3 operator*(ushort3 a, ushort3 b) { >+ ushort3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+ushort3 operator*(ushort3 a, ushort b) { >+ ushort3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+ushort3 operator*(ushort a, ushort3 b) { >+ ushort3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+ushort3 operator/(ushort3 a, ushort3 b) { >+ ushort3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+ushort3 operator/(ushort3 a, ushort b) { >+ ushort3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+ushort3 operator/(ushort a, ushort3 b) { >+ ushort3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+ushort4 operator+(ushort4 a, ushort4 b) { >+ ushort4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+ushort4 operator-(ushort4 a, ushort4 b) { >+ ushort4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+ushort4 operator*(ushort4 a, ushort4 b) { >+ ushort4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+ushort4 operator*(ushort4 a, ushort b) { >+ ushort4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+ushort4 operator*(ushort a, ushort4 b) { >+ ushort4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+ushort4 operator/(ushort4 a, ushort4 b) { >+ ushort4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+ushort4 operator/(ushort4 a, ushort b) { >+ ushort4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+ushort4 operator/(ushort a, ushort4 b) { >+ ushort4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+uint2 operator+(uint2 a, uint2 b) { >+ uint2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+uint2 operator-(uint2 a, uint2 b) { >+ uint2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+uint2 operator*(uint2 a, uint2 b) { >+ uint2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+uint2 operator*(uint2 a, uint b) { >+ uint2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+uint2 operator*(uint a, uint2 b) { >+ uint2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+uint2 operator/(uint2 a, uint2 b) { >+ uint2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+uint2 operator/(uint2 a, uint b) { >+ uint2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+uint2 operator/(uint a, uint2 b) { >+ uint2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+uint3 operator+(uint3 a, uint3 b) { >+ uint3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+uint3 operator-(uint3 a, uint3 b) { >+ uint3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+uint3 operator*(uint3 a, uint3 b) { >+ uint3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+uint3 operator*(uint3 a, uint b) { >+ uint3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+uint3 operator*(uint a, uint3 b) { >+ uint3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+uint3 operator/(uint3 a, uint3 b) { >+ uint3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+uint3 operator/(uint3 a, uint b) { >+ uint3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+uint3 operator/(uint a, uint3 b) { >+ uint3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+uint4 operator+(uint4 a, uint4 b) { >+ uint4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+uint4 operator-(uint4 a, uint4 b) { >+ uint4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+uint4 operator*(uint4 a, uint4 b) { >+ uint4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+uint4 operator*(uint4 a, uint b) { >+ uint4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+uint4 operator*(uint a, uint4 b) { >+ uint4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+uint4 operator/(uint4 a, uint4 b) { >+ uint4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+uint4 operator/(uint4 a, uint b) { >+ uint4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+uint4 operator/(uint a, uint4 b) { >+ uint4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+char2 operator+(char2 a, char2 b) { >+ char2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+char2 operator-(char2 a, char2 b) { >+ char2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+char2 operator*(char2 a, char2 b) { >+ char2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+char2 operator*(char2 a, char b) { >+ char2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+char2 operator*(char a, char2 b) { >+ char2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+char2 operator/(char2 a, char2 b) { >+ char2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+char2 operator/(char2 a, char b) { >+ char2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+char2 operator/(char a, char2 b) { >+ char2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+char3 operator+(char3 a, char3 b) { >+ char3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+char3 operator-(char3 a, char3 b) { >+ char3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+char3 operator*(char3 a, char3 b) { >+ char3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+char3 operator*(char3 a, char b) { >+ char3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+char3 operator*(char a, char3 b) { >+ char3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+char3 operator/(char3 a, char3 b) { >+ char3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+char3 operator/(char3 a, char b) { >+ char3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+char3 operator/(char a, char3 b) { >+ char3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+char4 operator+(char4 a, char4 b) { >+ char4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+char4 operator-(char4 a, char4 b) { >+ char4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+char4 operator*(char4 a, char4 b) { >+ char4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+char4 operator*(char4 a, char b) { >+ char4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+char4 operator*(char a, char4 b) { >+ char4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+char4 operator/(char4 a, char4 b) { >+ char4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+char4 operator/(char4 a, char b) { >+ char4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+char4 operator/(char a, char4 b) { >+ char4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+short2 operator+(short2 a, short2 b) { >+ short2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+short2 operator-(short2 a, short2 b) { >+ short2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+short2 operator*(short2 a, short2 b) { >+ short2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+short2 operator*(short2 a, short b) { >+ short2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+short2 operator*(short a, short2 b) { >+ short2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+short2 operator/(short2 a, short2 b) { >+ short2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+short2 operator/(short2 a, short b) { >+ short2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+short2 operator/(short a, short2 b) { >+ short2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+short3 operator+(short3 a, short3 b) { >+ short3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+short3 operator-(short3 a, short3 b) { >+ short3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+short3 operator*(short3 a, short3 b) { >+ short3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+short3 operator*(short3 a, short b) { >+ short3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+short3 operator*(short a, short3 b) { >+ short3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+short3 operator/(short3 a, short3 b) { >+ short3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+short3 operator/(short3 a, short b) { >+ short3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+short3 operator/(short a, short3 b) { >+ short3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+short4 operator+(short4 a, short4 b) { >+ short4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+short4 operator-(short4 a, short4 b) { >+ short4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+short4 operator*(short4 a, short4 b) { >+ short4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+short4 operator*(short4 a, short b) { >+ short4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+short4 operator*(short a, short4 b) { >+ short4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+short4 operator/(short4 a, short4 b) { >+ short4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+short4 operator/(short4 a, short b) { >+ short4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+short4 operator/(short a, short4 b) { >+ short4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+int2 operator+(int2 a, int2 b) { >+ int2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+int2 operator-(int2 a, int2 b) { >+ int2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+int2 operator*(int2 a, int2 b) { >+ int2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+int2 operator*(int2 a, int b) { >+ int2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+int2 operator*(int a, int2 b) { >+ int2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+int2 operator/(int2 a, int2 b) { >+ int2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+int2 operator/(int2 a, int b) { >+ int2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+int2 operator/(int a, int2 b) { >+ int2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+int3 operator+(int3 a, int3 b) { >+ int3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+int3 operator-(int3 a, int3 b) { >+ int3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+int3 operator*(int3 a, int3 b) { >+ int3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+int3 operator*(int3 a, int b) { >+ int3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+int3 operator*(int a, int3 b) { >+ int3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+int3 operator/(int3 a, int3 b) { >+ int3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+int3 operator/(int3 a, int b) { >+ int3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+int3 operator/(int a, int3 b) { >+ int3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+int4 operator+(int4 a, int4 b) { >+ int4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+int4 operator-(int4 a, int4 b) { >+ int4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+int4 operator*(int4 a, int4 b) { >+ int4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+int4 operator*(int4 a, int b) { >+ int4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+int4 operator*(int a, int4 b) { >+ int4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+int4 operator/(int4 a, int4 b) { >+ int4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+int4 operator/(int4 a, int b) { >+ int4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+int4 operator/(int a, int4 b) { >+ int4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+half2 operator+(half2 a, half2 b) { >+ half2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+half2 operator-(half2 a, half2 b) { >+ half2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+half2 operator*(half2 a, half2 b) { >+ half2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+half2 operator*(half2 a, half b) { >+ half2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+half2 operator*(half a, half2 b) { >+ half2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+half2 operator/(half2 a, half2 b) { >+ half2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+half2 operator/(half2 a, half b) { >+ half2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+half2 operator/(half a, half2 b) { >+ half2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+half3 operator+(half3 a, half3 b) { >+ half3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+half3 operator-(half3 a, half3 b) { >+ half3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+half3 operator*(half3 a, half3 b) { >+ half3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+half3 operator*(half3 a, half b) { >+ half3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+half3 operator*(half a, half3 b) { >+ half3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+half3 operator/(half3 a, half3 b) { >+ half3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+half3 operator/(half3 a, half b) { >+ half3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+half3 operator/(half a, half3 b) { >+ half3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+half4 operator+(half4 a, half4 b) { >+ half4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+half4 operator-(half4 a, half4 b) { >+ half4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+half4 operator*(half4 a, half4 b) { >+ half4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+half4 operator*(half4 a, half b) { >+ half4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+half4 operator*(half a, half4 b) { >+ half4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+half4 operator/(half4 a, half4 b) { >+ half4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+half4 operator/(half4 a, half b) { >+ half4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+half4 operator/(half a, half4 b) { >+ half4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+float2 operator+(float2 a, float2 b) { >+ float2 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ return result; >+} >+float2 operator-(float2 a, float2 b) { >+ float2 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ return result; >+} >+float2 operator*(float2 a, float2 b) { >+ float2 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ return result; >+} >+float2 operator*(float2 a, float b) { >+ float2 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ return result; >+} >+float2 operator*(float a, float2 b) { >+ float2 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ return result; >+} >+float2 operator/(float2 a, float2 b) { >+ float2 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ return result; >+} >+float2 operator/(float2 a, float b) { >+ float2 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ return result; >+} >+float2 operator/(float a, float2 b) { >+ float2 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ return result; >+} >+float3 operator+(float3 a, float3 b) { >+ float3 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ return result; >+} >+float3 operator-(float3 a, float3 b) { >+ float3 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ return result; >+} >+float3 operator*(float3 a, float3 b) { >+ float3 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ return result; >+} >+float3 operator*(float3 a, float b) { >+ float3 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ return result; >+} >+float3 operator*(float a, float3 b) { >+ float3 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ return result; >+} >+float3 operator/(float3 a, float3 b) { >+ float3 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ return result; >+} >+float3 operator/(float3 a, float b) { >+ float3 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ return result; >+} >+float3 operator/(float a, float3 b) { >+ float3 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ return result; >+} >+float4 operator+(float4 a, float4 b) { >+ float4 result; >+ result[0] = a[0] + b[0]; >+ result[1] = a[1] + b[1]; >+ result[2] = a[2] + b[2]; >+ result[3] = a[3] + b[3]; >+ return result; >+} >+float4 operator-(float4 a, float4 b) { >+ float4 result; >+ result[0] = a[0] - b[0]; >+ result[1] = a[1] - b[1]; >+ result[2] = a[2] - b[2]; >+ result[3] = a[3] - b[3]; >+ return result; >+} >+float4 operator*(float4 a, float4 b) { >+ float4 result; >+ result[0] = a[0] * b[0]; >+ result[1] = a[1] * b[1]; >+ result[2] = a[2] * b[2]; >+ result[3] = a[3] * b[3]; >+ return result; >+} >+float4 operator*(float4 a, float b) { >+ float4 result; >+ result[0] = a[0] * b; >+ result[1] = a[1] * b; >+ result[2] = a[2] * b; >+ result[3] = a[3] * b; >+ return result; >+} >+float4 operator*(float a, float4 b) { >+ float4 result; >+ result[0] = a * b[0]; >+ result[1] = a * b[1]; >+ result[2] = a * b[2]; >+ result[3] = a * b[3]; >+ return result; >+} >+float4 operator/(float4 a, float4 b) { >+ float4 result; >+ result[0] = a[0] / b[0]; >+ result[1] = a[1] / b[1]; >+ result[2] = a[2] / b[2]; >+ result[3] = a[3] / b[3]; >+ return result; >+} >+float4 operator/(float4 a, float b) { >+ float4 result; >+ result[0] = a[0] / b; >+ result[1] = a[1] / b; >+ result[2] = a[2] / b; >+ result[3] = a[3] / b; >+ return result; >+} >+float4 operator/(float a, float4 b) { >+ float4 result; >+ result[0] = a / b[0]; >+ result[1] = a / b[1]; >+ result[2] = a / b[2]; >+ result[3] = a / b[3]; >+ return result; >+} >+char2 operator-(char2 a) { >+ char2 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ return result; >+} >+char3 operator-(char3 a) { >+ char3 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ return result; >+} >+char4 operator-(char4 a) { >+ char4 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ result[3] = -a[3]; >+ return result; >+} >+short2 operator-(short2 a) { >+ short2 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ return result; >+} >+short3 operator-(short3 a) { >+ short3 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ return result; >+} >+short4 operator-(short4 a) { >+ short4 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ result[3] = -a[3]; >+ return result; >+} >+int2 operator-(int2 a) { >+ int2 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ return result; >+} >+int3 operator-(int3 a) { >+ int3 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ return result; >+} >+int4 operator-(int4 a) { >+ int4 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ result[3] = -a[3]; >+ return result; >+} >+half2 operator-(half2 a) { >+ half2 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ return result; >+} >+half3 operator-(half3 a) { >+ half3 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ return result; >+} >+half4 operator-(half4 a) { >+ half4 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ result[3] = -a[3]; >+ return result; >+} >+float2 operator-(float2 a) { >+ float2 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ return result; >+} >+float3 operator-(float3 a) { >+ float3 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ return result; >+} >+float4 operator-(float4 a) { >+ float4 result; >+ result[0] = -a[0]; >+ result[1] = -a[1]; >+ result[2] = -a[2]; >+ result[3] = -a[3]; >+ return result; >+} > >-native typedef int2; >-native typedef int3; >-native typedef int4; >+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; >+} >+native bool operator.x(bool2); >+native bool operator.y(bool2); >+native bool operator.x(bool3); >+native bool operator.y(bool3); >+native bool operator.z(bool3); >+native bool operator.x(bool4); >+native bool operator.y(bool4); >+native bool operator.z(bool4); >+native bool operator.w(bool4); >+native bool2 operator.x=(bool2, bool); >+native bool2 operator.y=(bool2, bool); >+native bool3 operator.x=(bool3, bool); >+native bool3 operator.y=(bool3, bool); >+native bool3 operator.z=(bool3, bool); >+native bool4 operator.x=(bool4, bool); >+native bool4 operator.y=(bool4, bool); >+native bool4 operator.z=(bool4, bool); >+native bool4 operator.w=(bool4, bool); >+bool operator[](bool2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+bool operator[](bool3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+bool operator[](bool4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+bool2 operator[]=(bool2 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool3 operator[]=(bool3 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool4 operator[]=(bool4 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool operator==(uchar2 a, uchar2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(uchar3 a, uchar3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(uchar4 a, uchar4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+native uchar operator.x(uchar2); >+native uchar operator.y(uchar2); >+native uchar operator.x(uchar3); >+native uchar operator.y(uchar3); >+native uchar operator.z(uchar3); >+native uchar operator.x(uchar4); >+native uchar operator.y(uchar4); >+native uchar operator.z(uchar4); >+native uchar operator.w(uchar4); >+native uchar2 operator.x=(uchar2, uchar); >+native uchar2 operator.y=(uchar2, uchar); >+native uchar3 operator.x=(uchar3, uchar); >+native uchar3 operator.y=(uchar3, uchar); >+native uchar3 operator.z=(uchar3, uchar); >+native uchar4 operator.x=(uchar4, uchar); >+native uchar4 operator.y=(uchar4, uchar); >+native uchar4 operator.z=(uchar4, uchar); >+native uchar4 operator.w=(uchar4, uchar); >+uchar operator[](uchar2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+uchar operator[](uchar3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+uchar operator[](uchar4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+uchar2 operator[]=(uchar2 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+uchar3 operator[]=(uchar3 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+uchar4 operator[]=(uchar4 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool operator==(ushort2 a, ushort2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(ushort3 a, ushort3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(ushort4 a, ushort4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+native ushort operator.x(ushort2); >+native ushort operator.y(ushort2); >+native ushort operator.x(ushort3); >+native ushort operator.y(ushort3); >+native ushort operator.z(ushort3); >+native ushort operator.x(ushort4); >+native ushort operator.y(ushort4); >+native ushort operator.z(ushort4); >+native ushort operator.w(ushort4); >+native ushort2 operator.x=(ushort2, ushort); >+native ushort2 operator.y=(ushort2, ushort); >+native ushort3 operator.x=(ushort3, ushort); >+native ushort3 operator.y=(ushort3, ushort); >+native ushort3 operator.z=(ushort3, ushort); >+native ushort4 operator.x=(ushort4, ushort); >+native ushort4 operator.y=(ushort4, ushort); >+native ushort4 operator.z=(ushort4, ushort); >+native ushort4 operator.w=(ushort4, ushort); >+ushort operator[](ushort2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+ushort operator[](ushort3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+ushort operator[](ushort4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+ushort2 operator[]=(ushort2 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+ushort3 operator[]=(ushort3 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+ushort4 operator[]=(ushort4 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+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; >+} >+native uint operator.x(uint2); >+native uint operator.y(uint2); >+native uint operator.x(uint3); >+native uint operator.y(uint3); >+native uint operator.z(uint3); >+native uint operator.x(uint4); >+native uint operator.y(uint4); >+native uint operator.z(uint4); >+native uint operator.w(uint4); >+native uint2 operator.x=(uint2, uint); >+native uint2 operator.y=(uint2, uint); >+native uint3 operator.x=(uint3, uint); >+native uint3 operator.y=(uint3, uint); >+native uint3 operator.z=(uint3, uint); >+native uint4 operator.x=(uint4, uint); >+native uint4 operator.y=(uint4, uint); >+native uint4 operator.z=(uint4, uint); >+native uint4 operator.w=(uint4, uint); >+uint operator[](uint2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+uint operator[](uint3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+uint operator[](uint4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+uint2 operator[]=(uint2 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+uint3 operator[]=(uint3 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+uint4 operator[]=(uint4 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool operator==(char2 a, char2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(char3 a, char3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(char4 a, char4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+native char operator.x(char2); >+native char operator.y(char2); >+native char operator.x(char3); >+native char operator.y(char3); >+native char operator.z(char3); >+native char operator.x(char4); >+native char operator.y(char4); >+native char operator.z(char4); >+native char operator.w(char4); >+native char2 operator.x=(char2, char); >+native char2 operator.y=(char2, char); >+native char3 operator.x=(char3, char); >+native char3 operator.y=(char3, char); >+native char3 operator.z=(char3, char); >+native char4 operator.x=(char4, char); >+native char4 operator.y=(char4, char); >+native char4 operator.z=(char4, char); >+native char4 operator.w=(char4, char); >+char operator[](char2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+char operator[](char3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+char operator[](char4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+char2 operator[]=(char2 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+char3 operator[]=(char3 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+char4 operator[]=(char4 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool operator==(short2 a, short2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(short3 a, short3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(short4 a, short4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+native short operator.x(short2); >+native short operator.y(short2); >+native short operator.x(short3); >+native short operator.y(short3); >+native short operator.z(short3); >+native short operator.x(short4); >+native short operator.y(short4); >+native short operator.z(short4); >+native short operator.w(short4); >+native short2 operator.x=(short2, short); >+native short2 operator.y=(short2, short); >+native short3 operator.x=(short3, short); >+native short3 operator.y=(short3, short); >+native short3 operator.z=(short3, short); >+native short4 operator.x=(short4, short); >+native short4 operator.y=(short4, short); >+native short4 operator.z=(short4, short); >+native short4 operator.w=(short4, short); >+short operator[](short2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+short operator[](short3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+short operator[](short4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+short2 operator[]=(short2 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+short3 operator[]=(short3 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+short4 operator[]=(short4 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+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; >+} >+native int operator.x(int2); >+native int operator.y(int2); >+native int operator.x(int3); >+native int operator.y(int3); >+native int operator.z(int3); >+native int operator.x(int4); >+native int operator.y(int4); >+native int operator.z(int4); >+native int operator.w(int4); >+native int2 operator.x=(int2, int); >+native int2 operator.y=(int2, int); >+native int3 operator.x=(int3, int); >+native int3 operator.y=(int3, int); >+native int3 operator.z=(int3, int); >+native int4 operator.x=(int4, int); >+native int4 operator.y=(int4, int); >+native int4 operator.z=(int4, int); >+native int4 operator.w=(int4, int); >+int operator[](int2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+int operator[](int3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+int operator[](int4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+int2 operator[]=(int2 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+int3 operator[]=(int3 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+int4 operator[]=(int4 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+bool operator==(half2 a, half2 b) { >+ return a.x == b.x && a.y == b.y; >+} >+bool operator==(half3 a, half3 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z; >+} >+bool operator==(half4 a, half4 b) { >+ return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; >+} >+native half operator.x(half2); >+native half operator.y(half2); >+native half operator.x(half3); >+native half operator.y(half3); >+native half operator.z(half3); >+native half operator.x(half4); >+native half operator.y(half4); >+native half operator.z(half4); >+native half operator.w(half4); >+native half2 operator.x=(half2, half); >+native half2 operator.y=(half2, half); >+native half3 operator.x=(half3, half); >+native half3 operator.y=(half3, half); >+native half3 operator.z=(half3, half); >+native half4 operator.x=(half4, half); >+native half4 operator.y=(half4, half); >+native half4 operator.z=(half4, half); >+native half4 operator.w=(half4, half); >+half operator[](half2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+half operator[](half3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+half operator[](half4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+half2 operator[]=(half2 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+half3 operator[]=(half3 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+half4 operator[]=(half4 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} >+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; >+} >+native float operator.x(float2); >+native float operator.y(float2); >+native float operator.x(float3); >+native float operator.y(float3); >+native float operator.z(float3); >+native float operator.x(float4); >+native float operator.y(float4); >+native float operator.z(float4); >+native float operator.w(float4); >+native float2 operator.x=(float2, float); >+native float2 operator.y=(float2, float); >+native float3 operator.x=(float3, float); >+native float3 operator.y=(float3, float); >+native float3 operator.z=(float3, float); >+native float4 operator.x=(float4, float); >+native float4 operator.y=(float4, float); >+native float4 operator.z=(float4, float); >+native float4 operator.w=(float4, float); >+float operator[](float2 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ trap; >+} >+float operator[](float3 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ trap; >+} >+float operator[](float4 v, uint index) { >+ if (index == 0) >+ return v.x; >+ if (index == 1) >+ return v.y; >+ if (index == 2) >+ return v.z; >+ if (index == 3) >+ return v.w; >+ trap; >+} >+float2 operator[]=(float2 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ default: >+ trap; >+ } >+ return v; >+} >+float3 operator[]=(float3 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ default: >+ trap; >+ } >+ return v; >+} >+float4 operator[]=(float4 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ case 1: >+ v.y = a; >+ case 2: >+ v.z = a; >+ case 3: >+ v.w = a; >+ default: >+ trap; >+ } >+ return v; >+} > >-native typedef float2; >-native typedef float3; >-native typedef float4; >+/*half2x2 operator+(half2x2 a, half2x2 b) { >+ half2x2 result; >+ result[0][0] = a[0][0] + b[0][0]; >+ result[0][1] = a[0][1] + b[0][1]; >+ result[1][0] = a[1][0] + b[1][0]; >+ result[1][1] = a[1][1] + b[1][1]; >+ return result; >+}*/ > `; > > // FIXME: Once the standard library has been replaced with a new version, this comments should be removed. > // This list is used to restrict the availability of vector types available in the langauge. > // Permissible vector element types must appear in this list and in the standard library >-const VectorElementTypes = [ /*"bool",*/ "uchar", /*"char", "ushort", "short",*/ "uint", "int", /* "half", */"float" ]; >+const VectorElementTypes = [ "bool", "uchar", "char", "ushort", "short", "uint", "int", "half", "float" ]; > const VectorElementSizes = [ 2, 3, 4 ]; > > function allVectorTypeNames() >@@ -181,19 +3263,8 @@ function allVectorTypeNames() > return names; > } > >-// Provides operator&[] >-standardLibrary += OperatorAnderIndexer.functions().join(";\n") + ";\n"; >- >-// Native vector types are like structs in the langauge, but they do not have the ander field access. >-// It is not possible to take the address of a vector field. >-standardLibrary += BuiltinVectorGetter.functions().join(";\n") + ";\n"; >-standardLibrary += BuiltinVectorSetter.functions().join(";\n") + ";\n"; >-standardLibrary += BuiltinVectorIndexGetter.functions().join(";\n") + ";\n"; >-standardLibrary += BuiltinVectorIndexSetter.functions().join(";\n") + ";\n"; >- > // FIXME: For native types these could be included as source in the standard library. > // https://bugs.webkit.org/show_bug.cgi?id=188685 >-standardLibrary += OperatorBool.functions().join(";\n") + ";\n"; > standardLibrary += BuiltinVectorEqualityOperator.functions().join(";\n") + ";\n"; > > // FIXME: These need to be included as source in the standard library. >diff --git a/Tools/WebGPUShadingLanguageRI/StatementCloner.js b/Tools/WebGPUShadingLanguageRI/StatementCloner.js >index b3948c450c7160977975ed4e8e98ed99c4f7a059..0d0715a9854def1bfd2a808c7404112ba1a4a0c1 100644 >--- a/Tools/WebGPUShadingLanguageRI/StatementCloner.js >+++ b/Tools/WebGPUShadingLanguageRI/StatementCloner.js >@@ -50,7 +50,7 @@ class StatementCloner extends Rewriter { > > visitNativeType(node) > { >- return new NativeType(node.origin, node.name); >+ return new NativeType(node.origin, node.name, node.typeArguments.map(argument => argument.visit(this))); > } > > visitTypeDef(node) >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js b/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >index fefe9c03d7b10b3116b3b67f2af057f16fc1516c..dc506538d1c6c7109b1ad1ecba3cec278d0f7b5c 100644 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >+++ b/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >@@ -45,6 +45,18 @@ function synthesizeDefaultConstructorOperator(program) > types.add(node); > super.visitElementalType(node); > } >+ >+ visitVectorType(node) >+ { >+ types.add(node); >+ super.visitVectorType(node); >+ } >+ >+ visitMatrixType(node) >+ { >+ types.add(node); >+ super.visitMatrixType(node); >+ } > } > > program.visit(new FindAllTypes()); >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeOperatorBool.js b/Tools/WebGPUShadingLanguageRI/SynthesizeOperatorBool.js >deleted file mode 100644 >index 695fe13753d0a2643b095b534b119217f62538b3..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeOperatorBool.js >+++ /dev/null >@@ -1,37 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >-"use strict"; >- >-function synthesizeOperatorBool(program) >-{ >- for (let type of program.types.values()) { >- if (!(type instanceof StructType) && !(type instanceof EnumType)) >- continue; >- const func = new NativeFunc(type.origin, "operator cast", TypeRef.wrap(program.types.get("bool")), [ new FuncParameter(type.origin, null, TypeRef.wrap(type)) ], true, null); >- const operatorBool = new OperatorBool(type.name); >- operatorBool.instantiateImplementation(func); >- program.add(func); >- } >-} >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js b/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >index bfe604494dc725ae7e74ad4a0bfe23e93c091776..a0181468a25ed4c09050d7bf1d61f44ed3a0aa66 100644 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >+++ b/Tools/WebGPUShadingLanguageRI/SynthesizeStructAccessors.js >@@ -51,7 +51,7 @@ function synthesizeStructAccessors(program) > > function createTypeRef() > { >- return TypeRef.instantiate(type); >+ return TypeRef.wrap(type); > } > > let isCast = false; >diff --git a/Tools/WebGPUShadingLanguageRI/Test.html b/Tools/WebGPUShadingLanguageRI/Test.html >index 13f358239929d8a3e6ace52545b91ca52d6060e4..d230ff58d7fdab2a103120164cb4676cb8b14e45 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.html >+++ b/Tools/WebGPUShadingLanguageRI/Test.html >@@ -26,8 +26,6 @@ > <script src="BuiltinVectorConstructors.js"></script> > <script src="BuiltinVectorGetter.js"></script> > <script src="BuiltinVectorSetter.js"></script> >-<script src="BuiltinVectorIndexGetter.js"></script> >-<script src="BuiltinVectorIndexSetter.js"></script> > <script src="BuiltinVectorEqualityOperator.js"></script> > <script src="CallExpression.js"></script> > <script src="CallFunction.js"></script> >@@ -37,6 +35,7 @@ > <script src="CheckRecursion.js"></script> > <script src="CheckRecursiveTypes.js"></script> > <script src="CheckReturns.js"></script> >+<script src="CheckTypesWithArguments.js"></script> > <script src="CheckUnreachableCode.js"></script> > <script src="CheckWrapped.js"></script> > <script src="Checker.js"></script> >@@ -89,6 +88,7 @@ > <script src="LoopChecker.js"></script> > <script src="MakeArrayRefExpression.js"></script> > <script src="MakePtrExpression.js"></script> >+<script src="MatrixType.js"></script> > <script src="NameContext.js"></script> > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> >@@ -96,9 +96,8 @@ > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >-<script src="OperatorAnderIndex.js"></script> >+<script src="OperatorAnderIndexer.js"></script> > <script src="OperatorArrayRefLength.js"></script> >-<script src="OperatorBool.js"></script> > <script src="OriginKind.js"></script> > <script src="OverloadResolutionFailure.js"></script> > <script src="Parse.js"></script> >@@ -110,7 +109,6 @@ > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> > <script src="RecursiveTypeChecker.js"></script> >-<script src="RemoveTypeArguments.js"></script> > <script src="ResolveNames.js"></script> > <script src="ResolveOverloadImpl.js"></script> > <script src="ResolveProperties.js"></script> >@@ -127,13 +125,13 @@ > <script src="SynthesizeArrayOperatorLength.js"></script> > <script src="SynthesizeEnumFunctions.js"></script> > <script src="SynthesizeStructAccessors.js"></script> >-<script src="SynthesizeOperatorBool.js"></script> > <script src="SynthesizeCopyConstructorOperator.js"></script> > <script src="SynthesizeDefaultConstructorOperator.js"></script> > <script src="TrapStatement.js"></script> > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeRef.js"></script> >+<script src="TypeOverloadResolutionFailure.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script> >diff --git a/Tools/WebGPUShadingLanguageRI/Test.js b/Tools/WebGPUShadingLanguageRI/Test.js >index df417dabf6d87135e735ca8c9b1bf13ab64075a1..b3598dd7fa188e8ed4b04ea0f4ed846e676286a0 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.js >+++ b/Tools/WebGPUShadingLanguageRI/Test.js >@@ -2153,41 +2153,6 @@ tests.operatorBool = function() > > bool boolFromFloatFalse() { return bool(float(0)); } > bool boolFromFloatTrue() { return bool(float(1)); } >- >- bool boolFromInt2False() { return bool(int2(0, 0)); } >- bool boolFromInt2True1() { return bool(int2(1, 0)); } >- bool boolFromInt2True2() { return bool(int2(0, 1)); } >- >- bool boolFromFloat3False() { return bool(float3(0, 0, 0)); } >- bool boolFromFloat3True1() { return bool(float3(1, 0, 0)); } >- bool boolFromFloat3True2() { return bool(float3(0, 1, 0)); } >- bool boolFromFloat3True3() { return bool(float3(0, 0, 1)); } >- >- bool boolFromUint4False() { return bool(uint4(0, 0, 0, 0)); } >- bool boolFromUint4True1() { return bool(uint4(1, 0, 0, 0)); } >- bool boolFromUint4True2() { return bool(uint4(0, 1, 0, 0)); } >- bool boolFromUint4True3() { return bool(uint4(0, 0, 1, 0)); } >- bool boolFromUint4True4() { return bool(uint4(0, 0, 0, 1)); } >- >- struct X { int x; } >- >- bool boolFromStructFalse() >- { >- X x; >- return bool(x); >- } >- >- bool boolFromStructTrue() >- { >- X x; >- x.x = 1; >- return bool(x); >- } >- >- enum Y { A, B } >- >- bool boolFromEnumFalse() { return bool(Y.A); } >- bool boolFromEnumTrue() { return bool(Y.B); } > `); > > checkBool(program, callFunction(program, "boolFromUcharFalse", []), false); >@@ -2201,27 +2166,6 @@ tests.operatorBool = function() > > checkBool(program, callFunction(program, "boolFromFloatFalse", []), false); > checkBool(program, callFunction(program, "boolFromFloatTrue", []), true); >- >- checkBool(program, callFunction(program, "boolFromInt2False", []), false); >- checkBool(program, callFunction(program, "boolFromInt2True1", []), true); >- checkBool(program, callFunction(program, "boolFromInt2True2", []), true); >- >- checkBool(program, callFunction(program, "boolFromFloat3False", []), false); >- checkBool(program, callFunction(program, "boolFromFloat3True1", []), true); >- checkBool(program, callFunction(program, "boolFromFloat3True2", []), true); >- checkBool(program, callFunction(program, "boolFromFloat3True3", []), true); >- >- checkBool(program, callFunction(program, "boolFromUint4False", []), false); >- checkBool(program, callFunction(program, "boolFromUint4True1", []), true); >- checkBool(program, callFunction(program, "boolFromUint4True2", []), true); >- checkBool(program, callFunction(program, "boolFromUint4True3", []), true); >- checkBool(program, callFunction(program, "boolFromUint4True4", []), true); >- >- checkBool(program, callFunction(program, "boolFromStructFalse", []), false); >- checkBool(program, callFunction(program, "boolFromStructTrue", []), true); >- >- checkBool(program, callFunction(program, "boolFromEnumFalse", []), false); >- checkBool(program, callFunction(program, "boolFromEnumTrue", []), true); > } > > tests.boolBitAnd = function() >@@ -2881,7 +2825,7 @@ tests.shaderTypes = function() > } > fragment Boo bar(Foo stageIn) > { >- return boo(); >+ return Boo(); > } > `), > (e) => e instanceof WTypeError); >@@ -2904,7 +2848,7 @@ tests.shaderTypes = function() > > tests.vectorTypeSyntax = function() > { >- const program = doPrep(` >+ let program = doPrep(` > int foo2() > { > int2 x; >@@ -2939,7 +2883,26 @@ tests.vectorTypeSyntax = function() > checkInt(program, callFunction(program, "foo2", []), 4); > checkInt(program, callFunction(program, "foo3", []), 5); > checkInt(program, callFunction(program, "foo4", []), 6); >+ checkBool(program, callFunction(program, "vec2OperatorCast", []), true); >+ >+ program = doPrep(` >+ typedef i = int; >+ int foo2() >+ { >+ int2 x; >+ vector<i, 2> z = int2(3, 4); >+ x = z; >+ return x.y; >+ } >+ >+ bool vec2OperatorCast() >+ { >+ int2 x = vector<i,2>(1, 2); >+ vector<i, 2> y = int2(1, 2); >+ return x == y && x.x == 1 && x.y == 2 && y.x == 1 && y.y == 2; >+ }`); > >+ checkInt(program, callFunction(program, "foo2", []), 4); > checkBool(program, callFunction(program, "vec2OperatorCast", []), true); > } > >diff --git a/Tools/WebGPUShadingLanguageRI/TypeOverloadResolutionFailure.js b/Tools/WebGPUShadingLanguageRI/TypeOverloadResolutionFailure.js >new file mode 100644 >index 0000000000000000000000000000000000000000..d5cb3f710fa0ce03d2902fa32ed8b0275fb62608 >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/TypeOverloadResolutionFailure.js >@@ -0,0 +1,42 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+"use strict"; >+ >+class TypeOverloadResolutionFailure { >+ constructor(type, reason) >+ { >+ this._type = type; >+ this._reason = reason; >+ } >+ >+ get type() { return this._type; } >+ get reason() { return this._reason; } >+ >+ toString() >+ { >+ return this.type.toString() + " did not match because: " + this.reason; >+ } >+} >+ >diff --git a/Tools/WebGPUShadingLanguageRI/TypeRef.js b/Tools/WebGPUShadingLanguageRI/TypeRef.js >index b5f3c0b3d92532e05c680054a161f05e0ddd646b..acda706c0ce3797e46b09517dcb081ea59e3df89 100644 >--- a/Tools/WebGPUShadingLanguageRI/TypeRef.js >+++ b/Tools/WebGPUShadingLanguageRI/TypeRef.js >@@ -25,7 +25,7 @@ > "use strict"; > > class TypeRef extends Type { >- constructor(origin, name, typeArguments = null) >+ constructor(origin, name, typeArguments = []) > { > super(); > this._origin = origin; >@@ -38,14 +38,11 @@ class TypeRef extends Type { > { > if (type instanceof TypeRef) > return type; >- let result = new TypeRef(type.origin, type.name); >- result.type = type; >- return result; >- } >- >- static instantiate(type) >- { >- let result = new TypeRef(type.origin, type.name); >+ let result; >+ if (type instanceof NativeType) >+ result = new TypeRef(type.origin, type.name, type.typeArguments); >+ else >+ result = new TypeRef(type.orgin, type.name); > result.type = type; > return result; > } >@@ -64,6 +61,39 @@ class TypeRef extends Type { > this._type = newType; > } > >+ resolve(possibleOverloads) >+ { >+ if (!possibleOverloads) >+ throw new WTypeError(this.origin.originString, "Did not find any types named " + this.name); >+ >+ let failures = []; >+ let overload = resolveTypeOverloadImpl(possibleOverloads, this.typeArguments); >+ >+ if (!overload.type) { >+ failures.push(...overload.failures); >+ let message = "Did not find type named " + this.name + " for type arguments "; >+ message += "(" + this.typeArguments + ")"; >+ if (failures.length) >+ message += ", but considered:\n" + failures.join("\n") >+ throw new WTypeError(this.origin.originString, message); >+ } >+ >+ for (let i = 0; i < this.typeArguments.length; ++i) { >+ let typeArgument = this.typeArguments[i]; >+ let resolvedTypeArgument = overload.type.typeArguments[i]; >+ let result = typeArgument.equalsWithCommit(resolvedTypeArgument); >+ if (!result) >+ throw new Error("At " + this.origin.originString + " argument types for Type and TypeRef not equal: argument type = " + typeArgument + ", resolved type argument = " + resolvedTypeArgument); >+ if (resolvedTypeArgument.constructor.name == "GenericLiteral") { >+ result = typeArgument.type.equalsWithCommit(resolvedTypeArgument.type); >+ if (!result) >+ throw new Error("At " + this.origin.originString + " argument types for Type and TypeRef not equal: argument type = " + typeArgument + ", resolved type argument = " + resolvedTypeArgument); >+ } >+ >+ } >+ this.type = overload.type; >+ } >+ > get unifyNode() > { > if (!this.type) >@@ -99,7 +129,10 @@ class TypeRef extends Type { > { > if (!this.name) > return this.type.toString(); >- return this.name; >+ let result = this.name; >+ if (this.typeArguments.length > 0) >+ result += "<" + this.typeArguments.map(argument => argument.toString()).join(",") + ">"; >+ return result; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/UnificationContext.js b/Tools/WebGPUShadingLanguageRI/UnificationContext.js >index 2f71547b0afbe180378f37996231862a2b91a82e..38191697223ef721a537914b3698976781fe6e6e 100644 >--- a/Tools/WebGPUShadingLanguageRI/UnificationContext.js >+++ b/Tools/WebGPUShadingLanguageRI/UnificationContext.js >@@ -92,6 +92,19 @@ class UnificationContext { > > verify() > { >+ // We do a two-phase pre-verification. This gives literals a chance to select a more specific type. >+ let preparations = []; >+ for (let node of this.nodes) { >+ let preparation = node.prepareToVerify(this); >+ if (preparation) >+ preparations.push(preparation); >+ } >+ for (let preparation of preparations) { >+ let result = preparation(); >+ if (!result.result) >+ return result; >+ } >+ > for (let typeArgument of this.typeArguments()) { > let result = typeArgument.verifyAsArgument(this); > if (!result.result) >diff --git a/Tools/WebGPUShadingLanguageRI/VectorType.js b/Tools/WebGPUShadingLanguageRI/VectorType.js >index 5014c671a07882002c234bb32f17c8860effc1c6..df0cbc2c7308f45413cbcc28d89621bc03ab2604 100644 >--- a/Tools/WebGPUShadingLanguageRI/VectorType.js >+++ b/Tools/WebGPUShadingLanguageRI/VectorType.js >@@ -25,19 +25,14 @@ > "use strict"; > > class VectorType extends NativeType { >- constructor(origin, name) >+ constructor(origin, name, typeArguments) > { >- super(origin, name); >- const match = /^([A-z]+)([0-9])$/.exec(name); >- if (!match) >- throw new WTypeError(origin.originString, `${name} doesn't match the format for vector type names.'`); >- >- this._elementType = new TypeRef(origin, match[1]); >- this._numElementsValue = parseInt(match[2]); >+ super(origin, name, typeArguments); > } > >- get elementType() { return this._elementType; } >- get numElementsValue() { return this._numElementsValue; } >+ get elementType() { return this.typeArguments[0]; } >+ get numElements() { return this.typeArguments[1]; } >+ get numElementsValue() { return this.numElements.value; } > get size() { return this.elementType.size * this.numElementsValue; } > > unifyImpl(unificationContext, other) >@@ -59,7 +54,7 @@ class VectorType extends NativeType { > > toString() > { >- return `native typedef ${this.elementType}${this.numElementsValue}`; >+ return `native typedef vector<${this.elementType}, ${this.numElementsValue}>`; > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/Visitor.js b/Tools/WebGPUShadingLanguageRI/Visitor.js >index 7d387b25f2589b873918af2f44c2434ad658747f..2de1e74df2718bb3ba68d05c0e7102bd05a01693 100644 >--- a/Tools/WebGPUShadingLanguageRI/Visitor.js >+++ b/Tools/WebGPUShadingLanguageRI/Visitor.js >@@ -68,10 +68,14 @@ class Visitor { > > visitTypeRef(node) > { >+ for (let typeArgument of node.typeArguments) >+ typeArgument.visit(this); > } > > visitNativeType(node) > { >+ for (let typeArgument of node.typeArguments) >+ typeArgument.visit(this); > } > > visitTypeDef(node) >@@ -327,6 +331,14 @@ class Visitor { > visitVectorType(node) > { > node.elementType.visit(this); >+ node.numElements.visit(this); >+ } >+ >+ visitMatrixType(node) >+ { >+ node.elementType.visit(this); >+ node.numRows.visit(this); >+ node.numColumns.visit(this); > } > } > >diff --git a/Tools/WebGPUShadingLanguageRI/index.html b/Tools/WebGPUShadingLanguageRI/index.html >index 4c93a33e6a38662e8ba1e842403d4c02d5e9f9df..07869bf038dc263ba086bcc8958918fef133f9b3 100644 >--- a/Tools/WebGPUShadingLanguageRI/index.html >+++ b/Tools/WebGPUShadingLanguageRI/index.html >@@ -26,8 +26,6 @@ > <script src="BuiltinVectorConstructors.js"></script> > <script src="BuiltinVectorGetter.js"></script> > <script src="BuiltinVectorSetter.js"></script> >-<script src="BuiltinVectorIndexGetter.js"></script> >-<script src="BuiltinVectorIndexSetter.js"></script> > <script src="BuiltinVectorEqualityOperator.js"></script> > <script src="CallExpression.js"></script> > <script src="CallFunction.js"></script> >@@ -38,6 +36,7 @@ > <script src="CheckRecursiveTypes.js"></script> > <script src="CheckReturns.js"></script> > <script src="CheckUnreachableCode.js"></script> >+<script src="CheckTypesWithArguments.js"></script> > <script src="CheckWrapped.js"></script> > <script src="Checker.js"></script> > <script src="CloneProgram.js"></script> >@@ -89,6 +88,7 @@ > <script src="LoopChecker.js"></script> > <script src="MakeArrayRefExpression.js"></script> > <script src="MakePtrExpression.js"></script> >+<script src="MatrixType.js"></script> > <script src="NameContext.js"></script> > <script src="NameFinder.js"></script> > <script src="NameResolver.js"></script> >@@ -96,9 +96,8 @@ > <script src="NormalUsePropertyResolver.js"></script> > <script src="NullLiteral.js"></script> > <script src="NullType.js"></script> >-<script src="OperatorAnderIndex.js"></script> >+<script src="OperatorAnderIndexer.js"></script> > <script src="OperatorArrayRefLength.js"></script> >-<script src="OperatorBool.js"></script> > <script src="OriginKind.js"></script> > <script src="OverloadResolutionFailure.js"></script> > <script src="Parse.js"></script> >@@ -110,7 +109,6 @@ > <script src="ReadModifyWriteExpression.js"></script> > <script src="RecursionChecker.js"></script> > <script src="RecursiveTypeChecker.js"></script> >-<script src="RemoveTypeArguments.js"></script> > <script src="ResolveNames.js"></script> > <script src="ResolveOverloadImpl.js"></script> > <script src="ResolveProperties.js"></script> >@@ -127,13 +125,13 @@ > <script src="SynthesizeArrayOperatorLength.js"></script> > <script src="SynthesizeEnumFunctions.js"></script> > <script src="SynthesizeStructAccessors.js"></script> >-<script src="SynthesizeOperatorBool.js"></script> > <script src="SynthesizeCopyConstructorOperator.js"></script> > <script src="SynthesizeDefaultConstructorOperator.js"></script> > <script src="TrapStatement.js"></script> > <script src="TypeDef.js"></script> > <script src="TypeDefResolver.js"></script> > <script src="TypeRef.js"></script> >+<script src="TypeOverloadResolutionFailure.js"></script> > <script src="TypedValue.js"></script> > <script src="UintLiteral.js"></script> > <script src="UintLiteralType.js"></script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188873
:
347885
|
347895
|
347901
|
347935
|
347936
|
347963
|
347980
|
347993
|
348011
|
348051
|
348053
|
348078
|
348087
|
348088
|
348091
|
348208
|
348224
|
348413
|
348415