| Differences between
and this patch
- a/Tools/ChangeLog +16 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2018-08-29  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        [WHLSL] Test row-majorness of matrices
4
        https://bugs.webkit.org/show_bug.cgi?id=189101
5
6
        The matrix multiplication functions are temporarily commented out of the standard library,
7
        so I've temporarily copy/pasted them into the test. Matrix multiplication is not
8
        commutative, so it requires the right indexing order.
9
10
        Reviewed by NOBODY (OOPS!).
11
12
        * WebGPUShadingLanguageRI/Intrinsics.js:
13
        * WebGPUShadingLanguageRI/StandardLibrary.js:
14
        (let.standardLibrary):
15
        * WebGPUShadingLanguageRI/Test.js:
16
1
2018-08-29  Jer Noble  <jer.noble@apple.com>
17
2018-08-29  Jer Noble  <jer.noble@apple.com>
2
18
3
        Unreviewed test gardening; NowPlayingTest API tests require High Sierra.
19
        Unreviewed test gardening; NowPlayingTest API tests require High Sierra.
- a/Tools/WebGPUShadingLanguageRI/Intrinsics.js -3 / +3 lines
Lines 316-326 class Intrinsics { a/Tools/WebGPUShadingLanguageRI/Intrinsics.js_sec1
316
            }
316
            }
317
        }
317
        }
318
318
319
        for (let type of ["half", "float"]) {
319
        for (let typeName of ["half", "float"]) {
320
            for (let height = 2; height <= 4; ++height) {
320
            for (let height = 2; height <= 4; ++height) {
321
                for (let width = 2; width <= 4; ++width) {
321
                for (let width = 2; width <= 4; ++width) {
322
                    this._map.set(`native typedef matrix<${type}, ${height}, ${width}>`, type => {
322
                    this._map.set(`native typedef matrix<${typeName}, ${height}, ${width}>`, type => {
323
                        this[`matrix<${type}, ${height}, ${width}>`] = type;
323
                        this[`matrix<${typeName}, ${height}, ${width}>`] = type;
324
                    });
324
                    });
325
                }
325
                }
326
            }
326
            }
- a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js -2 / +2 lines
Lines 1876-1884 let standardLibrary = (function() { a/Tools/WebGPUShadingLanguageRI/StandardLibrary.js_sec1
1876
                        print(`    ${type}${i}x${k} result;`);
1876
                        print(`    ${type}${i}x${k} result;`);
1877
                        for (var p = 0; p < i; ++p) {
1877
                        for (var p = 0; p < i; ++p) {
1878
                            for (var r = 0; r < k; ++r) {
1878
                            for (var r = 0; r < k; ++r) {
1879
                                print(`    result[${p}][${k}] = 0;`);
1879
                                print(`    result[${p}][${r}] = 0;`);
1880
                                for (var q = 0; q < j; ++q) {
1880
                                for (var q = 0; q < j; ++q) {
1881
                                    print(`    result[${p}][${k}] += x[${p}][${q}] * y[${q}][${r}];`);
1881
                                    print(`    result[${p}][${r}] += x[${p}][${q}] * y[${q}][${r}];`);
1882
                                }
1882
                                }
1883
                            }
1883
                            }
1884
                        }
1884
                        }
- a/Tools/WebGPUShadingLanguageRI/Test.js +100 lines
Lines 5451-5456 tests.halfSimpleMath = function() { a/Tools/WebGPUShadingLanguageRI/Test.js_sec1
5451
    checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, -2)]), -3.5);
5451
    checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, -2)]), -3.5);
5452
}
5452
}
5453
5453
5454
tests.matrixMultiplication = function() {
5455
    let program = doPrep(`
5456
        float2x4 multiply(float2x3 x, float3x4 y) {
5457
            // Copied and pasted from the standard library
5458
            float2x4 result;
5459
            result[0][0] = 0;
5460
            result[0][0] += x[0][0] * y[0][0];
5461
            result[0][0] += x[0][1] * y[1][0];
5462
            result[0][0] += x[0][2] * y[2][0];
5463
            result[0][1] = 0;
5464
            result[0][1] += x[0][0] * y[0][1];
5465
            result[0][1] += x[0][1] * y[1][1];
5466
            result[0][1] += x[0][2] * y[2][1];
5467
            result[0][2] = 0;
5468
            result[0][2] += x[0][0] * y[0][2];
5469
            result[0][2] += x[0][1] * y[1][2];
5470
            result[0][2] += x[0][2] * y[2][2];
5471
            result[0][3] = 0;
5472
            result[0][3] += x[0][0] * y[0][3];
5473
            result[0][3] += x[0][1] * y[1][3];
5474
            result[0][3] += x[0][2] * y[2][3];
5475
            result[1][0] = 0;
5476
            result[1][0] += x[1][0] * y[0][0];
5477
            result[1][0] += x[1][1] * y[1][0];
5478
            result[1][0] += x[1][2] * y[2][0];
5479
            result[1][1] = 0;
5480
            result[1][1] += x[1][0] * y[0][1];
5481
            result[1][1] += x[1][1] * y[1][1];
5482
            result[1][1] += x[1][2] * y[2][1];
5483
            result[1][2] = 0;
5484
            result[1][2] += x[1][0] * y[0][2];
5485
            result[1][2] += x[1][1] * y[1][2];
5486
            result[1][2] += x[1][2] * y[2][2];
5487
            result[1][3] = 0;
5488
            result[1][3] += x[1][0] * y[0][3];
5489
            result[1][3] += x[1][1] * y[1][3];
5490
            result[1][3] += x[1][2] * y[2][3];
5491
            return result;
5492
        }
5493
        float2x3 matrix1() {
5494
            float2x3 x;
5495
            x[0][0] = 2;
5496
            x[0][1] = 3;
5497
            x[0][2] = 5;
5498
            x[1][0] = 7;
5499
            x[1][1] = 11;
5500
            x[1][2] = 13;
5501
            return x;
5502
        }
5503
        float3x4 matrix2() {
5504
            float3x4 y;
5505
            y[0][0] = 17;
5506
            y[0][1] = 19;
5507
            y[0][2] = 23;
5508
            y[0][3] = 29;
5509
            y[1][0] = 31;
5510
            y[1][1] = 37;
5511
            y[1][2] = 41;
5512
            y[1][3] = 43;
5513
            y[2][0] = 47;
5514
            y[2][1] = 53;
5515
            y[2][2] = 59;
5516
            y[2][3] = 61;
5517
            return y;
5518
        }
5519
        float foo00() {
5520
            return multiply(matrix1(), matrix2())[0][0];
5521
        }
5522
        float foo01() {
5523
            return multiply(matrix1(), matrix2())[0][1];
5524
        }
5525
        float foo02() {
5526
            return multiply(matrix1(), matrix2())[0][2];
5527
        }
5528
        float foo03() {
5529
            return multiply(matrix1(), matrix2())[0][3];
5530
        }
5531
        float foo10() {
5532
            return multiply(matrix1(), matrix2())[1][0];
5533
        }
5534
        float foo11() {
5535
            return multiply(matrix1(), matrix2())[1][1];
5536
        }
5537
        float foo12() {
5538
            return multiply(matrix1(), matrix2())[1][2];
5539
        }
5540
        float foo13() {
5541
            return multiply(matrix1(), matrix2())[1][3];
5542
        }
5543
    `);
5544
    checkFloat(program, callFunction(program, "foo00", []), 17 * 2 + 31 * 3 + 47 * 5);
5545
    checkFloat(program, callFunction(program, "foo01", []), 19 * 2 + 37 * 3 + 53 * 5);
5546
    checkFloat(program, callFunction(program, "foo02", []), 23 * 2 + 41 * 3 + 59 * 5);
5547
    checkFloat(program, callFunction(program, "foo03", []), 29 * 2 + 43 * 3 + 61 * 5);
5548
    checkFloat(program, callFunction(program, "foo10", []), 17 * 7 + 31 * 11 + 47 * 13);
5549
    checkFloat(program, callFunction(program, "foo11", []), 19 * 7 + 37 * 11 + 53 * 13);
5550
    checkFloat(program, callFunction(program, "foo12", []), 23 * 7 + 41 * 11 + 59 * 13);
5551
    checkFloat(program, callFunction(program, "foo13", []), 29 * 7 + 43 * 11 + 61 * 13);
5552
}
5553
5454
okToTest = true;
5554
okToTest = true;
5455
5555
5456
let testFilter = /.*/; // run everything by default
5556
let testFilter = /.*/; // run everything by default

Return to Bug 189101