WebKit Bugzilla
Attachment 373694 Details for
Bug 199604
: [WHLSL] Import 23 new JS reference spec tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for landing
a-backup.diff (text/plain), 26.30 KB, created by
Saam Barati
on 2019-07-08 19:31:28 PDT
(
hide
)
Description:
patch for landing
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2019-07-08 19:31:28 PDT
Size:
26.30 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 247246) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,27 @@ >+2019-07-08 Saam Barati <sbarati@apple.com> >+ >+ [WHLSL Import 23 new JS reference spec tests >+ https://bugs.webkit.org/show_bug.cgi?id=199604 >+ >+ Reviewed by Myles C. Maxfield. >+ >+ 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. >+ 2. 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: >+ > 2019-07-08 Chris Dumez <cdumez@apple.com> > > Make Document::postTask() safe to call from a background thread >Index: Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp >=================================================================== >--- Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp (revision 247230) >+++ Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp (working copy) >@@ -49,6 +49,8 @@ private: > } > > Visitor::visit(functionDefinition); >+ if (error()) >+ return; > > auto success = m_visitingSet.remove(&functionDefinition); > ASSERT_UNUSED(success, success); >@@ -56,7 +58,9 @@ private: > > void visit(AST::CallExpression& callExpression) override > { >- Visitor::visit(callExpression.function()); >+ Visitor::visit(callExpression); >+ if (is<AST::FunctionDefinition>(callExpression.function())) >+ checkErrorAndVisit(downcast<AST::FunctionDefinition>(callExpression.function())); > } > > HashSet<AST::FunctionDefinition*> m_visitingSet; >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 247230) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,28 @@ >+2019-07-08 Saam Barati <sbarati@apple.com> >+ >+ [WHLSL Import 23 new JS reference spec tests >+ https://bugs.webkit.org/show_bug.cgi?id=199604 >+ >+ Reviewed by Myles C. Maxfield. >+ >+ 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. >+ > 2019-07-08 Charlie Turner <cturner@igalia.com> > > [GTK] Some media fragment tests are flaky >Index: LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt (revision 247230) >+++ LayoutTests/webgpu/whlsl-bitwise-bool-ops-expected.txt (working copy) >@@ -1,6 +1,6 @@ > >-PASS Bool bit and >-PASS Bool bit or >-PASS Bool bit or >-PASS Bool bit not >+PASS boolBitAnd >+PASS boolBitOr >+PASS boolBitXor >+PASS boolBitNot > >Index: LayoutTests/webgpu/whlsl-bitwise-bool-ops.html >=================================================================== >--- LayoutTests/webgpu/whlsl-bitwise-bool-ops.html (revision 247230) >+++ LayoutTests/webgpu/whlsl-bitwise-bool-ops.html (working copy) >@@ -11,7 +11,7 @@ const epsilon = 0.0001; > > const whlslTests = {}; > >-whlslTests.boolBitAnd = () => { >+whlslTests.boolBitAnd = async () => { > const source = ` > bool foo(bool a, bool b) > { >@@ -19,35 +19,28 @@ whlslTests.boolBitAnd = () => { > } > `; > >- webGPUPromiseTest(async () => { >- try { >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- } catch(e) { >- if (!(e instanceof WebGPUUnsupportedError)) >- throw e; >- } >- }, "Bool bit and"); >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } > }; > >-whlslTests.boolBitOr = () => { >+whlslTests.boolBitOr = async () => { > const source = ` > bool foo(bool a, bool b) > { >@@ -55,35 +48,28 @@ whlslTests.boolBitOr = () => { > } > `; > >- webGPUPromiseTest(async () => { >- try { >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- } catch(e) { >- if (!(e instanceof WebGPUUnsupportedError)) >- throw e; >- } >- }, "Bool bit or"); >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } > }; > >-whlslTests.boolBitXor = () => { >+whlslTests.boolBitXor = async () => { > const source = ` > bool foo(bool a, bool b) > { >@@ -91,35 +77,28 @@ whlslTests.boolBitXor = () => { > } > `; > >- webGPUPromiseTest(async () => { >- try { >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- } catch(e) { >- if (!(e instanceof WebGPUUnsupportedError)) >- throw e; >- } >- }, "Bool bit or"); >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(true)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(false)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true), makeBool(false)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false), makeBool(true)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } > }; > >-whlslTests.boolBitNot = () => { >+whlslTests.boolBitNot = async () => { > const source = ` > bool foo(bool a) > { >@@ -127,49 +106,17 @@ whlslTests.boolBitNot = () => { > } > `; > >- webGPUPromiseTest(async () => { >- try { >- { >- let result = await callBoolFunction(source, "foo", [makeBool(true)]); >- assert_equals(result, false, "Test returned expected value."); >- } >- >- { >- let result = await callBoolFunction(source, "foo", [makeBool(false)]); >- assert_equals(result, true, "Test returned expected value."); >- } >- } catch(e) { >- if (!(e instanceof WebGPUUnsupportedError)) >- throw e; >- } >- }, "Bool bit not"); >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(true)]); >+ assert_equals(result, false, "Test returned expected value."); >+ } >+ >+ { >+ let result = await callBoolFunction(source, "foo", [makeBool(false)]); >+ assert_equals(result, true, "Test returned expected value."); >+ } > }; > >-function runTests(obj) { >- window.addEventListener("load", () => { >- try { >- for (const name in obj) { >- if (!name.startsWith("_")) >- obj[name](); >- } >- } catch (e) { >- if (window.testRunner) >- testRunner.notifyDone(); >- >- throw e; >- } >- }); >-} >- > runTests(whlslTests); >- >-const webGPUPromiseTest = (testFunc, msg) => { >- promise_test(async () => { >- return testFunc().catch(e => { >- if (!(e instanceof WebGPUUnsupportedError)) >- throw e; >- }); >- }, msg); >-} > </script> > </html> >Index: LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt (nonexistent) >+++ LayoutTests/webgpu/whlsl-int-literal-compare-expected.txt (working copy) >@@ -0,0 +1,3 @@ >+ >+PASS twoIntLiterals >+ >Index: LayoutTests/webgpu/whlsl-int-literal-compare.html >=================================================================== >--- LayoutTests/webgpu/whlsl-int-literal-compare.html (nonexistent) >+++ LayoutTests/webgpu/whlsl-int-literal-compare.html (working copy) >@@ -0,0 +1,24 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> >+<html> >+<meta charset=utf-8> >+<meta name="timeout" content="long"> >+<title>Test the WHLSL test harness.</title> >+<script src="js/whlsl-test-harness.js"></script> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+const whlslTests = {}; >+ >+whlslTests.twoIntLiterals = async () => { >+ let program = ` >+ bool foo() >+ { >+ return 42 == 42; >+ } >+ `; >+ assert_equals(await callBoolFunction(program, "foo", []), true); >+} >+ >+runTests(whlslTests); >+</script> >+</html> >Index: LayoutTests/webgpu/whlsl-simple-tests-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-simple-tests-expected.txt (nonexistent) >+++ LayoutTests/webgpu/whlsl-simple-tests-expected.txt (working copy) >@@ -0,0 +1,7 @@ >+ >+PASS simpleUnreachableCode >+PASS simpleNoReturn >+PASS simpleRecursiveStruct >+PASS simpleRecursion >+PASS simpleRecursion2 >+ >Index: LayoutTests/webgpu/whlsl-simple-tests.html >=================================================================== >--- LayoutTests/webgpu/whlsl-simple-tests.html (nonexistent) >+++ LayoutTests/webgpu/whlsl-simple-tests.html (working copy) >@@ -0,0 +1,63 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> >+<html> >+<meta charset=utf-8> >+<meta name="timeout" content="long"> >+<title>Test the WHLSL test harness.</title> >+<script src="js/whlsl-test-harness.js"></script> >+<script src="js/webgpu-functions.js"></script> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+const whlslTests = {}; >+ >+whlslTests.simpleUnreachableCode = async () => { >+ await checkFail( >+ ` >+ void foo() >+ { >+ return; >+ int x; >+ } >+ `); >+} >+ >+whlslTests.simpleNoReturn = async () => { >+ await checkFail("int foo() { }"); >+} >+ >+whlslTests.simpleRecursiveStruct = async () => { >+ await checkFail( >+ ` >+ struct Foo { >+ Foo foo; >+ } >+ `); >+} >+ >+whlslTests.simpleRecursion = async () => { >+ await checkFail( >+ ` >+ void foo(int x) >+ { >+ foo(x); >+ } >+ `); >+} >+ >+whlslTests.simpleRecursion2 = async () => { >+ await checkFail( >+ ` >+ int bar(int x) { >+ foo(x); >+ return x; >+ } >+ void foo(int x) >+ { >+ foo(bar(x)); >+ } >+ `); >+} >+ >+runTests(whlslTests); >+</script> >+</html> >Index: LayoutTests/webgpu/whlsl-type-mismatch-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-type-mismatch-expected.txt (nonexistent) >+++ LayoutTests/webgpu/whlsl-type-mismatch-expected.txt (working copy) >@@ -0,0 +1,6 @@ >+ >+PASS typeMismatchReturn >+PASS typeMismatchVariableDecl >+PASS typeMismatchAssignment >+PASS typeMismatchReturnParam >+ >Index: LayoutTests/webgpu/whlsl-type-mismatch.html >=================================================================== >--- LayoutTests/webgpu/whlsl-type-mismatch.html (nonexistent) >+++ LayoutTests/webgpu/whlsl-type-mismatch.html (working copy) >@@ -0,0 +1,62 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> >+<html> >+<meta charset=utf-8> >+<meta name="timeout" content="long"> >+<title>Test the WHLSL test harness.</title> >+<script src="js/whlsl-test-harness.js"></script> >+<script src="js/webgpu-functions.js"></script> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+ >+const whlslTests = {}; >+ >+whlslTests.typeMismatchReturn = async () => >+{ >+ await checkFail( >+ ` >+ int foo() >+ { >+ return 10.5; >+ } >+ `); >+} >+ >+whlslTests.typeMismatchVariableDecl = async () => >+{ >+ await checkFail( >+ ` >+ void foo(uint x) >+ { >+ int y = x; >+ } >+ `); >+} >+ >+whlslTests.typeMismatchAssignment = async () => >+{ >+ await checkFail( >+ ` >+ void foo(uint x) >+ { >+ int y; >+ y = x; >+ } >+ `); >+} >+ >+whlslTests.typeMismatchReturnParam = async () => >+{ >+ await checkFail( >+ ` >+ int foo(uint x) >+ { >+ return x; >+ } >+ `); >+} >+ >+runTests(whlslTests); >+ >+</script> >+</html> >Index: LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt (nonexistent) >+++ LayoutTests/webgpu/whlsl-uint-bitwise-expected.txt (working copy) >@@ -0,0 +1,9 @@ >+ >+PASS uintBitAnd >+PASS uintBitOr >+PASS uintBitXor >+PASS uintBitNot >+PASS uintLShift >+PASS uintRShift >+PASS uintSimpleMath >+ >Index: LayoutTests/webgpu/whlsl-uint-bitwise.html >=================================================================== >--- LayoutTests/webgpu/whlsl-uint-bitwise.html (nonexistent) >+++ LayoutTests/webgpu/whlsl-uint-bitwise.html (working copy) >@@ -0,0 +1,108 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> >+<html> >+<meta charset=utf-8> >+<meta name="timeout" content="long"> >+<title>Test the WHLSL test harness.</title> >+<script src="js/whlsl-test-harness.js"></script> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+const whlslTests = {}; >+ >+whlslTests.uintBitAnd = async () => { >+ let program = ` >+ uint foo(uint a, uint b) >+ { >+ return a & b; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 1); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 42); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32) - 7)]), 4294967289); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 0); >+} >+ >+whlslTests.uintBitOr = async () => { >+ let program = ` >+ uint foo(uint a, uint b) >+ { >+ return a | b; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 7); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 65535); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32) - 7)]), 4294967295); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 85732); >+} >+ >+whlslTests.uintBitXor = async () => { >+ let program = ` >+ uint foo(uint a, uint b) >+ { >+ return a ^ b; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 6); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(42)]), 65493); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(Math.pow(2, 32) - 7)]), 6); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(85732)]), 85732); >+} >+ >+whlslTests.uintBitNot = async () => { >+ let program = ` >+ uint foo(uint a) >+ { >+ return ~a; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1)]), 4294967294); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535)]), 4294901760); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1)]), 0); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0)]), 4294967295); >+} >+ >+whlslTests.uintLShift = async () => { >+ let program = ` >+ uint foo(uint a, uint b) >+ { >+ return a << b; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 128); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(2)]), 262140); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(5)]), 4294967264); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(3)]), 0); >+}; >+ >+whlslTests.uintRShift = async () => { >+ let program = ` >+ uint foo(uint a, uint b) >+ { >+ return a >> b; >+ } >+ `; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(1), makeUint(7)]), 0); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(65535), makeUint(2)]), 16383); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(Math.pow(2, 32) - 1), makeUint(5)]), 134217727); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(0), makeUint(3)]), 0); >+}; >+ >+whlslTests.uintSimpleMath = async () => { >+ let program = "uint foo(uint x, uint y) { return x + y; }"; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 12); >+ >+ program = "uint foo(uint x, uint y) { return x - y; }"; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 2); >+ assert_equals(await callUintFunction(program, "foo", [makeUint(5), makeUint(7)]), 4294967294); >+ >+ program = "uint foo(uint x, uint y) { return x * y; }"; >+ assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(5)]), 35); >+ >+ // FIXME: make this work: https://bugs.webkit.org/show_bug.cgi?id=199602 >+ // program = "uint foo(uint x, uint y) { return x / y; }"; >+ // assert_equals(await callUintFunction(program, "foo", [makeUint(7), makeUint(2)]), 3); >+} >+ >+runTests(whlslTests); >+</script> >+</html> >Index: LayoutTests/webgpu/js/whlsl-test-harness.js >=================================================================== >--- LayoutTests/webgpu/js/whlsl-test-harness.js (revision 247230) >+++ LayoutTests/webgpu/js/whlsl-test-harness.js (working copy) >@@ -509,6 +509,63 @@ async function callFloat4x4Function(func > return (await harness.callTypedFunction(Types.FLOAT4X4, functions, name, args)).subarray(0, 16); > } > >+async function checkFail(source) { >+ // FIXME: Make this handle errors with proper messages once we implement the API for that. >+ const name = "____test_name____"; >+ const program = ` >+ ${source} >+ >+ [numthreads(1, 1, 1)] >+ compute void ${name}(device int[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) { >+ buffer[0] = 1; >+ } >+ `; >+ const device = await getBasicDevice(); >+ const shaderModule = device.createShaderModule({code: program, isWHLSL: true}); >+ const computeStage = {module: shaderModule, entryPoint: name}; >+ >+ const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]}; >+ const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); >+ const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; >+ const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor); >+ >+ const computePipelineDescriptor = {computeStage, layout: pipelineLayout}; >+ const computePipeline = device.createComputePipeline(computePipelineDescriptor); >+ >+ const size = Int32Array.BYTES_PER_ELEMENT * 1; >+ >+ const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; >+ const buffer = device.createBuffer(bufferDescriptor); >+ const bufferArrayBuffer = await buffer.mapWriteAsync(); >+ const bufferInt32Array = new Int32Array(bufferArrayBuffer); >+ bufferInt32Array[0] = 0; >+ buffer.unmap(); >+ >+ const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; >+ const resultsBuffer = device.createBuffer(resultsBufferDescriptor); >+ >+ const bufferBinding = {buffer: resultsBuffer, size}; >+ const bindGroupBinding = {binding: 0, resource: bufferBinding}; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; >+ const bindGroup = device.createBindGroup(bindGroupDescriptor); >+ >+ const commandEncoder = device.createCommandEncoder(); // {} >+ commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size); >+ const computePassEncoder = commandEncoder.beginComputePass(); >+ computePassEncoder.setPipeline(computePipeline); >+ computePassEncoder.setBindGroup(0, bindGroup); >+ computePassEncoder.dispatch(1, 1, 1); >+ computePassEncoder.endPass(); >+ const commandBuffer = commandEncoder.finish(); >+ device.getQueue().submit([commandBuffer]); >+ >+ const resultsArrayBuffer = await resultsBuffer.mapReadAsync(); >+ let resultsInt32Array = new Int32Array(resultsArrayBuffer); >+ if (resultsInt32Array[0] !== 0) >+ throw new Error("program did not fail to compile"); >+ resultsBuffer.unmap(); >+} >+ > /** > * Does not return a Promise. To observe the results of a call, > * call 'getArrayBuffer' on the Data object retaining your output buffer. >@@ -517,3 +574,29 @@ function callVoidFunction(functions, nam > { > harness.callVoidFunction(functions, name, args); > } >+ >+const webGPUPromiseTest = (testFunc, msg) => { >+ promise_test(async () => { >+ return testFunc().catch(e => { >+ if (!(e instanceof WebGPUUnsupportedError)) >+ throw e; >+ }); >+ }, msg); >+} >+ >+function runTests(obj) { >+ window.addEventListener("load", async () => { >+ try { >+ for (const name in obj) { >+ if (!name.startsWith("_")) >+ await webGPUPromiseTest(obj[name], name); >+ } >+ } catch (e) { >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ >+ throw e; >+ } >+ }); >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199604
:
373689
|
373692
|
373694
|
373695