Modified: trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js (235641 => 235642)
--- trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2018-09-04 21:41:19 UTC (rev 235641)
+++ trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2018-09-04 21:41:54 UTC (rev 235642)
@@ -36,11 +36,11 @@
print(`// This was autogenerated from Generate_Standard_Library.swift! Do not edit!!`);
print();
- for (var type of [`void`, `bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`, `atomic_int`, `atomic_uint`]) {
+ for (let type of [`void`, `bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`, `atomic_int`, `atomic_uint`]) {
print(`native typedef ${type};`);
}
- for (var type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`native typedef vector<${type}, ${size}>;`);
print(`typedef ${type}${size} = vector<${type}, ${size}>;`);
}
@@ -47,9 +47,9 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`native typedef matrix<${type}, ${i}, ${j}>;`);
print(`typedef ${type}${i}x${j} = matrix<${type}, ${i}, ${j}>;`);
}
@@ -56,22 +56,22 @@
}
}
print(`native typedef sampler;`);
- for (var type of [`Texture1D`, `RWTexture1D`, `Texture1DArray`, `RWTexture1DArray`, `Texture2D`, `RWTexture2D`, `Texture2DArray`, `RWTexture2DArray`, `Texture3D`, `RWTexture3D`, `TextureCube`]) {
- for (var typeArgumentBase of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`Texture1D`, `RWTexture1D`, `Texture1DArray`, `RWTexture1DArray`, `Texture2D`, `RWTexture2D`, `Texture2DArray`, `RWTexture2DArray`, `Texture3D`, `RWTexture3D`, `TextureCube`]) {
+ for (let typeArgumentBase of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`native typedef ${type}<${typeArgumentBase}${size}>;`);
}
}
}
- for (var type of [`TextureDepth2D`, `RWTextureDepth2D`, `TextureDepth2DArray`, `RWTextureDepth2DArray`, `TextureDepthCube`]) {
- for (var typeArgument of [`float`, `half`]) {
+ for (let type of [`TextureDepth2D`, `RWTextureDepth2D`, `TextureDepth2DArray`, `RWTextureDepth2DArray`, `TextureDepthCube`]) {
+ for (let typeArgument of [`float`, `half`]) {
print(`native typedef ${type}<${typeArgument}>;`);
}
}
print();
- for (var type1 of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var type2 of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type1 of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type2 of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
if (type1 != type2) {
print(`native operator ${type1}(${type2});`);
}
@@ -79,7 +79,7 @@
}
print();
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`operator bool(${type} x) {`);
print(` return x != 0;`);
print(`}`);
@@ -110,7 +110,7 @@
print(` return !value;`);
print(`}`);
- for (var type of [`int`, `uint`, `float`]) {
+ for (let type of [`int`, `uint`, `float`]) {
print(`native ${type} operator+(${type}, ${type});`);
print(`native ${type} operator-(${type}, ${type});`);
print(`native ${type} operator*(${type}, ${type});`);
@@ -122,7 +122,7 @@
print(`native bool operator>=(${type}, ${type});`);
}
- for (var type of [`int`, `uint`]) {
+ for (let type of [`int`, `uint`]) {
print(`native ${type} operator&(${type}, ${type});`);
print(`native ${type} operator|(${type}, ${type});`);
print(`native ${type} operator^(${type}, ${type});`);
@@ -131,7 +131,7 @@
print(`native ${type} operator>>(${type}, uint);`);
}
- for (var type of [`uchar`, `ushort`]) {
+ for (let type of [`uchar`, `ushort`]) {
print(`${type} operator+(${type} a, ${type} b) {`);
print(` return ${type}(uint(a) + uint(b));`);
print(`}`);
@@ -185,7 +185,7 @@
print(` return ushort(uint(a) >> (b & 65535));`);
print(`}`);
- for (var type of [`char`, `short`]) {
+ for (let type of [`char`, `short`]) {
print(`${type} operator+(${type} a, ${type} b) {`);
print(` return ${type}(int(a) + int(b));`);
print(`}`);
@@ -239,7 +239,7 @@
print(` return short(int(a) >> (b & 65535));`);
print(`}`);
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`${type} operator++(${type} value) {`);
print(` return value + 1;`);
print(`}`);
@@ -288,11 +288,11 @@
print(`native float operator-(float);`);
print();
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} operator+(${type}${size} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] + b[${m}];`);
}
print(` return result;`);
@@ -299,7 +299,7 @@
print(`}`);
print(`${type}${size} operator-(${type}${size} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] - b[${m}];`);
}
print(` return result;`);
@@ -306,7 +306,7 @@
print(`}`);
print(`${type}${size} operator*(${type}${size} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] * b[${m}];`);
}
print(` return result;`);
@@ -313,7 +313,7 @@
print(`}`);
print(`${type}${size} operator*(${type}${size} a, ${type} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] * b;`);
}
print(` return result;`);
@@ -320,7 +320,7 @@
print(`}`);
print(`${type}${size} operator*(${type} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a * b[${m}];`);
}
print(` return result;`);
@@ -327,7 +327,7 @@
print(`}`);
print(`${type}${size} operator/(${type}${size} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] / b[${m}];`);
}
print(` return result;`);
@@ -334,7 +334,7 @@
print(`}`);
print(`${type}${size} operator/(${type}${size} a, ${type} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a[${m}] / b;`);
}
print(` return result;`);
@@ -341,7 +341,7 @@
print(`}`);
print(`${type}${size} operator/(${type} a, ${type}${size} b) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = a / b[${m}];`);
}
print(` return result;`);
@@ -348,11 +348,11 @@
print(`}`);
}
}
- for (var type of [`char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} operator-(${type}${size} a) {`);
print(` ${type}${size} result;`);
- for (var m = 0; m < size; ++m) {
+ for (let m = 0; m < size; ++m) {
print(` result[${m}] = -a[${m}];`);
}
print(` return result;`);
@@ -359,13 +359,13 @@
print(`}`);
}
}
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} operator+(${type}${i}x${j} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] + b[${m}][${n}];`);
}
}
@@ -373,8 +373,8 @@
print(`}`);
print(`${type}${i}x${j} operator-(${type}${i}x${j} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] - b[${m}][${n}];`);
}
}
@@ -382,8 +382,8 @@
print(`}`);
print(`${type}${i}x${j} operator-(${type}${i}x${j} a) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = -a[${m}][${n}];`);
}
}
@@ -391,8 +391,8 @@
print(`}`);
print(`${type}${i}x${j} operator*(${type}${i}x${j} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] * b[${m}][${n}];`);
}
}
@@ -400,8 +400,8 @@
print(`}`);
print(`${type}${i}x${j} operator*(${type}${i}x${j} a, ${type} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] * b;`);
}
}
@@ -409,8 +409,8 @@
print(`}`);
print(`${type}${i}x${j} operator*(${type} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a * b[${m}][${n}];`);
}
}
@@ -418,8 +418,8 @@
print(`}`);
print(`${type}${i}x${j} operator/(${type}${i}x${j} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] / b[${m}][${n}];`);
}
}
@@ -427,8 +427,8 @@
print(`}`);
print(`${type}${i}x${j} operator/(${type}${i}x${j} a, ${type} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a[${m}][${n}] / b;`);
}
}
@@ -436,8 +436,8 @@
print(`}`);
print(`${type}${i}x${j} operator/(${type} a, ${type}${i}x${j} b) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = a / b[${m}][${n}];`);
}
}
@@ -447,7 +447,7 @@
}
}
- for (var type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`operator ${type}2(${type} x, ${type} y) {`);
print(` ${type}2 result;`);
print(` result.x = x;`);
@@ -543,12 +543,12 @@
}
print();
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
let variables = [`a`, `b`, `c`, `d`];
- for (var m of [2, 3, 4]) {
- for (var n of [2, 3, 4]) {
+ for (let m of [2, 3, 4]) {
+ for (let n of [2, 3, 4]) {
let signature = `operator ${type}${m}x${n}(`;
- for (var i = 0; i < m; ++i) {
+ for (let i = 0; i < m; ++i) {
if (i != 0) {
signature += `, `;
}
@@ -557,7 +557,7 @@
signature += `) {`;
print(signature);
print(` ${type}${m}x${n} result;`);
- for (var i = 0; i < m; ++i) {
+ for (let i = 0; i < m; ++i) {
print(` result[${i}] = ${variables[i]};`);
}
print(` return result;`);
@@ -567,7 +567,7 @@
}
print();
- for (var type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`bool operator==(${type}2 a, ${type}2 b) {`);
print(` return a.x == b.x && a.y == b.y;`);
print(`}`);
@@ -682,9 +682,9 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var m of [2, 3, 4]) {
- for (var n of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let m of [2, 3, 4]) {
+ for (let n of [2, 3, 4]) {
print(`native ${type}${n} operator[](${type}${m}x${n}, uint);`);
print(`native ${type}${m}x${n} operator[]=(${type}${m}x${n}, uint, ${type}${n});`);
}
@@ -692,13 +692,13 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`bool operator==(${type}${i}x${j} a, ${type}${i}x${j} b) {`);
print(` return`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` a[${m}][${n}] == b[${m}][${n}] &&`);
}
}
@@ -713,7 +713,7 @@
return [components];
} else {
let result = [];
- for (var i = 0; i < maxValue; ++i) {
+ for (let i = 0; i < maxValue; ++i) {
result = result.concat(computeSwizzle(components.concat([i]), maxValue, maxLength));
}
return result;
@@ -735,12 +735,12 @@
}
}
- function uniqueLength([Int]) {
+ function uniqueLength(swizzle) {
let has0 = false;
let has1 = false;
let has2 = false;
let has3 = false;
- for (var v of swizzle) {
+ for (let v of swizzle) {
switch (v) {
case 0:
has0 = true;
@@ -775,14 +775,14 @@
}
/*
- for (var type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
- for (var maxValue of [2, 3, 4]) {
- for (var swizzle of computeSwizzle([], maxValue, size)) {
+ for (let type of [`bool`, `uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
+ for (let maxValue of [2, 3, 4]) {
+ for (let swizzle of computeSwizzle([], maxValue, size)) {
let swizzleName = swizzle.map(component).join("");
print(`${type}${size} operator.${swizzleName}(${type}${maxValue} v) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result.${component(i)} = v.${component(swizzle[i])};`);
}
print(` return result;`);
@@ -790,7 +790,7 @@
if (uniqueLength(swizzle) == size) {
print(`${type}${maxValue} operator.${swizzleName}=(${type}${maxValue} v, ${type}${size} c) {`);
print(` ${type}${maxValue} result = v;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result.${component(swizzle[i])} = c.${component(i)};`);
}
print(` return result;`);
@@ -807,7 +807,7 @@
let nativeFunctions = [`cos`, `sin`, `tan`, `acos`, `asin`, `atan`, `cosh`, `sinh`, `tanh`, `ceil`, `exp`, `floor`, `log`, `round`, `trunc`, `ddx`, `ddy`];
let nonNativeFunctions = [`sqrt`, `log2`, `log10`, `frac`, `exp2`, `degrees`, `radians`, `rcp`, `rsqrt`, `saturate`, `ddx_coarse`, `ddx_fine`, `ddy_coarse`, `ddy_fine`, `fwidth`];
- for (var nativeFunction of nativeFunctions) {
+ for (let nativeFunction of nativeFunctions) {
print(`native float ${nativeFunction}(float);`);
print(`half ${nativeFunction}(half x) {`);
print(` return half(${nativeFunction}(float(x)));`);
@@ -814,7 +814,7 @@
print(`}`);
}
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type} sqrt(${type} x) {`);
print(` return pow(x, 0.5);`);
print(`}`);
@@ -861,22 +861,22 @@
print(` return abs(ddx(x)) + abs(ddy(x));`);
print(`}`);
- for (var outputFunction of nativeFunctions.concat(nonNativeFunctions)) {
- for (var size of [2, 3, 4]) {
+ for (let outputFunction of nativeFunctions.concat(nonNativeFunctions)) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} ${outputFunction}(${type}${size} x) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${outputFunction}(x[${i}]);`);
}
print(` return result;`);
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} ${outputFunction}(${type}${i}x${j} x) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = ${outputFunction}(x[${m}][${n}]);`);
}
}
@@ -894,7 +894,7 @@
(function() {
let nativeFunctions = [`pow`];
- for (var nativeFunction of nativeFunctions) {
+ for (let nativeFunction of nativeFunctions) {
print(`native float ${nativeFunction}(float, float);`);
print(`half ${nativeFunction}(half x, half y) {`);
print(` return half(${nativeFunction}(float(x), float(y)));`);
@@ -901,7 +901,7 @@
print(`}`);
}
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
let nonNativeFunctions = [`step`, `ldexp`, `fmod`];
print(`${type} step(${type} y, ${type} x) {`);
@@ -916,22 +916,22 @@
print(` return x - multiple;`);
print(`}`);
- for (var outputFunction of nativeFunctions.concat(nonNativeFunctions)) {
- for (var size of [2, 3, 4]) {
+ for (let outputFunction of nativeFunctions.concat(nonNativeFunctions)) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} ${outputFunction}(${type}${size} x, ${type}${size} y) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${outputFunction}(x[${i}], y[${i}]);`);
}
print(` return result;`);
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} ${outputFunction}(${type}${i}x${j} x, ${type}${i}x${j} y) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = ${outputFunction}(x[${m}][${n}], y[${m}][${n}]);`);
}
}
@@ -946,7 +946,7 @@
// These functions are ternary floating-point scalar functions,
// which can also be applied to vectors and matrices component-wise.
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
let nonNativeFunctions = [`smoothstep`, `lerp`, `fma`, `mad`];
print(`${type} smoothstep(${type} edge0, ${type} edge1, ${type} x) {`);
@@ -963,22 +963,22 @@
print(` return x * y + z;`);
print(`}`);
- for (var nonNativeFunction of nonNativeFunctions) {
- for (var size of [2, 3, 4]) {
+ for (let nonNativeFunction of nonNativeFunctions) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} ${nonNativeFunction}(${type}${size} x, ${type}${size} y, ${type}${size} z) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${nonNativeFunction}(x[${i}], y[${i}], z[${i}]);`);
}
print(` return result;`);
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} ${nonNativeFunction}(${type}${i}x${j} x, ${type}${i}x${j} y, ${type}${i}x${j} z) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = ${nonNativeFunction}(x[${m}][${n}], y[${m}][${n}], z[${m}][${n}]);`);
}
}
@@ -992,11 +992,11 @@
print(`native bool isnormal(half);`);
print(`native bool isnormal(float);`);
- for (var type of [`half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`bool${size} isnormal(${type}${size} x) {`);
print(` bool${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = isnormal(x[${i}]);`);
}
print(` return result;`);
@@ -1008,7 +1008,7 @@
(function() {
let nativeFunctions = [`isfinite`, `isinf`, `isnan`];
- for (var nativeFunction of nativeFunctions) {
+ for (let nativeFunction of nativeFunctions) {
print(`native bool ${nativeFunction}(float);`);
print(`bool ${nativeFunction}(half x) {`);
print(` return ${nativeFunction}(float(x));`);
@@ -1015,12 +1015,12 @@
print(`}`);
}
- for (var type of [`half`, `float`]) {
- for (var nativeFunction of nativeFunctions) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let nativeFunction of nativeFunctions) {
+ for (let size of [2, 3, 4]) {
print(`bool${size} ${nativeFunction}(${type}${size} x) {`);
print(` bool${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${nativeFunction}(x[${i}]);`);
}
print(` return result;`);
@@ -1031,7 +1031,7 @@
}
})()
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
let nonNativeFunctions = [`isordered`, `isunordered`];
print(`bool isordered(${type} x, ${type} y) {`);
@@ -1041,11 +1041,11 @@
print(` return isnan(x) || isnan(y);`);
print(`}`);
- for (var nonNativeFunction of nonNativeFunctions) {
- for (var size of [2, 3, 4]) {
+ for (let nonNativeFunction of nonNativeFunctions) {
+ for (let size of [2, 3, 4]) {
print(`bool${size} ${nonNativeFunction}(${type}${size} x, ${type}${size} y) {`);
print(` bool${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${nonNativeFunction}(x[${i}], y[${i}]);`);
}
print(` return result;`);
@@ -1059,22 +1059,22 @@
print(`half atan2(half x, half y) {`);
print(` return half(atan2(float(x), float(y)));`);
print(`}`);
- for (var type of [`half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} atan2(${type}${size} x, ${type}${size} y) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = atan2(x[${i}], y[${i}]);`);
}
print(` return result;`);
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} atan2(${type}${i}x${j} x, ${type}${i}x${j} y) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = atan2(x[${m}][${n}], y[${m}][${n}]);`);
}
}
@@ -1085,17 +1085,17 @@
}
print();
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`void sincos(${type} x, thread ${type}* y, thread ${type}* z) {`);
print(` *y = sin(x);`);
print(` *z = cos(x);`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`void sincos(${type}${size} x, thread ${type}${size}* y, thread ${type}${size}* z) {`);
// Can't take a pointer to a member of a vector.
print(` ${type} sinResult;`);
print(` ${type} cosResult;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` sincos(x[${i}], &sinResult, &cosResult);`);
print(` (*y)[${i}] = sinResult;`);
print(` (*z)[${i}] = cosResult;`);
@@ -1102,14 +1102,14 @@
}
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`void sincos(${type}${i}x${j} x, thread ${type}${i}x${j}* y, thread ${type}${i}x${j}* z) {`);
// Can't take a pointer to a member of a matrix.
print(` ${type} sinResult;`);
print(` ${type} cosResult;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` sincos(x[${m}][${n}], &sinResult, &cosResult);`);
print(` (*y)[${m}][${n}] = sinResult;`);
print(` (*z)[${m}][${n}] = cosResult;`);
@@ -1121,27 +1121,27 @@
}
print();
- for (var binaryFunction of [[`all`, `true`, `&&`], [`any`, `false`, `||`]]) {
+ for (let binaryFunction of [[`all`, `true`, `&&`], [`any`, `false`, `||`]]) {
print(`bool ${binaryFunction[0]}(bool x) {`);
print(` return x;`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`bool ${binaryFunction[0]}(bool${size} x) {`);
print(` bool result = ${binaryFunction[1]};`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result = result ${binaryFunction[2]} (x[${i}]);`);
}
print(` return result;`);
print(`}`);
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`bool ${binaryFunction[0]}(${type} x) {`);
print(` return x != 0;`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`bool ${binaryFunction[0]}(${type}${size} x) {`);
print(` bool result = ${binaryFunction[1]};`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result = result ${binaryFunction[2]} (x[${i}] != 0);`);
}
print(` return result;`);
@@ -1148,12 +1148,12 @@
print(`}`);
}
if (type == `half` || type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`bool ${binaryFunction[0]}(${type}${i}x${j} x) {`);
print(` bool result = ${binaryFunction[1]};`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result = result ${binaryFunction[2]} (x[${m}][${n}] != 0);`);
}
}
@@ -1166,12 +1166,12 @@
print();
}
- for (var type of [`uchar`, `ushort`, `uint`]) {
+ for (let type of [`uchar`, `ushort`, `uint`]) {
print(`${type} abs(${type} x) {`);
print(` return x;`);
print(`}`);
}
- for (var type of [`char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`char`, `short`, `int`, `half`, `float`]) {
print(`${type} abs(${type} x) {`);
print(` if (x < 0)`);
print(` return -x;`);
@@ -1178,11 +1178,11 @@
print(` return x;`);
print(`}`);
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} abs(${type}${size} x) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = abs(x[${i}]);`);
}
print(` return result;`);
@@ -1189,12 +1189,12 @@
print(`}`);
}
if (type == `half` || type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} abs(${type}${i}x${j} x) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = abs(x[${m}][${n}]);`);
}
}
@@ -1206,12 +1206,12 @@
}
print();
- for (var type of [`uchar`, `ushort`, `uint`]) {
+ for (let type of [`uchar`, `ushort`, `uint`]) {
print(`${type} sign(${type} x) {`);
print(` return x == 0 ? 0 : 1;`);
print(`}`);
}
- for (var type of [`char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`char`, `short`, `int`, `half`, `float`]) {
print(`${type} sign(${type} x) {`);
print(` if (x < 0)`);
print(` return -1;`);
@@ -1220,11 +1220,11 @@
print(` return 1;`);
print(`}`);
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} sign(${type}${size} x) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = sign(x[${i}]);`);
}
print(` return result;`);
@@ -1231,12 +1231,12 @@
print(`}`);
}
if (type == `half` || type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} sign(${type}${i}x${j} x) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = sign(x[${m}][${n}]);`);
}
}
@@ -1248,7 +1248,7 @@
}
print();
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
let nonNativeFunctions = [`min`, `max`];
print(`${type} min(${type} x, ${type} y) {`);
@@ -1258,11 +1258,11 @@
print(` return x > y ? x : y;`);
print(`}`);
- for (var nonNativeFunction of nonNativeFunctions) {
- for (var size of [2, 3, 4]) {
+ for (let nonNativeFunction of nonNativeFunctions) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} ${nonNativeFunction}(${type}${size} x, ${type}${size} y) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${nonNativeFunction}(x[${i}], y[${i}]);`);
}
print(` return result;`);
@@ -1269,12 +1269,12 @@
print(`}`);
}
if (type == `half` || type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} ${nonNativeFunction}(${type}${i}x${j} x, ${type}${i}x${j} y) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = ${nonNativeFunction}(x[${m}][${n}], y[${m}][${n}]);`);
}
}
@@ -1287,7 +1287,7 @@
print();
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
let nonNativeFunctions = [`clamp`];
print(`${type} clamp(${type} x, ${type} lower, ${type} upper) {`);
@@ -1294,11 +1294,11 @@
print(` return max(min(upper, x), lower);`);
print(`}`);
- for (var nonNativeFunction of nonNativeFunctions) {
- for (var size of [2, 3, 4]) {
+ for (let nonNativeFunction of nonNativeFunctions) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} ${nonNativeFunction}(${type}${size} x, ${type}${size} y, ${type}${size} z) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${nonNativeFunction}(x[${i}], y[${i}], z[${i}]);`);
}
print(` return result;`);
@@ -1305,12 +1305,12 @@
print(`}`);
}
if (type == `half` || type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} ${nonNativeFunction}(${type}${i}x${j} x, ${type}${i}x${j} y, ${type}${i}x${j} z) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = ${nonNativeFunction}(x[${m}][${n}], y[${m}][${n}], z[${m}][${n}]);`);
}
}
@@ -1323,7 +1323,7 @@
print();
}
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type} modf(${type} x, thread ${type}* ip) {`);
print(` uint result = uint(x);`);
print(` *ip = x - ${type}(result);`);
@@ -1330,12 +1330,12 @@
print(` return ${type}(result);`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} modf(${type}${size} x, thread ${type}${size}* y) {`);
print(` ${type}${size} result;`);
// Can't take a pointer to a member of a vector.
print(` ${type} buffer;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = modf(x[${i}], &buffer);`);
print(` (*y)[${i}] = buffer;`);
}
@@ -1342,14 +1342,14 @@
print(` return result;`);
print(`}`);
}
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} modf(${type}${i}x${j} x, thread ${type}${i}x${j}* y) {`);
print(` ${type}${i}x${j} result;`);
// Can't take a pointer to a member of a matrix.
print(` ${type} buffer;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = modf(x[${m}][${n}], &buffer);`);
print(` (*y)[${m}][${n}] = buffer;`);
}
@@ -1363,7 +1363,7 @@
print(`uchar count_bits(uchar x) {`);
print(` return uchar(((x | uchar(1 << 0)) == 0 ? 0 : 1) +`);
- for (var i = 1; i < 7; ++i) {
+ for (let i = 1; i < 7; ++i) {
print(` ((x | uchar(1 << ${i})) == 0 ? 0 : 1) +`);
}
print(` ((x | uchar(1 << 7)) == 0 ? 0 : 1));`);
@@ -1370,7 +1370,7 @@
print(`}`);
print(`uchar count_bits(ushort x) {`);
print(` return uchar(((x | ushort(1 << 0)) == 0 ? 0 : 1) +`);
- for (var i = 1; i < 15; ++i) {
+ for (let i = 1; i < 15; ++i) {
print(` ((x | ushort(1 << ${i})) == 0 ? 0 : 1) +`);
}
print(` ((x | ushort(1 << 15)) == 0 ? 0 : 1));`);
@@ -1377,7 +1377,7 @@
print(`}`);
print(`uchar count_bits(uint x) {`);
print(` return uchar(((x | uint(1 << 0)) == 0 ? 0 : 1) +`);
- for (var i = 1; i < 31; ++i) {
+ for (let i = 1; i < 31; ++i) {
print(` ((x | uint(1 << ${i})) == 0 ? 0 : 1) +`);
}
print(` ((x | uint(1 << 31)) == 0 ? 0 : 1));`);
@@ -1384,7 +1384,7 @@
print(`}`);
print(`uchar reversebits(uchar x) {`);
print(` return uchar(((x & uchar(1 << 0)) << 7) |`);
- for (var i = 1; i < 7; ++i) {
+ for (let i = 1; i < 7; ++i) {
let offset = 7 - 2 * i
print(` ((x & uchar(1 << ${i})) ${offset > 0 ? `<<` : `>>`} ${Math.abs(offset)}) |`);
}
@@ -1392,7 +1392,7 @@
print(`}`);
print(`ushort reversebits(ushort x) {`);
print(` return ushort(((x & ushort(1 << 0)) << 15) |`);
- for (var i = 1; i < 15; ++i) {
+ for (let i = 1; i < 15; ++i) {
let offset = 15 - 2 * i
print(` ((x & ushort(1 << ${i})) ${offset > 0 ? `<<` : `>>`} ${Math.abs(offset)}) |`);
}
@@ -1400,17 +1400,17 @@
print(`}`);
print(`uint reversebits(uint x) {`);
print(` return uint(((x & uint(1 << 0)) << 31) |`);
- for (var i = 1; i < 31; ++i) {
+ for (let i = 1; i < 31; ++i) {
let offset = 31 - 2 * i
print(` ((x & uint(1 << ${i})) ${offset > 0 ? `<<` : `>>`} ${Math.abs(offset)}) |`);
}
print(` ((x & uint(1 << 31)) >> 31));`);
print(`}`);
- for (var type of [`uchar`, `ushort`, `uint`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`]) {
+ for (let size of [2, 3, 4]) {
print(`uchar${size} count_bits(${type}${size} x) {`);
print(` uchar${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = count_bits(x[${i}]);`);
}
print(` return result;`);
@@ -1417,11 +1417,11 @@
print(`}`);
}
}
- for (var type of [`uchar`, `ushort`, `uint`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} reversebits(${type}${size} x) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = reversebits(x[${i}]);`);
}
print(` return result;`);
@@ -1431,7 +1431,7 @@
print();
print(`uint firstbithigh(uchar x) {`);
- for (var i = 0; i <= 7; ++i) {
+ for (let i = 0; i <= 7; ++i) {
print(` if ((x & uchar(1 << ${7 - i})) != 0)`);
print(` return ${i};`);
}
@@ -1438,7 +1438,7 @@
print(` return 8;`);
print(`}`);
print(`uint firstbithigh(ushort x) {`);
- for (var i = 0; i <= 15; ++i) {
+ for (let i = 0; i <= 15; ++i) {
print(` if ((x & ushort(1 << ${15 - i})) != 0)`);
print(` return ${i};`);
}
@@ -1445,7 +1445,7 @@
print(` return 16;`);
print(`}`);
print(`uint firstbithigh(uint x) {`);
- for (var i = 0; i <= 31; ++i) {
+ for (let i = 0; i <= 31; ++i) {
print(` if ((x & uint(1 << ${31 - i})) != 0)`);
print(` return ${i};`);
}
@@ -1461,7 +1461,7 @@
print(` return firstbithigh(uint(x));`);
print(`}`);
print(`uint firstbitlow(uchar x) {`);
- for (var i = 0; i <= 7; ++i) {
+ for (let i = 0; i <= 7; ++i) {
print(` if ((x & uchar(1 << ${i})) != 0)`);
print(` return ${7 - i};`);
}
@@ -1468,7 +1468,7 @@
print(` return 8;`);
print(`}`);
print(`uint firstbitlow(ushort x) {`);
- for (var i = 0; i <= 15; ++i) {
+ for (let i = 0; i <= 15; ++i) {
print(` if ((x & ushort(1 << ${i})) != 0)`);
print(` return ${15 - i};`);
}
@@ -1475,7 +1475,7 @@
print(` return 16;`);
print(`}`);
print(`uint firstbitlow(uint x) {`);
- for (var i = 0; i <= 31; ++i) {
+ for (let i = 0; i <= 31; ++i) {
print(` if ((x & uint(1 << ${i})) != 0)`);
print(` return ${31 - i};`);
}
@@ -1490,12 +1490,12 @@
print(`uint firstbitlow(int x) {`);
print(` return firstbitlow(uint(x));`);
print(`}`);
- for (var functionName of [`firstbithigh`, `firstbitlow`]) {
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`]) {
- for (var size of [2, 3, 4]) {
+ for (let functionName of [`firstbithigh`, `firstbitlow`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`]) {
+ for (let size of [2, 3, 4]) {
print(`uint${size} ${functionName}(${type}${size} x) {`);
print(` uint${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = ${functionName}(x[${i}]);`);
}
print(` return result;`);
@@ -1506,7 +1506,7 @@
print();
// Row-major, so the first index selects which row, and the second index selects which column
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type} determinant(${type} x) {`);
print(` return x;`);
print(`}`);
@@ -1569,7 +1569,7 @@
}
print();
- for (var type of [`uchar4`, `ushort4`, `uint4`, `char4`, `short4`, `int4`, `half4`, `float4`]) {
+ for (let type of [`uchar4`, `ushort4`, `uint4`, `char4`, `short4`, `int4`, `half4`, `float4`]) {
print(`${type} dst(${type} src0, ${type} src1) {`);
print(` ${type} result;`);
print(` result.x = 1;`);
@@ -1581,11 +1581,11 @@
}
print();
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type} distance(${type} x, ${type} y) {`);
print(` return length(x - y);`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`${type} distance(${type}${size} x, ${type}${size} y) {`);
print(` return length(x - y);`);
print(`}`);
@@ -1593,7 +1593,7 @@
}
print();
- for (var type of [`half3`, `float3`]) {
+ for (let type of [`half3`, `float3`]) {
print(`${type} cross(${type} u, ${type} v) {`);
print(` ${type} result;`);
print(` result.x = u.y * v.z - u.z * v.y;`);
@@ -1604,14 +1604,14 @@
}
print();
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`${type} dot(${type} a, ${type} b) {`);
print(` return a * b;`);
print(`}`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`${type} dot(${type}${size} a, ${type}${size} b) {`);
print(` ${type} result = 0;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result = result + a[${i}] * b[${i}];`);
}
print(` return result;`);
@@ -1620,8 +1620,8 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`${type}${size} faceforward(${type}${size} n, ${type}${size} i, ${type}${size} ng) {`);
print(` return -n * sign(dot(i, ng));`);
print(`}`);
@@ -1629,8 +1629,8 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`${type} length(${type}${size} x) {`);
print(` return sqrt(dot(x, x));`);
print(`}`);
@@ -1638,7 +1638,7 @@
}
print();
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type}4 lit(${type} n_dot_l, ${type} n_dot_h, ${type} m) {`);
print(` ${type} ambient = 1;`);
print(` ${type} diffuse = max(0, n_dot_l);`);
@@ -1653,8 +1653,8 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`${type}${size} normalize(${type}${size} x) {`);
print(` return x / length(x);`);
print(`}`);
@@ -1662,8 +1662,8 @@
}
print();
- for (var type of [`half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`${type}${size} reflect(${type}${size} i, ${type}${size} n) {`);
print(` return i - 2 * n * dot(i, n);`);
print(`}`);
@@ -1672,8 +1672,8 @@
print();
// OpenGL ES v3.30 section 8.4
- for (var type of [`half`, `float`]) {
- for (var size of [``, `2`, `3`, `4`]) {
+ for (let type of [`half`, `float`]) {
+ for (let size of [``, `2`, `3`, `4`]) {
print(`${type}${size} refract(${type}${size} i, ${type}${size} n, ${type} eta) {`);
print(` ${type}${size} result;`);
print(` ${type} k = 1 - eta * eta * (1 - dot(n, i) * dot(n, i));`);
@@ -1685,16 +1685,16 @@
}
print();
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`${type} transpose(${type} x) {`);
print(` return x;`);
print(`}`);
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} transpose(${type}${j}x${i} x) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = x[${n}][${m}];`);
}
}
@@ -1705,8 +1705,8 @@
}
print();
- for (var resultType of [`int`, `uint`, `float`]) {
- for (var type of [`int`, `uint`, `float`]) {
+ for (let resultType of [`int`, `uint`, `float`]) {
+ for (let type of [`int`, `uint`, `float`]) {
if (type == resultType) {
print(`${resultType} as${resultType}(${type} x) {`);
print(` return x;`);
@@ -1718,7 +1718,7 @@
} else {
print(`native ${resultType} as${resultType}(${type});`);
}
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
if (type == resultType) {
print(`${resultType}${size} as${resultType}(${type}${size} x) {`);
print(` return x;`);
@@ -1726,7 +1726,7 @@
} else {
print(`${resultType}${size} as${resultType}(${type}${size} x) {`);
print(` ${resultType}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = as${resultType}(x[${i}]);`);
}
print(` return result;`);
@@ -1734,8 +1734,8 @@
}
}
if (resultType == `float` && type == `float`) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
if (type == resultType) {
print(`${resultType}${i}x${j} as${resultType}(${type}${i}x${j} x) {`);
print(` return x;`);
@@ -1743,8 +1743,8 @@
} else {
print(`${resultType}${i}x${j} as${resultType}(${type}${i}x${j} x) {`);
print(` ${resultType}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = as${resultType}(x[${m}][${n}]);`);
}
}
@@ -1760,10 +1760,10 @@
print(`native float f16tof32(uint);`);
print(`native uint f32tof16(float);`);
- for (var size of [2, 3, 4]) {
+ for (let size of [2, 3, 4]) {
print(`float${size} f16tof32(uint${size} x) {`);
print(` float${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = f16tof32(x[${i}]);`);
}
print(` return result;`);
@@ -1770,7 +1770,7 @@
print(`}`);
print(`uint${size} f32tof16(float${size} x) {`);
print(` uint${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = f32tof16(x[${i}]);`);
}
print(` return result;`);
@@ -1783,17 +1783,17 @@
print(`native void GroupMemoryBarrierWithGroupSync();`);
print();
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
print(`${type} mul(${type} x, ${type} y) {`);
print(` return x * y;`);
print(`}`);
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type}${size} mul(${type} x, ${type}${size} y) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = x * y[${i}];`);
}
print(` return result;`);
@@ -1800,7 +1800,7 @@
print(`}`);
print(`${type}${size} mul(${type}${size} x, ${type} y) {`);
print(` ${type}${size} result;`);
- for (var i = 0; i < size; ++i) {
+ for (let i = 0; i < size; ++i) {
print(` result[${i}] = x[${i}] * y;`);
}
print(` return result;`);
@@ -1808,13 +1808,13 @@
}
}
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${i}x${j} mul(${type} x, ${type}${i}x${j} y) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = x * y[${m}][${n}];`);
}
}
@@ -1822,8 +1822,8 @@
print(`}`);
print(`${type}${i}x${j} mul(${type}${i}x${j} x, ${type} y) {`);
print(` ${type}${i}x${j} result;`);
- for (var m = 0; m < i; ++m) {
- for (var n = 0; n < j; ++n) {
+ for (let m = 0; m < i; ++m) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}][${n}] = x[${m}][${n}] * y;`);
}
}
@@ -1833,8 +1833,8 @@
}
}
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var size of [2, 3, 4]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let size of [2, 3, 4]) {
print(`${type} mul(${type}${size} x, ${type}${size} y) {`);
print(` return dot(x, y);`);
print(`}`);
@@ -1841,14 +1841,14 @@
}
}
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
print(`${type}${j} mul(${type}${i} x, ${type}${i}x${j} y) {`);
print(` ${type}${j} result;`);
- for (var m = 0; m < j; ++m) {
+ for (let m = 0; m < j; ++m) {
print(` result[${m}] = 0;`);
- for (var n = 0; n < i; ++n) {
+ for (let n = 0; n < i; ++n) {
print(` result[${m}] += x[${n}] * y[${n}][${m}];`);
}
}
@@ -1856,9 +1856,9 @@
print(`}`);
print(`${type}${i} mul(${type}${i}x${j} x, ${type}${j} y) {`);
print(` ${type}${i} result;`);
- for (var m = 0; m < i; ++m) {
+ for (let m = 0; m < i; ++m) {
print(` result[${m}] = 0;`);
- for (var n = 0; n < j; ++n) {
+ for (let n = 0; n < j; ++n) {
print(` result[${m}] += x[${m}][${n}] * y[${n}];`);
}
}
@@ -1868,16 +1868,16 @@
}
}
- for (var type of [`half`, `float`]) {
- for (var i of [2, 3, 4]) {
- for (var j of [2, 3, 4]) {
- for (var k of [2, 3, 4]) {
+ for (let type of [`half`, `float`]) {
+ for (let i of [2, 3, 4]) {
+ for (let j of [2, 3, 4]) {
+ for (let k of [2, 3, 4]) {
print(`${type}${i}x${k} mul(${type}${i}x${j} x, ${type}${j}x${k} y) {`);
print(` ${type}${i}x${k} result;`);
- for (var p = 0; p < i; ++p) {
- for (var r = 0; r < k; ++r) {
+ for (let p = 0; p < i; ++p) {
+ for (let r = 0; r < k; ++r) {
print(` result[${p}][${r}] = 0;`);
- for (var q = 0; q < j; ++q) {
+ for (let q = 0; q < j; ++q) {
print(` result[${p}][${r}] += x[${p}][${q}] * y[${q}][${r}];`);
}
}
@@ -1890,8 +1890,8 @@
}
print();
- for (var type of [`uint`, `int`]) {
- for (var functionName of [`Add`, `And`, `Exchange`, `Max`, `Min`, `Or`, `Xor`]) {
+ for (let type of [`uint`, `int`]) {
+ for (let functionName of [`Add`, `And`, `Exchange`, `Max`, `Min`, `Or`, `Xor`]) {
print(`native void Interlocked${functionName}(thread atomic_${type}*, ${type}, thread ${type}*);`);
}
print(`native void InterlockedCompareExchange(thread atomic_${type}*, ${type}, ${type}, thread ${type}*);`);
@@ -1899,8 +1899,8 @@
print();
*/
- for (var type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
- for (var length of [``, `2`, `3`, `4`]) {
+ for (let type of [`uchar`, `ushort`, `uint`, `char`, `short`, `int`, `half`, `float`]) {
+ for (let length of [``, `2`, `3`, `4`]) {
print(`native ${type}${length} Sample(Texture1D<${type}${length}>, sampler, float location);`);
print(`native ${type}${length} Sample(Texture1D<${type}${length}>, sampler, float location, int offset);`);
print(`native ${type}${length} Load(Texture1D<${type}${length}>, int2 location);`);
@@ -2019,7 +2019,7 @@
}
}
- for (var type of [`half`, `float`]) {
+ for (let type of [`half`, `float`]) {
print(`native ${type} Sample(TextureDepth2D<${type}>, sampler, float2 location);`);
print(`native ${type} Sample(TextureDepth2D<${type}>, sampler, float2 location, int2 offset);`);
print(`native ${type} SampleCmp(TextureDepth2D<${type}>, sampler, float2 location, ${type} CompareValue);`);