Modified: trunk/Tools/ChangeLog (235492 => 235493)
--- trunk/Tools/ChangeLog 2018-08-30 01:22:40 UTC (rev 235492)
+++ trunk/Tools/ChangeLog 2018-08-30 01:50:21 UTC (rev 235493)
@@ -1,3 +1,19 @@
+2018-08-29 Myles C. Maxfield <[email protected]>
+
+ [WHLSL] Test row-majorness of matrices
+ https://bugs.webkit.org/show_bug.cgi?id=189101
+
+ The matrix multiplication functions are temporarily commented out of the standard library,
+ so I've temporarily copy/pasted them into the test. Matrix multiplication is not
+ commutative, so it requires the right indexing order.
+
+ Reviewed by Dean Jackson and Thomas Denney.
+
+ * WebGPUShadingLanguageRI/Intrinsics.js:
+ * WebGPUShadingLanguageRI/StandardLibrary.js:
+ (let.standardLibrary):
+ * WebGPUShadingLanguageRI/Test.js:
+
2018-08-29 Jer Noble <[email protected]>
Unreviewed test gardening; NowPlayingTest API tests require High Sierra.
Modified: trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js (235492 => 235493)
--- trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2018-08-30 01:22:40 UTC (rev 235492)
+++ trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2018-08-30 01:50:21 UTC (rev 235493)
@@ -316,11 +316,11 @@
}
}
- for (let type of ["half", "float"]) {
+ for (let typeName 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 typedef matrix<${typeName}, ${height}, ${width}>`, type => {
+ this[`matrix<${typeName}, ${height}, ${width}>`] = type;
});
}
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js (235492 => 235493)
--- trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2018-08-30 01:22:40 UTC (rev 235492)
+++ trunk/Tools/WebGPUShadingLanguageRI/StandardLibrary.js 2018-08-30 01:50:21 UTC (rev 235493)
@@ -1876,9 +1876,9 @@
print(` ${type}${i}x${k} result;`);
for (var p = 0; p < i; ++p) {
for (var r = 0; r < k; ++r) {
- print(` result[${p}][${k}] = 0;`);
+ print(` result[${p}][${r}] = 0;`);
for (var q = 0; q < j; ++q) {
- print(` result[${p}][${k}] += x[${p}][${q}] * y[${q}][${r}];`);
+ print(` result[${p}][${r}] += x[${p}][${q}] * y[${q}][${r}];`);
}
}
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (235492 => 235493)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-08-30 01:22:40 UTC (rev 235492)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-08-30 01:50:21 UTC (rev 235493)
@@ -5451,6 +5451,106 @@
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, -2)]), -3.5);
}
+tests.matrixMultiplication = function() {
+ let program = doPrep(`
+ float2x4 multiply(float2x3 x, float3x4 y) {
+ // Copied and pasted from the standard library
+ float2x4 result;
+ result[0][0] = 0;
+ result[0][0] += x[0][0] * y[0][0];
+ result[0][0] += x[0][1] * y[1][0];
+ result[0][0] += x[0][2] * y[2][0];
+ result[0][1] = 0;
+ result[0][1] += x[0][0] * y[0][1];
+ result[0][1] += x[0][1] * y[1][1];
+ result[0][1] += x[0][2] * y[2][1];
+ result[0][2] = 0;
+ result[0][2] += x[0][0] * y[0][2];
+ result[0][2] += x[0][1] * y[1][2];
+ result[0][2] += x[0][2] * y[2][2];
+ result[0][3] = 0;
+ result[0][3] += x[0][0] * y[0][3];
+ result[0][3] += x[0][1] * y[1][3];
+ result[0][3] += x[0][2] * y[2][3];
+ result[1][0] = 0;
+ result[1][0] += x[1][0] * y[0][0];
+ result[1][0] += x[1][1] * y[1][0];
+ result[1][0] += x[1][2] * y[2][0];
+ result[1][1] = 0;
+ result[1][1] += x[1][0] * y[0][1];
+ result[1][1] += x[1][1] * y[1][1];
+ result[1][1] += x[1][2] * y[2][1];
+ result[1][2] = 0;
+ result[1][2] += x[1][0] * y[0][2];
+ result[1][2] += x[1][1] * y[1][2];
+ result[1][2] += x[1][2] * y[2][2];
+ result[1][3] = 0;
+ result[1][3] += x[1][0] * y[0][3];
+ result[1][3] += x[1][1] * y[1][3];
+ result[1][3] += x[1][2] * y[2][3];
+ return result;
+ }
+ float2x3 matrix1() {
+ float2x3 x;
+ x[0][0] = 2;
+ x[0][1] = 3;
+ x[0][2] = 5;
+ x[1][0] = 7;
+ x[1][1] = 11;
+ x[1][2] = 13;
+ return x;
+ }
+ float3x4 matrix2() {
+ float3x4 y;
+ y[0][0] = 17;
+ y[0][1] = 19;
+ y[0][2] = 23;
+ y[0][3] = 29;
+ y[1][0] = 31;
+ y[1][1] = 37;
+ y[1][2] = 41;
+ y[1][3] = 43;
+ y[2][0] = 47;
+ y[2][1] = 53;
+ y[2][2] = 59;
+ y[2][3] = 61;
+ return y;
+ }
+ float foo00() {
+ return multiply(matrix1(), matrix2())[0][0];
+ }
+ float foo01() {
+ return multiply(matrix1(), matrix2())[0][1];
+ }
+ float foo02() {
+ return multiply(matrix1(), matrix2())[0][2];
+ }
+ float foo03() {
+ return multiply(matrix1(), matrix2())[0][3];
+ }
+ float foo10() {
+ return multiply(matrix1(), matrix2())[1][0];
+ }
+ float foo11() {
+ return multiply(matrix1(), matrix2())[1][1];
+ }
+ float foo12() {
+ return multiply(matrix1(), matrix2())[1][2];
+ }
+ float foo13() {
+ return multiply(matrix1(), matrix2())[1][3];
+ }
+ `);
+ checkFloat(program, callFunction(program, "foo00", []), 17 * 2 + 31 * 3 + 47 * 5);
+ checkFloat(program, callFunction(program, "foo01", []), 19 * 2 + 37 * 3 + 53 * 5);
+ checkFloat(program, callFunction(program, "foo02", []), 23 * 2 + 41 * 3 + 59 * 5);
+ checkFloat(program, callFunction(program, "foo03", []), 29 * 2 + 43 * 3 + 61 * 5);
+ checkFloat(program, callFunction(program, "foo10", []), 17 * 7 + 31 * 11 + 47 * 13);
+ checkFloat(program, callFunction(program, "foo11", []), 19 * 7 + 37 * 11 + 53 * 13);
+ checkFloat(program, callFunction(program, "foo12", []), 23 * 7 + 41 * 11 + 59 * 13);
+ checkFloat(program, callFunction(program, "foo13", []), 29 * 7 + 43 * 11 + 61 * 13);
+}
+
okToTest = true;
let testFilter = /.*/; // run everything by default