WebKit Bugzilla
Attachment 348365 Details for
Bug 188940
: [WHLSL] Implement texture types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-188940-20180828173143.patch (text/plain), 203.86 KB, created by
Myles C. Maxfield
on 2018-08-28 17:31:44 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2018-08-28 17:31:44 PDT
Size:
203.86 KB
patch
obsolete
>Subversion Revision: 235439 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index f46457b441f05d6f56df62a86ae53163b1973908..edea0a8e998910d73f8e8e18c3bff41552f40e54 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,166 @@ >+2018-08-28 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Implement texture types >+ https://bugs.webkit.org/show_bug.cgi?id=188940 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebGPUShadingLanguageRI/All.js: >+ * WebGPUShadingLanguageRI/BuiltinMatrixGetter.js: Copied from Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexSetter.js. >+ (BuiltinMatrixGetter): >+ (BuiltinMatrixGetter.prototype.get height): >+ (BuiltinMatrixGetter.prototype.get width): >+ (BuiltinMatrixGetter.prototype.toString): >+ (BuiltinMatrixGetter.functions): >+ (BuiltinMatrixGetter.prototype.instantiateImplementation): >+ * WebGPUShadingLanguageRI/BuiltinMatrixSetter.js: Renamed from Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexSetter.js. >+ (BuiltinMatrixSetter): >+ (BuiltinMatrixSetter.prototype.get height): >+ (BuiltinMatrixSetter.prototype.get width): >+ (BuiltinMatrixSetter.prototype.toString): >+ (BuiltinMatrixSetter.functions): >+ (BuiltinMatrixSetter.prototype.instantiateImplementation): >+ * WebGPUShadingLanguageRI/BuiltinVectorConstructors.js: Removed. >+ * WebGPUShadingLanguageRI/BuiltinVectorEqualityOperator.js: Removed. >+ * WebGPUShadingLanguageRI/BuiltinVectorGetter.js: >+ (BuiltinVectorGetter.prototype.instantiateImplementation): >+ (BuiltinVectorGetter): >+ * WebGPUShadingLanguageRI/BuiltinVectorSetter.js: >+ (BuiltinVectorSetter.functions): >+ (BuiltinVectorSetter.prototype.instantiateImplementation): >+ (BuiltinVectorSetter): >+ * WebGPUShadingLanguageRI/CallExpression.js: >+ (CallExpression.prototype.resolve): >+ * WebGPUShadingLanguageRI/CheckTypesWithArguments.js: >+ (checkTypesWithArguments.TypeWithArgumentsChecker.prototype.visitTypeRef): >+ (checkTypesWithArguments.TypeWithArgumentsChecker): >+ (checkTypesWithArguments): >+ * WebGPUShadingLanguageRI/Checker.js: >+ (Checker.prototype.visitVectorType): >+ (Checker.prototype.visitMatrixType): >+ * WebGPUShadingLanguageRI/ConstexprFolder.js: >+ (ConstexprFolder.prototype.visitCallExpression): >+ (ConstexprFolder): >+ * WebGPUShadingLanguageRI/Evaluator.js: >+ (Evaluator.prototype.visitTernaryExpression): >+ * WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js: >+ (FlattenedStructOffsetGatherer.prototype.visitMatrixType): >+ (FlattenedStructOffsetGatherer): >+ * WebGPUShadingLanguageRI/FloatLiteralType.js: >+ (let.FloatLiteralType.createLiteralType.verifyAsArgument): >+ * WebGPUShadingLanguageRI/Intrinsics.js: >+ (Intrinsics.): >+ (Intrinsics): >+ * WebGPUShadingLanguageRI/MatrixType.js: Renamed from Tools/WebGPUShadingLanguageRI/BuiltinVectorIndexGetter.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): >+ * WebGPUShadingLanguageRI/NativeType.js: >+ (NativeType.create): >+ (NativeType): >+ * WebGPUShadingLanguageRI/OperatorAnderIndexer.js: Renamed from Tools/WebGPUShadingLanguageRI/OperatorAnderIndex.js. >+ (OperatorAnderIndexer): >+ * WebGPUShadingLanguageRI/OperatorBool.js: Removed. >+ * WebGPUShadingLanguageRI/Prepare.js: >+ (let.prepare): >+ * WebGPUShadingLanguageRI/Program.js: >+ (Program.prototype.add): >+ * WebGPUShadingLanguageRI/Rewriter.js: >+ (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): >+ (operator.bool2): >+ (operator.bool3): >+ (operator.bool4): >+ (uint.operator.length): >+ (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): >+ (bool2.operator): >+ (bool3.operator): >+ (bool4.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): >+ (allVectorTypeNames): >+ * WebGPUShadingLanguageRI/SwizzleOp.js: Removed. >+ * WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js: >+ (synthesizeDefaultConstructorOperator.FindAllTypes.prototype.visitMatrixType): >+ (synthesizeDefaultConstructorOperator.FindAllTypes): >+ (synthesizeDefaultConstructorOperator): >+ * WebGPUShadingLanguageRI/SynthesizeOperatorBool.js: Removed. >+ * WebGPUShadingLanguageRI/Test.html: >+ * WebGPUShadingLanguageRI/Test.js: >+ (makeSampler): >+ (make1DTexture): >+ (tests.textureDimensions): >+ * WebGPUShadingLanguageRI/Visitor.js: >+ (Visitor.prototype.visitMatrixType): >+ (Visitor): >+ * WebGPUShadingLanguageRI/index.html: >+ > 2018-08-28 David Kilzer <ddkilzer@apple.com> > > Fix incorrect use of `sourceTree = "<group>";` for built products and frameworks in Xcode projects >diff --git a/Tools/WebGPUShadingLanguageRI/All.js b/Tools/WebGPUShadingLanguageRI/All.js >index 315bec2e688627c3cd80ba46fba24001e28f9f4c..9c2a37150c1e976b926cfbee23437520a8de4a47 100644 >--- a/Tools/WebGPUShadingLanguageRI/All.js >+++ b/Tools/WebGPUShadingLanguageRI/All.js >@@ -34,7 +34,6 @@ load("Visitor.js"); > load("CreateLiteral.js"); > load("CreateLiteralType.js"); > load("PropertyAccessExpression.js"); >-load("SwizzleOp.js"); > load("NativeType.js"); > > load("AddressSpace.js"); >@@ -46,12 +45,10 @@ load("AutoWrapper.js"); > load("Block.js"); > load("BoolLiteral.js"); > load("Break.js"); >-load("BuiltinVectorConstructors.js"); >+load("BuiltinMatrixGetter.js"); >+load("BuiltinMatrixSetter.js"); > load("BuiltinVectorGetter.js"); > load("BuiltinVectorSetter.js"); >-load("BuiltinVectorIndexGetter.js"); >-load("BuiltinVectorIndexSetter.js"); >-load("BuiltinVectorEqualityOperator.js"); > load("CallExpression.js"); > load("CallFunction.js"); > load("Check.js"); >@@ -113,6 +110,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"); >@@ -120,9 +118,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"); >@@ -150,7 +147,6 @@ load("SwitchStatement.js"); > load("SynthesizeArrayOperatorLength.js"); > load("SynthesizeEnumFunctions.js"); > load("SynthesizeStructAccessors.js"); >-load("SynthesizeOperatorBool.js"); > load("SynthesizeCopyConstructorOperator.js"); > load("SynthesizeDefaultConstructorOperator.js"); > load("TernaryExpression.js"); >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinMatrixGetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinMatrixGetter.js >new file mode 100644 >index 0000000000000000000000000000000000000000..86a333946cbf4e5db7a48db85858817ff8c67d6e >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinMatrixGetter.js >@@ -0,0 +1,73 @@ >+/* >+ * 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 BuiltinMatrixGetter { >+ constructor(baseTypeName, height, width) >+ { >+ this._baseTypeName = baseTypeName; >+ this._height = height; >+ this._width = width; >+ } >+ >+ get baseTypeName() { return this._baseTypeName; } >+ get height() { return this._height; } >+ get width() { return this._width; } >+ >+ toString() >+ { >+ return `native ${this.baseTypeName}${this.width} operator[](${this.baseTypeName}${this.height}x${this.width},uint)`; >+ } >+ >+ static functions() >+ { >+ if (!this._functions) { >+ this._functions = []; >+ >+ for (let typeName of ["half", "float"]) { >+ for (let height of [2, 3, 4]) { >+ for (let width of [2, 3, 4]) >+ this._functions.push(new BuiltinMatrixGetter(typeName, height, width)); >+ } >+ } >+ } >+ return this._functions; >+ } >+ >+ instantiateImplementation(func) >+ { >+ func.implementation = ([mat, index]) => { >+ const indexValue = index.loadValue(); >+ if (indexValue >= 0 && indexValue < this.height) { >+ const result = new EPtr(new EBuffer(this.width), 0); >+ for (let i = 0; i < this.width; i++) >+ result.set(offset++, mat.get(indexValue * this.width + i)); >+ return result; >+ } else >+ throw new WTrapError("[Builtin matrix getter]", "Out-of-bounds index when indexing into a matrix"); >+ }; >+ func.implementationData = this; >+ } >+} >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinMatrixSetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinMatrixSetter.js >new file mode 100644 >index 0000000000000000000000000000000000000000..f7b85749ce1f2d7d1af26b1cde8f78f3f84b5538 >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinMatrixSetter.js >@@ -0,0 +1,73 @@ >+/* >+ * 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 BuiltinMatrixSetter { >+ constructor(baseTypeName, height, width) >+ { >+ this._baseTypeName = baseTypeName; >+ this._height = height; >+ this._width = width; >+ } >+ >+ get baseTypeName() { return this._baseTypeName; } >+ get height() { return this._height; } >+ get width() { return this._width; } >+ >+ toString() >+ { >+ return `native ${this.baseTypeName}${this.height}x${this.width} operator[]=(${this.baseTypeName}${this.height}x${this.width},uint,${this.baseTypeName}${this.width})`; >+ } >+ >+ static functions() >+ { >+ if (!this._functions) { >+ this._functions = []; >+ >+ for (let typeName of ["half", "float"]) { >+ for (let height of [2, 3, 4]) { >+ for (let width of [2, 3, 4]) >+ this._functions.push(new BuiltinMatrixSetter(typeName, height, width)); >+ } >+ } >+ } >+ return this._functions; >+ } >+ >+ instantiateImplementation(func) >+ { >+ func.implementation = ([base, index, value]) => { >+ const indexValue = index.loadValue(); >+ if (indexValue >= 0 && indexValue < this.height) { >+ let result = new EPtr(new EBuffer(this.width * this.height), 0); >+ result.copyFrom(base, this.width * this.height); >+ result.plus(indexValue * this.width).copyFrom(value, this.width); >+ return result; >+ } else >+ throw new WTrapError("[Builtin matrix setter]", "Out-of-bounds index when indexing into a matrix"); >+ }; >+ func.implementationData = this; >+ } >+} >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js >deleted file mode 100644 >index 2704b43a06c2faed9dfa73dead33bb0c5c955985..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorConstructors.js >+++ /dev/null >@@ -1,84 +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 BuiltinVectorConstructors { >- constructor(baseTypeName, parameterSizes) >- { >- this._baseTypeName = baseTypeName; >- this._parameterSizes = parameterSizes; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- get parameterSizes() { return this._parameterSizes; } >- get outputSize() >- { >- return this.parameterSizes.reduce((a, b) => a + b, 0); >- } >- >- toString() >- { >- return `native operator ${this.baseTypeName}${this.outputSize}(${this.parameterSizes.map(x => x == 1 ? this.baseTypeName : this.baseTypeName + x).join(",")})`; >- } >- >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) { >- for (let paramSizes of this._vectorParameterSizesForMaximumSize(size)) >- this._functions.push(new BuiltinVectorConstructors(typeName, paramSizes)); >- } >- } >- } >- return this._functions; >- } >- >- static _vectorParameterSizesForMaximumSize(maxSize) >- { >- let variants = [ [ maxSize ] ]; >- for (let splitPoint = 1; splitPoint < maxSize; splitPoint++) { >- for (let v of BuiltinVectorConstructors._vectorParameterSizesForMaximumSize(maxSize - splitPoint)) >- variants.push([ splitPoint ].concat(v)); >- } >- return variants; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = (args) => { >- const result = new EPtr(new EBuffer(this.outputSize), 0); >- let offset = 0; >- for (let i = 0; i < args.length; i++) { >- for (let j = 0; j < this.parameterSizes[i]; j++) >- result.set(offset++, args[i].get(j)); >- } >- return result; >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorEqualityOperator.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorEqualityOperator.js >deleted file mode 100644 >index b183d356861941bc276e4d3c67c5e47ecafe4709..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorEqualityOperator.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 BuiltinVectorEqualityOperator { >- constructor(baseTypeName, size) >- { >- this._baseTypeName = baseTypeName; >- this._size = size; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- get size() { return this._size; } >- >- toString() >- { >- return `native bool operator==(${this.baseTypeName}${this.size},${this.baseTypeName}${this.size})`; >- } >- >- static functions() >- { >- if (!this._functions) { >- this._functions = []; >- >- for (let typeName of VectorElementTypes) { >- for (let size of VectorElementSizes) >- this._functions.push(new BuiltinVectorEqualityOperator(typeName, size)); >- } >- } >- return this._functions; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([ref1, ref2], node) => { >- for (let i = 0; i < this.size; i++) { >- if (ref1.get(i) != ref2.get(i)) >- return EPtr.box(false); >- } >- return EPtr.box(true); >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js b/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >index c253f7630ee9dc47cd1e1945bc87f42eaa3ccb28..40872b4f8e2bb3a8e4ffb26275d8d83fe72182f7 100644 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinVectorGetter.js >@@ -62,9 +62,9 @@ class BuiltinVectorGetter { > > instantiateImplementation(func) > { >- func.implementation = ([vec], node) => { >+ func.implementation = ([vec]) => { > return EPtr.box(vec.get(this.index)); > }; > 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..d559591e968671ef9035996a3fb6157ef97b25ec 100644 >--- a/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js >+++ b/Tools/WebGPUShadingLanguageRI/BuiltinVectorSetter.js >@@ -47,7 +47,7 @@ class BuiltinVectorSetter { > { > if (!this._functions) { > this._functions = []; >- >+ > const elements = [ "x", "y", "z", "w" ]; > > for (let typeName of VectorElementTypes) { >@@ -62,7 +62,7 @@ class BuiltinVectorSetter { > > instantiateImplementation(func) > { >- func.implementation = ([base, value], node) => { >+ func.implementation = ([base, value]) => { > let result = new EPtr(new EBuffer(this.size), 0); > result.copyFrom(base, this.size); > result.plus(this.index).copyFrom(value, 1); >@@ -70,4 +70,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 3b15455992e64e2677ba0b03ab6568ef43d5d865..5fbdd505f79d4b326e093e0fb76cd375d0a2c5ba 100644 >--- a/Tools/WebGPUShadingLanguageRI/CallExpression.js >+++ b/Tools/WebGPUShadingLanguageRI/CallExpression.js >@@ -52,19 +52,22 @@ class CallExpression extends Expression { > > resolve(possibleOverloads, program) > { >- if (!possibleOverloads) >- throw new WTypeError(this.origin.originString, "Did not find any functions named " + this.name); >- > let failures = []; >- let overload = resolveOverloadImpl(possibleOverloads, this.argumentTypes, this.returnType); >+ let overload; >+ if (possibleOverloads) >+ overload = resolveOverloadImpl(possibleOverloads, this.argumentTypes, this.returnType); > >- if (!overload.func) { >+ if (!overload || !overload.func) { >+ if (!overload) >+ overload = {}; > const func = this._resolveByInstantiation(program); > if (func) > overload.func = func; > } > > if (!overload.func) { >+ if (!overload.failures) >+ overload.failures = []; > failures.push(...overload.failures); > let message = "Did not find function named " + this.name + " for call with "; > message += "argument types (" + this.argumentTypes + ")"; >diff --git a/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js b/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js >index bb6b2bd498e77b149df4c68f4ef3ac1ff1cdaab2..2f69142a3517d294900530c0cf066c9bfd2277af 100644 >--- a/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js >+++ b/Tools/WebGPUShadingLanguageRI/CheckTypesWithArguments.js >@@ -29,8 +29,20 @@ function checkTypesWithArguments(program) > class TypeWithArgumentsChecker extends Visitor { > visitTypeRef(node) > { >- if (node.name == "vector" && node.typeArguments.length == 0) >- throw new Error("Builtin type ${node.name} should always have type arguments."); >+ 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 c69d5549bad93dbd243fa6693c86f0b59978cc59..5f598b2ee7522bbc810545c948d773f2e4f9947d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Checker.js >+++ b/Tools/WebGPUShadingLanguageRI/Checker.js >@@ -263,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) { >@@ -277,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/ConstexprFolder.js b/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >index 5451332d7f10c495cee94f6139645878abb071d2..36e5f6f35e579107339ab30b283808d3d7cf1e0c 100644 >--- a/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >+++ b/Tools/WebGPUShadingLanguageRI/ConstexprFolder.js >@@ -35,9 +35,9 @@ class ConstexprFolder extends Visitor { > > if (node.name == "operator-" > && node.argumentList.length == 1 >- && node.argumentList[0].unifyNode.isConstexpr >- && node.argumentList[0].unifyNode.negConstexpr) { >- node.become(node.argumentList[0].unifyNode.negConstexpr(node.origin)); >+ && node.argumentList[0].isLiteral >+ && node.argumentList[0].negConstexpr) { >+ node.become(node.argumentList[0].negConstexpr(node.origin)); > return; > } > } >diff --git a/Tools/WebGPUShadingLanguageRI/Evaluator.js b/Tools/WebGPUShadingLanguageRI/Evaluator.js >index 0290de23d441aa2f3a8c13290f21f1fcca6d2c7d..aee0a2312fed72c0c87e73f18ac348ea1ac3c7ba 100644 >--- a/Tools/WebGPUShadingLanguageRI/Evaluator.js >+++ b/Tools/WebGPUShadingLanguageRI/Evaluator.js >@@ -148,7 +148,6 @@ class Evaluator extends Visitor { > if (node.predicate.visit(this).loadValue()) > return node.bodyExpression.visit(this); > return node.elseExpression.visit(this); >- > } > > visitVariableRef(node) >diff --git a/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js b/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >index 53c8716c45046f87fc4f6cd53fa9f7a42c53e165..2739d7bf7fa4962c775f28c79ce58458bfd4a8e8 100644 >--- a/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >+++ b/Tools/WebGPUShadingLanguageRI/FlattenedStructOffsetGatherer.js >@@ -73,5 +73,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/FloatLiteralType.js b/Tools/WebGPUShadingLanguageRI/FloatLiteralType.js >index f7bb7f2c8b00cb3806cc56a5d25d8fe053873cd9..60ece415c693357db1beaf7e651047527801aec8 100644 >--- a/Tools/WebGPUShadingLanguageRI/FloatLiteralType.js >+++ b/Tools/WebGPUShadingLanguageRI/FloatLiteralType.js >@@ -32,8 +32,7 @@ let FloatLiteralType = createLiteralType({ > let realThis = unificationContext.find(this); > if (!realThis.isFloating) > return {result: false, reason: "Cannot use float literal with non-floating type " + realThis}; >- if (!realThis.canRepresent(this.value)) >- return {result: false, reason: "Float literal " + this.value + " does not fit in type " + realThis}; >+ // Floats can represent any number. > return {result: true}; > } > }); >diff --git a/Tools/WebGPUShadingLanguageRI/Intrinsics.js b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >index 72290632982ee108412e88b0882e41ce85a7301d..5547c1ad64278997378663f511dd163a942eb1af 100644 >--- a/Tools/WebGPUShadingLanguageRI/Intrinsics.js >+++ b/Tools/WebGPUShadingLanguageRI/Intrinsics.js >@@ -316,90 +316,242 @@ class Intrinsics { > } > } > >+ 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; >+ type.size = 1; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, {}); >+ }); >+ for (let i = 2; i <= 4; ++i) { >+ this._map.set( >+ `native typedef ${textureType}<${typeArgument}${i}>`, >+ type => { >+ this[`${textureType}<${typeArgument}${i}>`] = type; >+ type.size = 1; >+ type.populateDefaultValue = (buffer, offset) => buffer.set(offset, {}); >+ }); >+ } >+ } >+ } >+ >+ 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( >@@ -410,67 +562,65 @@ class Intrinsics { > }); > > 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( >@@ -481,223 +631,415 @@ class Intrinsics { > }); > > this._map.set( >- "native int operator|(int,int)", >+ "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 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 int operator^(int,int)", >+ "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)", >+ "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 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()) >>> 0); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.cos(value.loadValue()))); > }); > > this._map.set( >- "native int operator>>(int,uint)", >+ "native float sin(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >> right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.sin(value.loadValue()))); > }); > > this._map.set( >- "native uint operator>>(uint,uint)", >+ "native float tan(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >>> right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.tan(value.loadValue()))); > }); > > this._map.set( >- "native int operator~(int)", >+ "native float acos(float)", > func => { >- func.implementation = ([value]) => EPtr.box(~value.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.acos(value.loadValue()))); > }); > > this._map.set( >- "native uint operator~(uint)", >+ "native float asin(float)", > func => { >- func.implementation = ([value]) => EPtr.box((~value.loadValue()) >>> 0); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.asin(value.loadValue()))); > }); > > this._map.set( >- "native float operator/(float,float)", >+ "native float atan(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(Math.fround(left.loadValue() / right.loadValue())); >+ func.implementation = ([value]) => >+ EPtr.box(Math.fround(Math.atan(value.loadValue()))); > }); > > this._map.set( >- "native bool operator==(int,int)", >+ "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==(uint,uint)", >+ "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==(bool,bool)", >+ "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==(float,float)", >+ "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<(int,int)", >+ "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<(uint,uint)", >+ "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<(float,float)", >+ "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<=(int,int)", >+ "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<=(uint,uint)", >+ "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<=(float,float)", >+ "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>(int,int)", >+ "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>(uint,uint)", >+ "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>(float,float)", >+ "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 operator>=(int,int)", >+ "native bool isfinite(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ func.implementation = ([value]) => >+ EPtr.box(Number.isFinite(value.loadValue())); > }); > > this._map.set( >- "native bool operator>=(uint,uint)", >+ "native bool isinf(float)", > func => { >- func.implementation = ([left, right]) => >- EPtr.box(left.loadValue() >= right.loadValue()); >+ 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 operator>=(float,float)", >+ "native bool isnormal(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(isNaN(value.loadValue())); >+ }); >+ >+ this._map.set( >+ "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 typedef ${nativeVectorTypeName}`, type => { >- type.isPrimitive = true; >+ this._map.set( >+ "native int asint(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Float32Array, Int32Array, value.loadValue())); > }); > >- for (let swizzle of SwizzleOp.functions()) >- this._map.set(swizzle.toString(), func => swizzle.instantiateImplementation(func)); >+ this._map.set( >+ "native uint asuint(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Float32Array, Uint32Array, value.loadValue())); >+ }); > >- for (let boolOp of OperatorBool.functions()) >- this._map.set(boolOp.toString(), func => boolOp.instantiateImplementation(func)); >+ this._map.set( >+ "native float asfloat(int)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Int32Array, Float32Array, value.loadValue())); >+ }); > >- for (let anderIndex of OperatorAnderIndexer.functions()) >- this._map.set(anderIndex.toString(), func => anderIndex.instantiateImplementation(func)); >+ this._map.set( >+ "native float asfloat(uint)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(bitwiseCast(Uint32Array, Float32Array, value.loadValue())); >+ }); > >- for (let cast of BuiltinVectorConstructors.functions()) >- this._map.set(cast.toString(), func => cast.instantiateImplementation(func)); >+ // FIXME: Implement this. >+ this._map.set( >+ "native float f16tof32(uint)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(0); >+ }); > >- for (let getter of BuiltinVectorIndexGetter.functions()) >- this._map.set(getter.toString(), func => getter.instantiateImplementation(func)); >+ // FIXME: Implement this. >+ this._map.set( >+ "native uint f32tof16(float)", >+ func => { >+ func.implementation = ([value]) => >+ EPtr.box(0); >+ }); > >- for (let setter of BuiltinVectorIndexSetter.functions()) >- this._map.set(setter.toString(), func => setter.instantiateImplementation(func)); >+ this._map.set( >+ "native void AllMemoryBarrierWithGroupSync()", >+ func => { >+ func.implementation = function() {}; >+ }); >+ >+ this._map.set( >+ "native void DeviceMemoryBarrierWithGroupSync()", >+ func => { >+ func.implementation = function() {}; >+ }); > >- for (let equalityOperator of BuiltinVectorEqualityOperator.functions()) >- this._map.set(equalityOperator.toString(), func => equalityOperator.instantiateImplementation(func)); >+ 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 getter of BuiltinVectorGetter.functions()) > this._map.set(getter.toString(), func => getter.instantiateImplementation(func)); > > for (let setter of BuiltinVectorSetter.functions()) > this._map.set(setter.toString(), func => setter.instantiateImplementation(func)); >+ >+ for (let getter of BuiltinMatrixGetter.functions()) >+ this._map.set(getter.toString(), func => getter.instantiateImplementation(func)); >+ >+ for (let setter of BuiltinMatrixSetter.functions()) >+ this._map.set(setter.toString(), func => setter.instantiateImplementation(func)); >+ >+ for (let type of ["bool", "uchar", "ushort", "uint", "char", "short", "int", "half", "float"]) { >+ this._map.set( >+ `native ${type} Sample(Texture1D<${type}>,sampler,float location)`, >+ func => { >+ func.implementation = function([texture, sampler, location]) { >+ } >+ }); >+ this._map.set( >+ `native ${type} Sample(Texture1D<${type}>,sampler,float location,int offset)`, >+ func => { >+ func.implementation = function([texture, sampler, location, offset]) { >+ } >+ }); >+ this._map.set( >+ `native ${type} Load(Texture1D<${type}>,int2 location)`, >+ func => { >+ func.implementation = function ([texture, location]) { >+ var tex = texture.loadValue(); >+ var mipID = location.get(0); >+ if (mipID < 0 || mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ var mip = tex[mipID]; >+ var position = location.get(1); >+ if (position < 0 || position >= tex.mip) >+ throw new WTrapError("[load]", "Texture read not in bounds"); >+ return EPtr.box(mip[position]); >+ } >+ }); >+ this._map.set( >+ `native ${type} Load(Texture1D<${type}>,int2 location,int offset)`, >+ func => { >+ func.implementation = function ([texture, location, offset]) { >+ var tex = texture.loadValue(); >+ var mipID = location.get(0); >+ if (mipID < 0 || mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ var mip = tex[mipID]; >+ var position = location.get(1) + offset.loadValue(); >+ if (position < 0 || position >= tex.mip) >+ throw new WTrapError("[load]", "Texture read not in bounds"); >+ return EPtr.box(mip[position]); >+ } >+ }); >+ this._map.set( >+ `native void GetDimensions(Texture1D<${type}>,uint MipLevel,uint* thread Width,uint* thread NumberOfLevels)`, >+ func => { >+ func.implementation = function([texture, miplevel, width, numberOfLevels]) { >+ var tex = texture.loadValue(); >+ var mipID = miplevel.loadValue(); >+ if (mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ width.loadValue().copyFrom(EPtr.box(tex[mipID].length), 1); >+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.length), 1); >+ } >+ }); >+ >+ for (let length of [2, 3, 4]) { >+ this._map.set( >+ `native ${type}${length} Sample(Texture1D<${type}${length}>,sampler,float location)`, >+ func => { >+ func.implementation = function([texture, sampler, location]) { >+ } >+ }); >+ this._map.set( >+ `native ${type}${length} Sample(Texture1D<${type}${length}>,sampler,float location,int offset)`, >+ func => { >+ func.implementation = function([texture, sampler, location, offset]) { >+ } >+ }); >+ this._map.set( >+ `native ${type}${length} Load(Texture1D<${type}${length}>,int2 location)`, >+ func => { >+ func.implementation = function ([texture, location]) { >+ var tex = texture.loadValue(); >+ var mipID = location.get(0); >+ if (mipID < 0 || mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ var mip = tex[mipID]; >+ var position = location.get(1); >+ if (position < 0 || position >= tex.mip) >+ throw new WTrapError("[load]", "Texture read not in bounds"); >+ var element = mip[position]; >+ var result = new EPtr(new EBuffer(4), 0); >+ for (var i = 0; i < length; ++i) >+ result.set(i, element[i]); >+ return result; >+ } >+ }); >+ this._map.set( >+ `native ${type}${length} Load(Texture1D<${type}${length}>,int2 location,int offset)`, >+ func => { >+ func.implementation = function ([texture, location, offset]) { >+ var tex = texture.loadValue(); >+ var mipID = location.get(0); >+ if (mipID < 0 || mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ var mip = tex[mipID]; >+ var position = location.get(1) + offset.loadValue(); >+ if (position < 0 || position >= tex.mip) >+ throw new WTrapError("[load]", "Texture read not in bounds"); >+ var element = mip[position]; >+ var result = new EPtr(new EBuffer(4), 0); >+ for (var i = 0; i < length; ++i) >+ result.set(i, element[i]); >+ return result; >+ } >+ }); >+ this._map.set( >+ `native void GetDimensions(Texture1D<${type}${length}>,uint MipLevel,uint* thread Width,uint* thread NumberOfLevels)`, >+ func => { >+ func.implementation = function([texture, miplevel, width, numberOfLevels]) { >+ var tex = texture.loadValue(); >+ var mipID = miplevel.loadValue(); >+ if (mipID >= tex.length) >+ throw new WTrapError("[load]", "Reading from nonexistant mip level of texture"); >+ width.loadValue().copyFrom(EPtr.box(tex[mipID].length), 1); >+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.length), 1); >+ } >+ }); >+ } >+ } > } > > add(thing) >diff --git a/Tools/WebGPUShadingLanguageRI/MatrixType.js b/Tools/WebGPUShadingLanguageRI/MatrixType.js >new file mode 100644 >index 0000000000000000000000000000000000000000..bd996bf4633770685140b90052faa19dca6212a8 >--- /dev/null >+++ b/Tools/WebGPUShadingLanguageRI/MatrixType.js >@@ -0,0 +1,61 @@ >+/* >+ * 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.numColumnsValue !== 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 dc68578ff556b312b0927ef3c0dffa0068f1be63..c89968c779607b7cabcc6a5f969b4ab913e7263e 100644 >--- a/Tools/WebGPUShadingLanguageRI/NameContext.js >+++ b/Tools/WebGPUShadingLanguageRI/NameContext.js >@@ -71,7 +71,7 @@ class NameContext { > > if (thing.kind == Type) { > this._set.add(thing); >- if (thing.name == "vector") { >+ if (thing.typeArguments && thing.typeArguments.length != 0) { > let array = this._map.get(thing.name); > if (!array) { > array = []; >diff --git a/Tools/WebGPUShadingLanguageRI/NativeType.js b/Tools/WebGPUShadingLanguageRI/NativeType.js >index 2381b5a6b0b010e0fdd4dc53550a8ea6b4f8347b..b368a2e8b24f548eab88a2824b495be23c87cb85 100644 >--- a/Tools/WebGPUShadingLanguageRI/NativeType.js >+++ b/Tools/WebGPUShadingLanguageRI/NativeType.js >@@ -66,6 +66,8 @@ class NativeType extends Type { > { > if (name == "vector") > return new VectorType(origin, name, typeArguments); >+ if (name == "matrix") >+ return new MatrixType(origin, name, typeArguments); > > 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 9faca86e205755b2c6a66f412b5692e99e7b03af..834592d36f3457dfa86b5751bb7262472a3f0a2d 100644 >--- a/Tools/WebGPUShadingLanguageRI/Prepare.js >+++ b/Tools/WebGPUShadingLanguageRI/Prepare.js >@@ -46,7 +46,6 @@ let prepare = (() => { > resolveTypeDefsInTypes(program); > checkRecursiveTypes(program); > synthesizeStructAccessors(program); >- synthesizeOperatorBool(program); > synthesizeEnumFunctions(program); > synthesizeArrayOperatorLength(program); > synthesizeCopyConstructorOperator(program); >diff --git a/Tools/WebGPUShadingLanguageRI/Program.js b/Tools/WebGPUShadingLanguageRI/Program.js >index 1116c4f577562215fdd7428a317579a929165414..ac1defb4fbaaa6e8e13429734ccf4915339ba539 100644 >--- a/Tools/WebGPUShadingLanguageRI/Program.js >+++ b/Tools/WebGPUShadingLanguageRI/Program.js >@@ -51,7 +51,7 @@ class Program extends Node { > this.functions.set(statement.name, array = []); > array.push(statement); > } else if (statement instanceof Type) { >- if (statement.isNative && statement.name == "vector") { >+ if (statement.isNative && statement.typeArguments.length != 0) { > let array = this.types.get(statement.name); > if (!array) > this.types.set(statement.name, array = []); >diff --git a/Tools/WebGPUShadingLanguageRI/Rewriter.js b/Tools/WebGPUShadingLanguageRI/Rewriter.js >index 94d3a762e38fb921c584cbafff1f59478ebb791d..7c2dfba6955339884dbbf910478d43effdec65cf 100644 >--- a/Tools/WebGPUShadingLanguageRI/Rewriter.js >+++ b/Tools/WebGPUShadingLanguageRI/Rewriter.js >@@ -391,5 +391,11 @@ class Rewriter { > vecType._elementType = node.elementType.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 ff2c02c7bafca4d1e2cf833c6c79fa1cec89013c..78d008f835f9e9c234ef2df6d6deea3f7426ce65 100644 >--- a/Tools/WebGPUShadingLanguageRI/SPIRV.html >+++ b/Tools/WebGPUShadingLanguageRI/SPIRV.html >@@ -17,7 +17,6 @@ td { > <script src="CreateLiteral.js"></script> > <script src="CreateLiteralType.js"></script> > <script src="PropertyAccessExpression.js"></script> >- <script src="SwizzleOp.js"></script> > <script src="NativeType.js"></script> > > <script src="AddressSpace.js"></script> >@@ -29,12 +28,10 @@ td { > <script src="Block.js"></script> > <script src="BoolLiteral.js"></script> > <script src="Break.js"></script> >- <script src="BuiltinVectorConstructors.js"></script> >+ <script src="BuiltinMatrixGetter.js"></script> >+ <script src="BuiltinMatrixSetter.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> > <script src="Check.js"></script> >@@ -96,6 +93,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> >@@ -103,9 +101,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> >@@ -133,7 +130,6 @@ 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="TernaryExpression.js"></script> >diff --git a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >index 8190a4356923a61e5485bdd4f180d1383774898b..2f7119ad5bb6d89de5cd346442b2323783a614d7 100644 >--- a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >+++ b/Tools/WebGPUShadingLanguageRI/StandardLibrary.js >@@ -30,6 +30,8 @@ let standardLibrary = ` > // Intrinsics.js. > > // Need to bootstrap void first. >+// This was autogenerated from Generate_Standard_Library.swift! Do not edit!! >+ > native typedef void; > native typedef bool; > native typedef uchar; >@@ -42,7 +44,6 @@ native typedef half; > native typedef float; > native typedef atomic_int; > native typedef atomic_uint; >- > native typedef vector<bool, 2>; > typedef bool2 = vector<bool, 2>; > native typedef vector<bool, 3>; >@@ -98,40 +99,577 @@ 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); >@@ -144,62 +682,2534 @@ 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)); >+} >+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, 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); > >-bool operator^(bool a, bool b) >-{ >- if (a) >- return !b; >- return b; >+operator bool2(bool x, bool y) { >+ bool2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator bool3(bool x, bool y, bool z) { >+ bool3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator bool3(bool2 x, bool y) { >+ bool3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator bool3(bool x, bool2 y) { >+ bool3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator bool4(bool x, bool y, bool z, bool w) { >+ bool4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator bool4(bool2 x, bool y, bool z) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator bool4(bool x, bool2 y, bool z) { >+ bool4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator bool4(bool x, bool y, bool2 z) { >+ bool4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator bool4(bool2 x, bool2 y) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator bool4(bool3 x, bool y) { >+ bool4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator bool4(bool x, bool3 y) { >+ bool4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(bool2) { >+ return 2; >+} >+uint operator.length(bool3) { >+ return 3; >+} >+uint operator.length(bool4) { >+ return 4; >+} >+operator uchar2(uchar x, uchar y) { >+ uchar2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator uchar3(uchar x, uchar y, uchar z) { >+ uchar3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator uchar3(uchar2 x, uchar y) { >+ uchar3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator uchar3(uchar x, uchar2 y) { >+ uchar3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator uchar4(uchar x, uchar y, uchar z, uchar w) { >+ uchar4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator uchar4(uchar2 x, uchar y, uchar z) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator uchar4(uchar x, uchar2 y, uchar z) { >+ uchar4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator uchar4(uchar x, uchar y, uchar2 z) { >+ uchar4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator uchar4(uchar2 x, uchar2 y) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator uchar4(uchar3 x, uchar y) { >+ uchar4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator uchar4(uchar x, uchar3 y) { >+ uchar4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(uchar2) { >+ return 2; >+} >+uint operator.length(uchar3) { >+ return 3; >+} >+uint operator.length(uchar4) { >+ return 4; >+} >+operator ushort2(ushort x, ushort y) { >+ ushort2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator ushort3(ushort x, ushort y, ushort z) { >+ ushort3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator ushort3(ushort2 x, ushort y) { >+ ushort3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator ushort3(ushort x, ushort2 y) { >+ ushort3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator ushort4(ushort x, ushort y, ushort z, ushort w) { >+ ushort4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator ushort4(ushort2 x, ushort y, ushort z) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator ushort4(ushort x, ushort2 y, ushort z) { >+ ushort4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator ushort4(ushort x, ushort y, ushort2 z) { >+ ushort4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator ushort4(ushort2 x, ushort2 y) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator ushort4(ushort3 x, ushort y) { >+ ushort4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator ushort4(ushort x, ushort3 y) { >+ ushort4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(ushort2) { >+ return 2; >+} >+uint operator.length(ushort3) { >+ return 3; >+} >+uint operator.length(ushort4) { >+ return 4; >+} >+operator uint2(uint x, uint y) { >+ uint2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator uint3(uint x, uint y, uint z) { >+ uint3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator uint3(uint2 x, uint y) { >+ uint3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator uint3(uint x, uint2 y) { >+ uint3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator uint4(uint x, uint y, uint z, uint w) { >+ uint4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator uint4(uint2 x, uint y, uint z) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator uint4(uint x, uint2 y, uint z) { >+ uint4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator uint4(uint x, uint y, uint2 z) { >+ uint4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator uint4(uint2 x, uint2 y) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator uint4(uint3 x, uint y) { >+ uint4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator uint4(uint x, uint3 y) { >+ uint4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(uint2) { >+ return 2; >+} >+uint operator.length(uint3) { >+ return 3; >+} >+uint operator.length(uint4) { >+ return 4; >+} >+operator char2(char x, char y) { >+ char2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator char3(char x, char y, char z) { >+ char3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator char3(char2 x, char y) { >+ char3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator char3(char x, char2 y) { >+ char3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator char4(char x, char y, char z, char w) { >+ char4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator char4(char2 x, char y, char z) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator char4(char x, char2 y, char z) { >+ char4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator char4(char x, char y, char2 z) { >+ char4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator char4(char2 x, char2 y) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator char4(char3 x, char y) { >+ char4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator char4(char x, char3 y) { >+ char4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(char2) { >+ return 2; >+} >+uint operator.length(char3) { >+ return 3; >+} >+uint operator.length(char4) { >+ return 4; >+} >+operator short2(short x, short y) { >+ short2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator short3(short x, short y, short z) { >+ short3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator short3(short2 x, short y) { >+ short3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator short3(short x, short2 y) { >+ short3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator short4(short x, short y, short z, short w) { >+ short4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator short4(short2 x, short y, short z) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator short4(short x, short2 y, short z) { >+ short4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator short4(short x, short y, short2 z) { >+ short4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator short4(short2 x, short2 y) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator short4(short3 x, short y) { >+ short4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator short4(short x, short3 y) { >+ short4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(short2) { >+ return 2; >+} >+uint operator.length(short3) { >+ return 3; >+} >+uint operator.length(short4) { >+ return 4; >+} >+operator int2(int x, int y) { >+ int2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator int3(int x, int y, int z) { >+ int3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator int3(int2 x, int y) { >+ int3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator int3(int x, int2 y) { >+ int3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator int4(int x, int y, int z, int w) { >+ int4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator int4(int2 x, int y, int z) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator int4(int x, int2 y, int z) { >+ int4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator int4(int x, int y, int2 z) { >+ int4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator int4(int2 x, int2 y) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator int4(int3 x, int y) { >+ int4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator int4(int x, int3 y) { >+ int4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(int2) { >+ return 2; >+} >+uint operator.length(int3) { >+ return 3; >+} >+uint operator.length(int4) { >+ return 4; >+} >+operator half2(half x, half y) { >+ half2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator half3(half x, half y, half z) { >+ half3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator half3(half2 x, half y) { >+ half3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator half3(half x, half2 y) { >+ half3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator half4(half x, half y, half z, half w) { >+ half4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator half4(half2 x, half y, half z) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator half4(half x, half2 y, half z) { >+ half4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator half4(half x, half y, half2 z) { >+ half4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator half4(half2 x, half2 y) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator half4(half3 x, half y) { >+ half4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator half4(half x, half3 y) { >+ half4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(half2) { >+ return 2; >+} >+uint operator.length(half3) { >+ return 3; >+} >+uint operator.length(half4) { >+ return 4; >+} >+operator float2(float x, float y) { >+ float2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+operator float3(float x, float y, float z) { >+ float3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+operator float3(float2 x, float y) { >+ float3 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ return result; >+} >+operator float3(float x, float2 y) { >+ float3 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ return result; >+} >+operator float4(float x, float y, float z, float w) { >+ float4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ result.w = w; >+ return result; >+} >+operator float4(float2 x, float y, float z) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y; >+ result.w = z; >+ return result; >+} >+operator float4(float x, float2 y, float z) { >+ float4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = z; >+ return result; >+} >+operator float4(float x, float y, float2 z) { >+ float4 result; >+ result.x = x; >+ result.y = y; >+ result.z = z.x; >+ result.w = z.y; >+ return result; >+} >+operator float4(float2 x, float2 y) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = y.x; >+ result.w = y.y; >+ return result; >+} >+operator float4(float3 x, float y) { >+ float4 result; >+ result.x = x.x; >+ result.y = x.y; >+ result.z = x.z; >+ result.w = y; >+ return result; >+} >+operator float4(float x, float3 y) { >+ float4 result; >+ result.x = x; >+ result.y = y.x; >+ result.z = y.y; >+ result.w = y.z; >+ return result; >+} >+uint operator.length(float2) { >+ return 2; >+} >+uint operator.length(float3) { >+ return 3; >+} >+uint operator.length(float4) { >+ return 4; >+} >+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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+bool operator[](bool3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+bool operator[](bool4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+bool2 operator[]=(bool2 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+bool3 operator[]=(bool3 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+bool4 operator[]=(bool4 v, uint index, bool a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+uchar operator[](uchar3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+uchar operator[](uchar4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+uchar2 operator[]=(uchar2 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+uchar3 operator[]=(uchar3 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+uchar4 operator[]=(uchar4 v, uint index, uchar a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+ushort operator[](ushort3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+ushort operator[](ushort4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+ushort2 operator[]=(ushort2 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+ushort3 operator[]=(ushort3 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+ushort4 operator[]=(ushort4 v, uint index, ushort a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+uint operator[](uint3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+uint operator[](uint4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+uint2 operator[]=(uint2 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+uint3 operator[]=(uint3 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+uint4 operator[]=(uint4 v, uint index, uint a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+char operator[](char3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+char operator[](char4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+char2 operator[]=(char2 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+char3 operator[]=(char3 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+char4 operator[]=(char4 v, uint index, char a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+short operator[](short3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+short operator[](short4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+short2 operator[]=(short2 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+short3 operator[]=(short3 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+short4 operator[]=(short4 v, uint index, short a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+int operator[](int3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+int operator[](int4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+int2 operator[]=(int2 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+int3 operator[]=(int3 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+int4 operator[]=(int4 v, uint index, int a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+half operator[](half3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+half operator[](half4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+half2 operator[]=(half2 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+half3 operator[]=(half3 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+half4 operator[]=(half4 v, uint index, half a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ 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) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ default: >+ trap; >+ } >+} >+float operator[](float3 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ default: >+ trap; >+ } >+} >+float operator[](float4 v, uint index) { >+ switch (index) { >+ case 0: >+ return v.x; >+ case 1: >+ return v.y; >+ case 2: >+ return v.z; >+ case 3: >+ return v.w; >+ default: >+ trap; >+ } >+} >+float2 operator[]=(float2 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+float3 operator[]=(float3 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ default: >+ trap; >+ } >+ return v; >+} >+float4 operator[]=(float4 v, uint index, float a) { >+ switch (index) { >+ case 0: >+ v.x = a; >+ break; >+ case 1: >+ v.y = a; >+ break; >+ case 2: >+ v.z = a; >+ break; >+ case 3: >+ v.w = a; >+ break; >+ default: >+ trap; >+ } >+ return v; > } > >-bool operator~(bool value) >-{ >- return !value; >+native half2 operator[](half2x2, uint); >+native half2x2 operator[]=(half2x2, uint, half2); >+native half3 operator[](half2x3, uint); >+native half2x3 operator[]=(half2x3, uint, half3); >+native half4 operator[](half2x4, uint); >+native half2x4 operator[]=(half2x4, uint, half4); >+native half2 operator[](half3x2, uint); >+native half3x2 operator[]=(half3x2, uint, half2); >+native half3 operator[](half3x3, uint); >+native half3x3 operator[]=(half3x3, uint, half3); >+native half4 operator[](half3x4, uint); >+native half3x4 operator[]=(half3x4, uint, half4); >+native half2 operator[](half4x2, uint); >+native half4x2 operator[]=(half4x2, uint, half2); >+native half3 operator[](half4x3, uint); >+native half4x3 operator[]=(half4x3, uint, half3); >+native half4 operator[](half4x4, uint); >+native half4x4 operator[]=(half4x4, uint, half4); >+native float2 operator[](float2x2, uint); >+native float2x2 operator[]=(float2x2, uint, float2); >+native float3 operator[](float2x3, uint); >+native float2x3 operator[]=(float2x3, uint, float3); >+native float4 operator[](float2x4, uint); >+native float2x4 operator[]=(float2x4, uint, float4); >+native float2 operator[](float3x2, uint); >+native float3x2 operator[]=(float3x2, uint, float2); >+native float3 operator[](float3x3, uint); >+native float3x3 operator[]=(float3x3, uint, float3); >+native float4 operator[](float3x4, uint); >+native float3x4 operator[]=(float3x4, uint, float4); >+native float2 operator[](float4x2, uint); >+native float4x2 operator[]=(float4x2, uint, float2); >+native float3 operator[](float4x3, uint); >+native float4x3 operator[]=(float4x3, uint, float3); >+native float4 operator[](float4x4, uint); >+native float4x4 operator[]=(float4x4, uint, float4); >+ >+bool operator==(half2x2 a, half2x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ true; >+} >+bool operator==(half2x3 a, half2x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ true; >+} >+bool operator==(half2x4 a, half2x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ true; >+} >+bool operator==(half3x2 a, half3x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ true; >+} >+bool operator==(half3x3 a, half3x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ true; >+} >+bool operator==(half3x4 a, half3x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[2][3] == b[2][3] && >+ true; >+} >+bool operator==(half4x2 a, half4x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ true; >+} >+bool operator==(half4x3 a, half4x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ a[3][2] == b[3][2] && >+ true; >+} >+bool operator==(half4x4 a, half4x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[2][3] == b[2][3] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ a[3][2] == b[3][2] && >+ a[3][3] == b[3][3] && >+ true; >+} >+bool operator==(float2x2 a, float2x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ true; > } >+bool operator==(float2x3 a, float2x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ true; >+} >+bool operator==(float2x4 a, float2x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ true; >+} >+bool operator==(float3x2 a, float3x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ true; >+} >+bool operator==(float3x3 a, float3x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ true; >+} >+bool operator==(float3x4 a, float3x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[2][3] == b[2][3] && >+ true; >+} >+bool operator==(float4x2 a, float4x2 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ true; >+} >+bool operator==(float4x3 a, float4x3 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ a[3][2] == b[3][2] && >+ true; >+} >+bool operator==(float4x4 a, float4x4 b) { >+ return >+ a[0][0] == b[0][0] && >+ a[0][1] == b[0][1] && >+ a[0][2] == b[0][2] && >+ a[0][3] == b[0][3] && >+ a[1][0] == b[1][0] && >+ a[1][1] == b[1][1] && >+ a[1][2] == b[1][2] && >+ a[1][3] == b[1][3] && >+ a[2][0] == b[2][0] && >+ a[2][1] == b[2][1] && >+ a[2][2] == b[2][2] && >+ a[2][3] == b[2][3] && >+ a[3][0] == b[3][0] && >+ a[3][1] == b[3][1] && >+ a[3][2] == b[3][2] && >+ a[3][3] == b[3][3] && >+ true; >+} >+ >+native uchar Sample(Texture1D<uchar>, sampler, float location); >+native uchar Sample(Texture1D<uchar>, sampler, float location, int offset); >+native uchar Load(Texture1D<uchar>, int2 location); >+native uchar Load(Texture1D<uchar>, int2 location, int offset); >+native void GetDimensions(Texture1D<uchar>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uchar2 Sample(Texture1D<uchar2>, sampler, float location); >+native uchar2 Sample(Texture1D<uchar2>, sampler, float location, int offset); >+native uchar2 Load(Texture1D<uchar2>, int2 location); >+native uchar2 Load(Texture1D<uchar2>, int2 location, int offset); >+native void GetDimensions(Texture1D<uchar2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uchar3 Sample(Texture1D<uchar3>, sampler, float location); >+native uchar3 Sample(Texture1D<uchar3>, sampler, float location, int offset); >+native uchar3 Load(Texture1D<uchar3>, int2 location); >+native uchar3 Load(Texture1D<uchar3>, int2 location, int offset); >+native void GetDimensions(Texture1D<uchar3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uchar4 Sample(Texture1D<uchar4>, sampler, float location); >+native uchar4 Sample(Texture1D<uchar4>, sampler, float location, int offset); >+native uchar4 Load(Texture1D<uchar4>, int2 location); >+native uchar4 Load(Texture1D<uchar4>, int2 location, int offset); >+native void GetDimensions(Texture1D<uchar4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native ushort Sample(Texture1D<ushort>, sampler, float location); >+native ushort Sample(Texture1D<ushort>, sampler, float location, int offset); >+native ushort Load(Texture1D<ushort>, int2 location); >+native ushort Load(Texture1D<ushort>, int2 location, int offset); >+native void GetDimensions(Texture1D<ushort>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native ushort2 Sample(Texture1D<ushort2>, sampler, float location); >+native ushort2 Sample(Texture1D<ushort2>, sampler, float location, int offset); >+native ushort2 Load(Texture1D<ushort2>, int2 location); >+native ushort2 Load(Texture1D<ushort2>, int2 location, int offset); >+native void GetDimensions(Texture1D<ushort2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native ushort3 Sample(Texture1D<ushort3>, sampler, float location); >+native ushort3 Sample(Texture1D<ushort3>, sampler, float location, int offset); >+native ushort3 Load(Texture1D<ushort3>, int2 location); >+native ushort3 Load(Texture1D<ushort3>, int2 location, int offset); >+native void GetDimensions(Texture1D<ushort3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native ushort4 Sample(Texture1D<ushort4>, sampler, float location); >+native ushort4 Sample(Texture1D<ushort4>, sampler, float location, int offset); >+native ushort4 Load(Texture1D<ushort4>, int2 location); >+native ushort4 Load(Texture1D<ushort4>, int2 location, int offset); >+native void GetDimensions(Texture1D<ushort4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uint Sample(Texture1D<uint>, sampler, float location); >+native uint Sample(Texture1D<uint>, sampler, float location, int offset); >+native uint Load(Texture1D<uint>, int2 location); >+native uint Load(Texture1D<uint>, int2 location, int offset); >+native void GetDimensions(Texture1D<uint>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uint2 Sample(Texture1D<uint2>, sampler, float location); >+native uint2 Sample(Texture1D<uint2>, sampler, float location, int offset); >+native uint2 Load(Texture1D<uint2>, int2 location); >+native uint2 Load(Texture1D<uint2>, int2 location, int offset); >+native void GetDimensions(Texture1D<uint2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uint3 Sample(Texture1D<uint3>, sampler, float location); >+native uint3 Sample(Texture1D<uint3>, sampler, float location, int offset); >+native uint3 Load(Texture1D<uint3>, int2 location); >+native uint3 Load(Texture1D<uint3>, int2 location, int offset); >+native void GetDimensions(Texture1D<uint3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native uint4 Sample(Texture1D<uint4>, sampler, float location); >+native uint4 Sample(Texture1D<uint4>, sampler, float location, int offset); >+native uint4 Load(Texture1D<uint4>, int2 location); >+native uint4 Load(Texture1D<uint4>, int2 location, int offset); >+native void GetDimensions(Texture1D<uint4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native char Sample(Texture1D<char>, sampler, float location); >+native char Sample(Texture1D<char>, sampler, float location, int offset); >+native char Load(Texture1D<char>, int2 location); >+native char Load(Texture1D<char>, int2 location, int offset); >+native void GetDimensions(Texture1D<char>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native char2 Sample(Texture1D<char2>, sampler, float location); >+native char2 Sample(Texture1D<char2>, sampler, float location, int offset); >+native char2 Load(Texture1D<char2>, int2 location); >+native char2 Load(Texture1D<char2>, int2 location, int offset); >+native void GetDimensions(Texture1D<char2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native char3 Sample(Texture1D<char3>, sampler, float location); >+native char3 Sample(Texture1D<char3>, sampler, float location, int offset); >+native char3 Load(Texture1D<char3>, int2 location); >+native char3 Load(Texture1D<char3>, int2 location, int offset); >+native void GetDimensions(Texture1D<char3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native char4 Sample(Texture1D<char4>, sampler, float location); >+native char4 Sample(Texture1D<char4>, sampler, float location, int offset); >+native char4 Load(Texture1D<char4>, int2 location); >+native char4 Load(Texture1D<char4>, int2 location, int offset); >+native void GetDimensions(Texture1D<char4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native short Sample(Texture1D<short>, sampler, float location); >+native short Sample(Texture1D<short>, sampler, float location, int offset); >+native short Load(Texture1D<short>, int2 location); >+native short Load(Texture1D<short>, int2 location, int offset); >+native void GetDimensions(Texture1D<short>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native short2 Sample(Texture1D<short2>, sampler, float location); >+native short2 Sample(Texture1D<short2>, sampler, float location, int offset); >+native short2 Load(Texture1D<short2>, int2 location); >+native short2 Load(Texture1D<short2>, int2 location, int offset); >+native void GetDimensions(Texture1D<short2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native short3 Sample(Texture1D<short3>, sampler, float location); >+native short3 Sample(Texture1D<short3>, sampler, float location, int offset); >+native short3 Load(Texture1D<short3>, int2 location); >+native short3 Load(Texture1D<short3>, int2 location, int offset); >+native void GetDimensions(Texture1D<short3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native short4 Sample(Texture1D<short4>, sampler, float location); >+native short4 Sample(Texture1D<short4>, sampler, float location, int offset); >+native short4 Load(Texture1D<short4>, int2 location); >+native short4 Load(Texture1D<short4>, int2 location, int offset); >+native void GetDimensions(Texture1D<short4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native int Sample(Texture1D<int>, sampler, float location); >+native int Sample(Texture1D<int>, sampler, float location, int offset); >+native int Load(Texture1D<int>, int2 location); >+native int Load(Texture1D<int>, int2 location, int offset); >+native void GetDimensions(Texture1D<int>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native int2 Sample(Texture1D<int2>, sampler, float location); >+native int2 Sample(Texture1D<int2>, sampler, float location, int offset); >+native int2 Load(Texture1D<int2>, int2 location); >+native int2 Load(Texture1D<int2>, int2 location, int offset); >+native void GetDimensions(Texture1D<int2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native int3 Sample(Texture1D<int3>, sampler, float location); >+native int3 Sample(Texture1D<int3>, sampler, float location, int offset); >+native int3 Load(Texture1D<int3>, int2 location); >+native int3 Load(Texture1D<int3>, int2 location, int offset); >+native void GetDimensions(Texture1D<int3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native int4 Sample(Texture1D<int4>, sampler, float location); >+native int4 Sample(Texture1D<int4>, sampler, float location, int offset); >+native int4 Load(Texture1D<int4>, int2 location); >+native int4 Load(Texture1D<int4>, int2 location, int offset); >+native void GetDimensions(Texture1D<int4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native half Sample(Texture1D<half>, sampler, float location); >+native half Sample(Texture1D<half>, sampler, float location, int offset); >+native half Load(Texture1D<half>, int2 location); >+native half Load(Texture1D<half>, int2 location, int offset); >+native void GetDimensions(Texture1D<half>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native half2 Sample(Texture1D<half2>, sampler, float location); >+native half2 Sample(Texture1D<half2>, sampler, float location, int offset); >+native half2 Load(Texture1D<half2>, int2 location); >+native half2 Load(Texture1D<half2>, int2 location, int offset); >+native void GetDimensions(Texture1D<half2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native half3 Sample(Texture1D<half3>, sampler, float location); >+native half3 Sample(Texture1D<half3>, sampler, float location, int offset); >+native half3 Load(Texture1D<half3>, int2 location); >+native half3 Load(Texture1D<half3>, int2 location, int offset); >+native void GetDimensions(Texture1D<half3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native half4 Sample(Texture1D<half4>, sampler, float location); >+native half4 Sample(Texture1D<half4>, sampler, float location, int offset); >+native half4 Load(Texture1D<half4>, int2 location); >+native half4 Load(Texture1D<half4>, int2 location, int offset); >+native void GetDimensions(Texture1D<half4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native float Sample(Texture1D<float>, sampler, float location); >+native float Sample(Texture1D<float>, sampler, float location, int offset); >+native float Load(Texture1D<float>, int2 location); >+native float Load(Texture1D<float>, int2 location, int offset); >+native void GetDimensions(Texture1D<float>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native float2 Sample(Texture1D<float2>, sampler, float location); >+native float2 Sample(Texture1D<float2>, sampler, float location, int offset); >+native float2 Load(Texture1D<float2>, int2 location); >+native float2 Load(Texture1D<float2>, int2 location, int offset); >+native void GetDimensions(Texture1D<float2>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native float3 Sample(Texture1D<float3>, sampler, float location); >+native float3 Sample(Texture1D<float3>, sampler, float location, int offset); >+native float3 Load(Texture1D<float3>, int2 location); >+native float3 Load(Texture1D<float3>, int2 location, int offset); >+native void GetDimensions(Texture1D<float3>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+native float4 Sample(Texture1D<float4>, sampler, float location); >+native float4 Sample(Texture1D<float4>, sampler, float location, int offset); >+native float4 Load(Texture1D<float4>, int2 location); >+native float4 Load(Texture1D<float4>, int2 location, int offset); >+native void GetDimensions(Texture1D<float4>, uint MipLevel, thread uint* Width, thread uint* NumberOfLevels); >+ > `; > > // FIXME: Once the standard library has been replaced with a new version, this comments should be removed. >@@ -217,22 +3227,3 @@ 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. >-standardLibrary += SwizzleOp.functions().join(";\n") + ";\n"; >-standardLibrary += BuiltinVectorConstructors.functions().join(";\n") + ";\n"; >diff --git a/Tools/WebGPUShadingLanguageRI/SwizzleOp.js b/Tools/WebGPUShadingLanguageRI/SwizzleOp.js >deleted file mode 100644 >index 25998ef79d98a5288209875d346cf5509e9ba726..0000000000000000000000000000000000000000 >--- a/Tools/WebGPUShadingLanguageRI/SwizzleOp.js >+++ /dev/null >@@ -1,107 +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 SwizzleOp { >- constructor(baseTypeName, outSize, components, inSize) >- { >- this._baseTypeName = baseTypeName; >- this._outSize = outSize; >- this._components = components.slice(); // Shallow clone >- this._inSize = inSize; >- } >- >- get baseTypeName() { return this._baseTypeName; } >- get outSize() { return this._outSize; } >- get components() { return this._components; } >- get inSize() { return this._inSize; } >- >- toString() >- { >- return `native ${this.baseTypeName}${this.outSize} operator.${this.components.join("")}(${this.baseTypeName}${this.inSize} v)`; >- } >- >- static intToString(x) >- { >- switch (x) { >- case 0: >- return "x"; >- case 1: >- return "y"; >- case 2: >- return "z"; >- case 3: >- return "w"; >- default: >- throw new Error("Could not generate standard library."); >- } >- } >- >- static functions() >- { >- if (!this._functions) { >- // We can't directly use this._functions in _generateSwizzles. >- const functions = []; >- >- function _generateSwizzle(baseTypeName, maxDepth, maxItems, array) { >- if (!array) >- array = []; >- if (array.length == maxDepth) { >- functions.push(new SwizzleOp(baseTypeName, array.length, array, maxItems)); >- return; >- } >- for (let i = 0; i < maxItems; ++i) { >- array.push(SwizzleOp.intToString(i)); >- _generateSwizzle(baseTypeName, maxDepth, maxItems, array); >- array.pop(); >- } >- }; >- >- for (let typeName of VectorElementTypes) { >- for (let maxDepth of VectorElementSizes) { >- for (let maxItems = 2; maxItems <= 4; maxItems++) >- _generateSwizzle(typeName, maxDepth, maxItems); >- } >- } >- >- this._functions = functions; >- } >- return this._functions; >- } >- >- instantiateImplementation(func) >- { >- func.implementation = ([vec], node) => { >- const outputBuffer = new EBuffer(this.outSize); >- const readIndices = { 'x': 0, 'y': 1, 'z': 2, 'w': 3 }; >- for (let i = 0; i < this.outSize; i++) >- outputBuffer.set(i, vec.get(readIndices[this.components[i]])); >- >- >- return new EPtr(outputBuffer, 0); >- }; >- func.implementationData = this; >- } >-} >\ No newline at end of file >diff --git a/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js b/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >index 3a3f7673867b9aab013221803568738c163a567e..dc506538d1c6c7109b1ad1ecba3cec278d0f7b5c 100644 >--- a/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >+++ b/Tools/WebGPUShadingLanguageRI/SynthesizeDefaultConstructorOperator.js >@@ -51,6 +51,12 @@ function synthesizeDefaultConstructorOperator(program) > 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/Test.html b/Tools/WebGPUShadingLanguageRI/Test.html >index 7d26d2607a95f9bf64df1bca91658f2e748c043d..fa9234e5a6bd21f70b1dfe961613a1606d0789d4 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.html >+++ b/Tools/WebGPUShadingLanguageRI/Test.html >@@ -11,7 +11,6 @@ > <script src="CreateLiteral.js"></script> > <script src="CreateLiteralType.js"></script> > <script src="PropertyAccessExpression.js"></script> >-<script src="SwizzleOp.js"></script> > <script src="NativeType.js"></script> > > <script src="AddressSpace.js"></script> >@@ -23,12 +22,10 @@ > <script src="Block.js"></script> > <script src="BoolLiteral.js"></script> > <script src="Break.js"></script> >-<script src="BuiltinVectorConstructors.js"></script> >+<script src="BuiltinMatrixGetter.js"></script> >+<script src="BuiltinMatrixSetter.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> > <script src="Check.js"></script> >@@ -90,6 +87,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> >@@ -97,9 +95,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> >@@ -127,7 +124,6 @@ > <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="TernaryExpression.js"></script> >@@ -156,7 +152,7 @@ > <script> > function doTestInBrowser() > { >- var tester = doTest(/.*/); >+ var tester = doTest(/texture/); > var lastTime; > function next() > { >diff --git a/Tools/WebGPUShadingLanguageRI/Test.js b/Tools/WebGPUShadingLanguageRI/Test.js >index 4f395a94cc7283dd62a004fa1d4c3b9faad30a61..e851fecd794ebb300b7d2be2b8e745bd48b17148 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.js >+++ b/Tools/WebGPUShadingLanguageRI/Test.js >@@ -78,6 +78,150 @@ function makeFloat(program, value) > return TypedValue.box(program.intrinsics.float, value); > } > >+function makeSampler(program, samplerData) >+{ >+ // enum AddressMode { >+ // "clampToEdge", >+ // "mirrorClampToEdge", >+ // "repeat", >+ // "mirrorRepeat", >+ // "clampToBorderColor" >+ // } >+ // >+ // enum Filter { >+ // "nearest", >+ // "linear" >+ // } >+ // >+ // enum CompareFunction { >+ // "never", >+ // "less", >+ // "equal", >+ // "lessEqual", >+ // "greater", >+ // "notEqual", >+ // "greaterEqual", >+ // "always" >+ // } >+ // >+ // enum BorderColor { >+ // "transparentBlack", >+ // "opaqueBlack", >+ // "opaqueWhite" >+ // } >+ // >+ // dictionary SamplerData { >+ // AddressMode rAddressMode = "clampToEdge", >+ // AddressMode sAddressMode = "clampToEdge", >+ // AddressMode tAddressMode = "clampToEdge", >+ // Filter minFilter = "nearest", >+ // Filter magFilter = "nearest", >+ // Filter mipFilter = "nearest", >+ // float lodMinClamp = 0, >+ // float lodMaxClamp = FLT_MAX, >+ // unsigned long maxAnisotropy = 1, >+ // boolean normalizedCoordinates = true, >+ // CompareFunction compareFunction = "never", >+ // BorderColor borderColor = "transparentBlack" >+ // float bias = 0; >+ // } >+ // >+ return TypedValue.box(program.intrinsics.sampler, samplerData); >+} >+ >+function isPowerOf2(x) >+{ >+ return x && (x & (x - 1)) === 0; >+} >+ >+function elementVectorSize(elementType) >+{ >+ switch (elementType) { >+ case "bool": >+ case "uchar": >+ case "ushort": >+ case "uint": >+ case "char": >+ case "short": >+ case "int": >+ case "half": >+ case "float": >+ return null; >+ case "bool2": >+ case "uchar2": >+ case "ushort2": >+ case "uint2": >+ case "char2": >+ case "short2": >+ case "int2": >+ case "half2": >+ case "float2": >+ return 2; >+ case "bool3": >+ case "uchar3": >+ case "ushort3": >+ case "uint3": >+ case "char3": >+ case "short3": >+ case "int3": >+ case "half3": >+ case "float3": >+ return 3; >+ case "bool4": >+ case "uchar4": >+ case "ushort4": >+ case "uint4": >+ case "char4": >+ case "short4": >+ case "int4": >+ case "half4": >+ case "float4": >+ return 4; >+ default: >+ throw new Error("Unknown vector element type"); >+ } >+} >+ >+function make1DTexture(program, mipmaps, elementType) >+{ >+ var vectorSize = elementVectorSize(elementType); >+ >+ if (!(mipmaps instanceof Array)) >+ throw new Error("Texture needs to be an array of mipmaps"); >+ if (mipmaps.length == 0) >+ throw new Error("Need to have at least 1 mipmap"); >+ var size = mipmaps[0].length; >+ if (!isPowerOf2(size)) >+ throw new Error("Textures must be power-of-two sized"); >+ for (var mipmap of mipmaps) { >+ if (size == 0) >+ throw new Error("Cannot have zero-sized mipmap"); >+ if (!(mipmap instanceof Array)) >+ throw new Error("Each mipmap of a texture needs to be an array of values"); >+ if (mipmap.length != size) >+ throw new Error("Each mipmap of a texture must be half as big as the previous one"); >+ for (var element of mipmap) { >+ if (vectorSize == null && (typeof element) != "number") { >+ throw new Error(`${elementType} texture element must be a number`); >+ } else if (vectorSize != null) { >+ if (!(element instanceof Array)) >+ throw new Error(`${elementType} texture element must be an array`); >+ if (element.size != vectorSize) >+ throw new Error("Wrong number of components in texture element"); >+ for (var component of element) { >+ if ((typeof component) != "number") >+ throw new Error("Component needs to be a number"); >+ } >+ } >+ } >+ if (size == 1) >+ size = 0; >+ else >+ size /= 2; >+ } >+ return TypedValue.box(program.intrinsics[`Texture1D<${elementType}>`], mipmaps); >+} >+ > function makeEnum(program, enumName, value) > { > let enumType = program.types.get(enumName); >@@ -181,6 +325,35 @@ tests = new Proxy({}, { > } > }); > >+tests.textureDimensions = function() { >+ let program = doPrep(` >+ uint foo(Texture1D<float> texture) { >+ uint width; >+ uint numberOfLevels; >+ GetDimensions(texture, 0, &width, &numberOfLevels); >+ return width; >+ } >+ uint bar(Texture1D<float> texture) { >+ uint width; >+ uint numberOfLevels; >+ GetDimensions(texture, 0, &width, &numberOfLevels); >+ return numberOfLevels; >+ } >+ `); >+ checkUint(program, callFunction(program, "foo", [make1DTexture(program, [[1, 7, 14, 79], [13, 16], [15]], "float")]), 4); >+ checkUint(program, callFunction(program, "bar", [make1DTexture(program, [[1, 7, 14, 79], [13, 16], [15]], "float")]), 3); >+} >+ >+tests.textureLoad = function() { >+ let program = doPrep(` >+ float foo(Texture1D<float> texture, int mipmap, int location) { >+ return Load(texture, int2(mipmap, location)); >+ } >+ `); >+ checkFloat(program, callFunction(program, "foo", [make1DTexture(program, [[1, 7, 14, 79], [13, 16], [15]], "float"), makeInt(program, 0), makeInt(program, 1)]), 7); >+ checkFloat(program, callFunction(program, "foo", [make1DTexture(program, [[1, 7, 14, 79], [13, 16], [15]], "float"), makeInt(program, 1), makeInt(program, 1)]), 16); >+} >+ > tests.commentParsing = function() { > let program = doPrep(` > /* this comment >@@ -2215,41 +2388,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); >@@ -2263,27 +2401,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() >@@ -3548,6 +3665,7 @@ tests.trap = function() > e => e instanceof WTrapError); > } > >+/* > tests.swizzle = function() > { > let program = doPrep(` >@@ -3572,6 +3690,7 @@ tests.swizzle = function() > checkFloat(program, callFunction(program, "foo2", []), 6); > checkFloat(program, callFunction(program, "foo3", []), 4); > } >+*/ > > tests.enumWithExplicitIntBase = function() > { >diff --git a/Tools/WebGPUShadingLanguageRI/Visitor.js b/Tools/WebGPUShadingLanguageRI/Visitor.js >index 1f1f54d8cca75c110198e5084588790791de0e58..b9ea7e463c4e08bdf86fe9076ead405876d11592 100644 >--- a/Tools/WebGPUShadingLanguageRI/Visitor.js >+++ b/Tools/WebGPUShadingLanguageRI/Visitor.js >@@ -340,5 +340,12 @@ class Visitor { > 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 17d0c20c9fd638fb30eed7bb62204aa097c5acbd..65a86411b3e770b557b41acc7e414def42403013 100644 >--- a/Tools/WebGPUShadingLanguageRI/index.html >+++ b/Tools/WebGPUShadingLanguageRI/index.html >@@ -11,7 +11,6 @@ > <script src="CreateLiteral.js"></script> > <script src="CreateLiteralType.js"></script> > <script src="PropertyAccessExpression.js"></script> >-<script src="SwizzleOp.js"></script> > <script src="NativeType.js"></script> > > <script src="AddressSpace.js"></script> >@@ -23,12 +22,10 @@ > <script src="Block.js"></script> > <script src="BoolLiteral.js"></script> > <script src="Break.js"></script> >-<script src="BuiltinVectorConstructors.js"></script> >+<script src="BuiltinMatrixGetter.js"></script> >+<script src="BuiltinMatrixSetter.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> > <script src="Check.js"></script> >@@ -90,6 +87,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> >@@ -97,9 +95,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> >@@ -127,7 +124,6 @@ > <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="TernaryExpression.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 188940
:
348066
|
348347
|
348365
|
348376
|
348433
|
348459
|
348464
|
348467
|
348521
|
348581
|
348582
|
348607
|
348661
|
348687
|
348695
|
348698
|
348705
|
348717
|
348718
|
348723
|
348724
|
348726
|
348727
|
348752
|
348758
|
348775
|
348791
|
348797
|
348798
|
348800
|
348801
|
348804