Changeset 247254 in webkit


Ignore:
Timestamp:
Jul 8, 2019 10:32:26 PM (5 years ago)
Author:
sbarati@apple.com
Message:

[WHLSL Import 23 new JS reference spec tests
https://bugs.webkit.org/show_bug.cgi?id=199604

Reviewed by Myles C. Maxfield.

Source/WebCore:

This patch imports a bunch of JS reference spec tests on our way to
completing https://bugs.webkit.org/show_bug.cgi?id=199595

It also fixes the recursion checker phase. That phase had two bugs:

  1. We'd assert after visiting the function declaration that it was

still in the set. However, it will not be in the set when we actually
detect recursion.

  1. We would not visit the arguments to a call, so if they contained other

calls which were recursive, we would not detect such recursive calls.

Tests: webgpu/whlsl-int-literal-compare.html

webgpu/whlsl-simple-tests.html
webgpu/whlsl-type-mismatch.html
webgpu/whlsl-uint-bitwise.html

  • Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:

LayoutTests:

This moves some stuff down into whlsl-test-harness which are needed by
all tests. This also adds a new checkFail that ensures the program never
runs (e.g, it has a compile error).

  • webgpu/js/whlsl-test-harness.js:

(async.checkFail):
(const.webGPUPromiseTest):

  • webgpu/whlsl-bitwise-bool-ops-expected.txt:
  • webgpu/whlsl-bitwise-bool-ops.html:
  • webgpu/whlsl-int-literal-compare-expected.txt: Added.
  • webgpu/whlsl-int-literal-compare.html: Added.
  • webgpu/whlsl-simple-tests-expected.txt: Added.
  • webgpu/whlsl-simple-tests.html: Added.
  • webgpu/whlsl-type-mismatch-expected.txt: Added.
  • webgpu/whlsl-type-mismatch.html: Added.
  • webgpu/whlsl-uint-bitwise-expected.txt: Added.
  • webgpu/whlsl-uint-bitwise.html: Added.
Location:
trunk
Files:
8 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247251 r247254  
     12019-07-08  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL Import 23 new JS reference spec tests
     4        https://bugs.webkit.org/show_bug.cgi?id=199604
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        This moves some stuff down into whlsl-test-harness which are needed by
     9        all tests. This also adds a new checkFail that ensures the program never
     10        runs (e.g, it has a compile error).
     11
     12        * webgpu/js/whlsl-test-harness.js:
     13        (async.checkFail):
     14        (const.webGPUPromiseTest):
     15        * webgpu/whlsl-bitwise-bool-ops-expected.txt:
     16        * webgpu/whlsl-bitwise-bool-ops.html:
     17        * webgpu/whlsl-int-literal-compare-expected.txt: Added.
     18        * webgpu/whlsl-int-literal-compare.html: Added.
     19        * webgpu/whlsl-simple-tests-expected.txt: Added.
     20        * webgpu/whlsl-simple-tests.html: Added.
     21        * webgpu/whlsl-type-mismatch-expected.txt: Added.
     22        * webgpu/whlsl-type-mismatch.html: Added.
     23        * webgpu/whlsl-uint-bitwise-expected.txt: Added.
     24        * webgpu/whlsl-uint-bitwise.html: Added.
     25
    1262019-07-08  Wenson Hsieh  <wenson_hsieh@apple.com>
    227
  • trunk/LayoutTests/webgpu/js/whlsl-test-harness.js

    r247130 r247254  
    510510}
    511511
     512async function checkFail(source) {
     513    // FIXME: Make this handle errors with proper messages once we implement the API for that.
     514    const name = "____test_name____";
     515    const program = `
     516        ${source}
     517
     518        [numthreads(1, 1, 1)]
     519        compute void ${name}(device int[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) {
     520            buffer[0] = 1;
     521        }
     522    `;
     523    const device = await getBasicDevice();
     524    const shaderModule = device.createShaderModule({code: program, isWHLSL: true});
     525    const computeStage = {module: shaderModule, entryPoint: name};
     526
     527    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]};
     528    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
     529    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
     530    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
     531
     532    const computePipelineDescriptor = {computeStage, layout: pipelineLayout};
     533    const computePipeline = device.createComputePipeline(computePipelineDescriptor);
     534
     535    const size = Int32Array.BYTES_PER_ELEMENT * 1;
     536
     537    const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC};
     538    const buffer = device.createBuffer(bufferDescriptor);
     539    const bufferArrayBuffer = await buffer.mapWriteAsync();
     540    const bufferInt32Array = new Int32Array(bufferArrayBuffer);
     541    bufferInt32Array[0] = 0;
     542    buffer.unmap();
     543
     544    const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ};
     545    const resultsBuffer = device.createBuffer(resultsBufferDescriptor);
     546
     547    const bufferBinding = {buffer: resultsBuffer, size};
     548    const bindGroupBinding = {binding: 0, resource: bufferBinding};
     549    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]};
     550    const bindGroup = device.createBindGroup(bindGroupDescriptor);
     551
     552    const commandEncoder = device.createCommandEncoder(); // {}
     553    commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size);
     554    const computePassEncoder = commandEncoder.beginComputePass();
     555    computePassEncoder.setPipeline(computePipeline);
     556    computePassEncoder.setBindGroup(0, bindGroup);
     557    computePassEncoder.dispatch(1, 1, 1);
     558    computePassEncoder.endPass();
     559    const commandBuffer = commandEncoder.finish();
     560    device.getQueue().submit([commandBuffer]);
     561
     562    const resultsArrayBuffer = await resultsBuffer.mapReadAsync();
     563    let resultsInt32Array = new Int32Array(resultsArrayBuffer);
     564    if (resultsInt32Array[0] !== 0)
     565        throw new Error("program did not fail to compile");
     566    resultsBuffer.unmap();
     567}
     568
    512569/**
    513570 * Does not return a Promise. To observe the results of a call,
     
    518575    harness.callVoidFunction(functions, name, args);
    519576}
     577
     578const webGPUPromiseTest = (testFunc, msg) => {
     579    promise_test(async () => {
     580        return testFunc().catch(e => {
     581        if (!(e instanceof WebGPUUnsupportedError))
     582            throw e;
     583        });
     584    }, msg);
     585}
     586
     587function runTests(obj) {
     588    window.addEventListener("load", async () => {
     589        try {
     590            for (const name in obj) {
     591                if (!name.startsWith("_"))
     592                    await webGPUPromiseTest(obj[name], name);
     593            }
     594        } catch (e) {
     595            if (window.testRunner)
     596                testRunner.notifyDone();
     597           
     598            throw e;
     599        }
     600    });
     601}
     602
  • trunk/LayoutTests/webgpu/msl-harness-test.html

    r246824 r247254  
    206206    }, "Return an expected float4 value.");
    207207}
    208 
    209 const webGPUPromiseTest = (testFunc, msg) => {
    210     promise_test(async () => {
    211         return testFunc().catch(e => {
    212         if (!(e instanceof WebGPUUnsupportedError))
    213             throw e;
    214         });
    215     }, msg);
    216 }
    217208</script>
    218209</html>
  • trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt

    r247067 r247254  
    11
    2 PASS Bool bit and
    3 PASS Bool bit or
    4 PASS Bool bit or
    5 PASS Bool bit not
     2PASS boolBitAnd
     3PASS boolBitOr
     4PASS boolBitXor
     5PASS boolBitNot
    66
  • trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops.html

    r247067 r247254  
    1212const whlslTests = {};
    1313
    14 whlslTests.boolBitAnd = () => {
     14whlslTests.boolBitAnd = async () => {
    1515    const source = `
    1616        bool foo(bool a, bool b)
     
    2020    `;
    2121
    22     webGPUPromiseTest(async () => {
    23         try {
    24             {
    25                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
    26                 assert_equals(result, true, "Test returned expected value.");
    27             }
     22    {
     23        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
     24        assert_equals(result, true, "Test returned expected value.");
     25    }
    2826
    29             {
    30                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
    31                 assert_equals(result, false, "Test returned expected value.");
    32             }
     27    {
     28        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
     29        assert_equals(result, false, "Test returned expected value.");
     30    }
    3331
    34             {
    35                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
    36                 assert_equals(result, false, "Test returned expected value.");
    37             }
     32    {
     33        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
     34        assert_equals(result, false, "Test returned expected value.");
     35    }
    3836
    39             {
    40                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
    41                 assert_equals(result, false, "Test returned expected value.");
    42             }
    43         } catch(e) {
    44             if (!(e instanceof WebGPUUnsupportedError))
    45                 throw e;
    46         }
    47     }, "Bool bit and");
     37    {
     38        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
     39        assert_equals(result, false, "Test returned expected value.");
     40    }
    4841};
    4942
    50 whlslTests.boolBitOr = () => {
     43whlslTests.boolBitOr = async () => {
    5144    const source = `
    5245        bool foo(bool a, bool b)
     
    5649    `;
    5750
    58     webGPUPromiseTest(async () => {
    59         try {
    60             {
    61                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
    62                 assert_equals(result, true, "Test returned expected value.");
    63             }
     51    {
     52        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
     53        assert_equals(result, true, "Test returned expected value.");
     54    }
    6455
    65             {
    66                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
    67                 assert_equals(result, false, "Test returned expected value.");
    68             }
     56    {
     57        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
     58        assert_equals(result, false, "Test returned expected value.");
     59    }
    6960
    70             {
    71                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
    72                 assert_equals(result, true, "Test returned expected value.");
    73             }
     61    {
     62        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
     63        assert_equals(result, true, "Test returned expected value.");
     64    }
    7465
    75             {
    76                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
    77                 assert_equals(result, true, "Test returned expected value.");
    78             }
    79         } catch(e) {
    80             if (!(e instanceof WebGPUUnsupportedError))
    81                 throw e;
    82         }
    83     }, "Bool bit or");
     66    {
     67        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
     68        assert_equals(result, true, "Test returned expected value.");
     69    }
    8470};
    8571
    86 whlslTests.boolBitXor = () => {
     72whlslTests.boolBitXor = async () => {
    8773    const source = `
    8874        bool foo(bool a, bool b)
     
    9278    `;
    9379
    94     webGPUPromiseTest(async () => {
    95         try {
    96             {
    97                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
    98                 assert_equals(result, false, "Test returned expected value.");
    99             }
     80    {
     81        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]);
     82        assert_equals(result, false, "Test returned expected value.");
     83    }
    10084
    101             {
    102                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
    103                 assert_equals(result, false, "Test returned expected value.");
    104             }
     85    {
     86        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]);
     87        assert_equals(result, false, "Test returned expected value.");
     88    }
    10589
    106             {
    107                 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
    108                 assert_equals(result, true, "Test returned expected value.");
    109             }
     90    {
     91        let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]);
     92        assert_equals(result, true, "Test returned expected value.");
     93    }
    11094
    111             {
    112                 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
    113                 assert_equals(result, true, "Test returned expected value.");
    114             }
    115         } catch(e) {
    116             if (!(e instanceof WebGPUUnsupportedError))
    117                 throw e;
    118         }
    119     }, "Bool bit or");
     95    {
     96        let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]);
     97        assert_equals(result, true, "Test returned expected value.");
     98    }
    12099};
    121100
    122 whlslTests.boolBitNot = () => {
     101whlslTests.boolBitNot = async () => {
    123102    const source = `
    124103        bool foo(bool a)
     
    128107    `;
    129108
    130     webGPUPromiseTest(async () => {
    131         try {
    132             {
    133                 let result = await callBoolFunction(source, "foo", [makeBool(true)]);
    134                 assert_equals(result, false, "Test returned expected value.");
    135             }
     109    {
     110        let result = await callBoolFunction(source, "foo", [makeBool(true)]);
     111        assert_equals(result, false, "Test returned expected value.");
     112    }
    136113
    137             {
    138                 let result = await callBoolFunction(source, "foo", [makeBool(false)]);
    139                 assert_equals(result, true, "Test returned expected value.");
    140             }
    141         } catch(e) {
    142             if (!(e instanceof WebGPUUnsupportedError))
    143                 throw e;
    144         }
    145     }, "Bool bit not");
     114    {
     115        let result = await callBoolFunction(source, "foo", [makeBool(false)]);
     116        assert_equals(result, true, "Test returned expected value.");
     117    }
    146118};
    147119
    148 function runTests(obj) {
    149     window.addEventListener("load", () => {
    150         try {
    151             for (const name in obj) {
    152                 if (!name.startsWith("_"))
    153                     obj[name]();
    154             }
    155         } catch (e) {
    156             if (window.testRunner)
    157                 testRunner.notifyDone();
    158            
    159             throw e;
    160         }
    161     });
    162 }
    163 
    164120runTests(whlslTests);
    165 
    166 const webGPUPromiseTest = (testFunc, msg) => {
    167     promise_test(async () => {
    168         return testFunc().catch(e => {
    169         if (!(e instanceof WebGPUUnsupportedError))
    170             throw e;
    171         });
    172     }, msg);
    173 }
    174121</script>
    175122</html>
  • trunk/LayoutTests/webgpu/whlsl-test-harness-test.html

    r247130 r247254  
    263263    return [src, name, values];
    264264};
    265 
    266 const webGPUPromiseTest = (testFunc, msg) => {
    267     promise_test(async () => {
    268         return testFunc().catch(e => {
    269         if (!(e instanceof WebGPUUnsupportedError))
    270             throw e;
    271         });
    272     }, msg);
    273 }
    274265</script>
    275266</html>
  • trunk/Source/WebCore/ChangeLog

    r247246 r247254  
     12019-07-08  Saam Barati  <sbarati@apple.com>
     2
     3        [WHLSL Import 23 new JS reference spec tests
     4        https://bugs.webkit.org/show_bug.cgi?id=199604
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        This patch imports a bunch of JS reference spec tests on our way to
     9        completing https://bugs.webkit.org/show_bug.cgi?id=199595
     10       
     11        It also fixes the recursion checker phase. That phase had two bugs:
     12        1. We'd assert after visiting the function declaration that it was
     13        still in the set. However, it will not be in the set when we actually
     14        detect recursion.
     15        2. We would not visit the arguments to a call, so if they contained other
     16        calls which were recursive, we would not detect such recursive calls.
     17
     18        Tests: webgpu/whlsl-int-literal-compare.html
     19               webgpu/whlsl-simple-tests.html
     20               webgpu/whlsl-type-mismatch.html
     21               webgpu/whlsl-uint-bitwise.html
     22
     23        * Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp:
     24
    1252019-07-08  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp

    r247174 r247254  
    5050
    5151        Visitor::visit(functionDefinition);
     52        if (error())
     53            return;
    5254
    5355        auto success = m_visitingSet.remove(&functionDefinition);
     
    5759    void visit(AST::CallExpression& callExpression) override
    5860    {
    59         Visitor::visit(callExpression.function());
     61        Visitor::visit(callExpression);
     62        if (is<AST::FunctionDefinition>(callExpression.function()))
     63            checkErrorAndVisit(downcast<AST::FunctionDefinition>(callExpression.function()));
    6064    }
    6165
Note: See TracChangeset for help on using the changeset viewer.