Changeset 247254 in webkit
- Timestamp:
- Jul 8, 2019 10:32:26 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247251 r247254 1 2019-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 1 26 2019-07-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 27 -
trunk/LayoutTests/webgpu/js/whlsl-test-harness.js
r247130 r247254 510 510 } 511 511 512 async 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 512 569 /** 513 570 * Does not return a Promise. To observe the results of a call, … … 518 575 harness.callVoidFunction(functions, name, args); 519 576 } 577 578 const 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 587 function 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 206 206 }, "Return an expected float4 value."); 207 207 } 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 }217 208 </script> 218 209 </html> -
trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt
r247067 r247254 1 1 2 PASS Bool bit and3 PASS Bool bit or4 PASS Bool bitor5 PASS Bool bit not2 PASS boolBitAnd 3 PASS boolBitOr 4 PASS boolBitXor 5 PASS boolBitNot 6 6 -
trunk/LayoutTests/webgpu/whlsl-bitwise-bool-ops.html
r247067 r247254 12 12 const whlslTests = {}; 13 13 14 whlslTests.boolBitAnd = () => {14 whlslTests.boolBitAnd = async () => { 15 15 const source = ` 16 16 bool foo(bool a, bool b) … … 20 20 `; 21 21 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 } 28 26 29 30 31 32 27 { 28 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); 29 assert_equals(result, false, "Test returned expected value."); 30 } 33 31 34 35 36 37 32 { 33 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); 34 assert_equals(result, false, "Test returned expected value."); 35 } 38 36 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 } 48 41 }; 49 42 50 whlslTests.boolBitOr = () => {43 whlslTests.boolBitOr = async () => { 51 44 const source = ` 52 45 bool foo(bool a, bool b) … … 56 49 `; 57 50 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 } 64 55 65 66 67 68 56 { 57 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); 58 assert_equals(result, false, "Test returned expected value."); 59 } 69 60 70 71 72 73 61 { 62 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); 63 assert_equals(result, true, "Test returned expected value."); 64 } 74 65 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 } 84 70 }; 85 71 86 whlslTests.boolBitXor = () => {72 whlslTests.boolBitXor = async () => { 87 73 const source = ` 88 74 bool foo(bool a, bool b) … … 92 78 `; 93 79 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 } 100 84 101 102 103 104 85 { 86 let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); 87 assert_equals(result, false, "Test returned expected value."); 88 } 105 89 106 107 108 109 90 { 91 let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); 92 assert_equals(result, true, "Test returned expected value."); 93 } 110 94 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 } 120 99 }; 121 100 122 whlslTests.boolBitNot = () => {101 whlslTests.boolBitNot = async () => { 123 102 const source = ` 124 103 bool foo(bool a) … … 128 107 `; 129 108 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 } 136 113 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 } 146 118 }; 147 119 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 164 120 runTests(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 }174 121 </script> 175 122 </html> -
trunk/LayoutTests/webgpu/whlsl-test-harness-test.html
r247130 r247254 263 263 return [src, name, values]; 264 264 }; 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 }274 265 </script> 275 266 </html> -
trunk/Source/WebCore/ChangeLog
r247246 r247254 1 2019-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 1 25 2019-07-08 Chris Dumez <cdumez@apple.com> 2 26 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp
r247174 r247254 50 50 51 51 Visitor::visit(functionDefinition); 52 if (error()) 53 return; 52 54 53 55 auto success = m_visitingSet.remove(&functionDefinition); … … 57 59 void visit(AST::CallExpression& callExpression) override 58 60 { 59 Visitor::visit(callExpression.function()); 61 Visitor::visit(callExpression); 62 if (is<AST::FunctionDefinition>(callExpression.function())) 63 checkErrorAndVisit(downcast<AST::FunctionDefinition>(callExpression.function())); 60 64 } 61 65
Note: See TracChangeset
for help on using the changeset viewer.