From 260eaf17f37eb4fe08b697f89192e32bccf90d4e Mon Sep 17 00:00:00 2001 From: David Neto Date: Fri, 15 Mar 2024 16:11:14 -0400 Subject: [PATCH] Test validation of arg numbers and types, must_use for degrees, radians, sqrt --- src/webgpu/listing_meta.json | 6 ++++ .../expression/call/builtin/degrees.spec.ts | 33 +++++++++++++++++++ .../expression/call/builtin/radians.spec.ts | 33 +++++++++++++++++++ .../expression/call/builtin/sqrt.spec.ts | 33 +++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index b5862c4ec95c..05a7975a4413 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1888,7 +1888,9 @@ "webgpu:shader,validation,expression,call,builtin,cos:values:*": { "subcaseMS": 0.338 }, "webgpu:shader,validation,expression,call,builtin,cosh:integer_argument:*": { "subcaseMS": 0.889 }, "webgpu:shader,validation,expression,call,builtin,cosh:values:*": { "subcaseMS": 0.272 }, + "webgpu:shader,validation,expression,call,builtin,degrees:args:*": { "subcaseMS": 4.949 }, "webgpu:shader,validation,expression,call,builtin,degrees:integer_argument:*": { "subcaseMS": 1.311 }, + "webgpu:shader,validation,expression,call,builtin,degrees:must_use:*": { "subcaseMS": 1.406 }, "webgpu:shader,validation,expression,call,builtin,degrees:values:*": { "subcaseMS": 0.303 }, "webgpu:shader,validation,expression,call,builtin,derivatives:invalid_argument_types:*": { "subcaseMS": 1.000 }, "webgpu:shader,validation,expression,call,builtin,derivatives:only_in_fragment:*": { "subcaseMS": 1.000 }, @@ -1947,7 +1949,9 @@ "webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:must_use:*": { "subcaseMS": 32.600 }, "webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:supported:*": { "subcaseMS": 134.750 }, "webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:unsupported:*": { "subcaseMS": 570.500 }, + "webgpu:shader,validation,expression,call,builtin,radians:args:*": { "subcaseMS": 4.561 }, "webgpu:shader,validation,expression,call,builtin,radians:integer_argument:*": { "subcaseMS": 1.811 }, + "webgpu:shader,validation,expression,call,builtin,radians:must_use:*": { "subcaseMS": 0.757 }, "webgpu:shader,validation,expression,call,builtin,radians:values:*": { "subcaseMS": 0.382 }, "webgpu:shader,validation,expression,call,builtin,round:integer_argument:*": { "subcaseMS": 1.834 }, "webgpu:shader,validation,expression,call,builtin,round:values:*": { "subcaseMS": 0.382 }, @@ -1961,7 +1965,9 @@ "webgpu:shader,validation,expression,call,builtin,sin:values:*": { "subcaseMS": 0.349 }, "webgpu:shader,validation,expression,call,builtin,sinh:integer_argument:*": { "subcaseMS": 1.078 }, "webgpu:shader,validation,expression,call,builtin,sinh:values:*": { "subcaseMS": 0.357 }, + "webgpu:shader,validation,expression,call,builtin,sqrt:args:*": { "subcaseMS": 5.398 }, "webgpu:shader,validation,expression,call,builtin,sqrt:integer_argument:*": { "subcaseMS": 1.356 }, + "webgpu:shader,validation,expression,call,builtin,sqrt:must_use:*": { "subcaseMS": 1.286 }, "webgpu:shader,validation,expression,call,builtin,sqrt:values:*": { "subcaseMS": 0.302 }, "webgpu:shader,validation,expression,call,builtin,tan:integer_argument:*": { "subcaseMS": 1.734 }, "webgpu:shader,validation,expression,call,builtin,tan:values:*": { "subcaseMS": 0.350 }, diff --git a/src/webgpu/shader/validation/expression/call/builtin/degrees.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/degrees.spec.ts index f1cba6a6aef8..058f6ffa6cb9 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/degrees.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/degrees.spec.ts @@ -79,3 +79,36 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}() 'constant' ); }); + +const kArgCases = { + good: '(1.1)', + bad_no_parens: '', + // Bad number of args + bad_too_few: '()', + bad_too_many: '(1.0,2.0)', + // Bad value type for arg 0 + bad_0i32: '(1i)', + bad_0u32: '(1u)', + bad_0bool: '(false)', + bad_0vec2u: '(vec2u())', + bad_0array: '(array(1.1,2.2))', + bad_0struct: '(modf(2.2))', +}; + +g.test('args') + .desc(`Test compilation failure of ${builtin} with variously shaped and typed arguments`) + .params(u => u.combine('arg', keysOf(kArgCases))) + .fn(t => { + t.expectCompileResult( + t.params.arg === 'good', + `const c = ${builtin}${kArgCases[t.params.arg]};` + ); + }); + +g.test('must_use') + .desc(`Result of ${builtin} must be used`) + .params(u => u.combine('use', [true, false])) + .fn(t => { + const use_it = t.params.use ? '_ = ' : ''; + t.expectCompileResult(t.params.use, `fn f() { ${use_it}${builtin}${kArgCases['good']}; }`); + }); diff --git a/src/webgpu/shader/validation/expression/call/builtin/radians.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/radians.spec.ts index 8689bc3dbbe8..9017231b690a 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/radians.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/radians.spec.ts @@ -73,3 +73,36 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}() 'constant' ); }); + +const kArgCases = { + good: '(1.1)', + bad_no_parens: '', + // Bad number of args + bad_too_few: '()', + bad_too_many: '(1.0,2.0)', + // Bad value type for arg 0 + bad_0i32: '(1i)', + bad_0u32: '(1u)', + bad_0bool: '(false)', + bad_0vec2u: '(vec2u())', + bad_0array: '(array(1.1,2.2))', + bad_0struct: '(modf(2.2))', +}; + +g.test('args') + .desc(`Test compilation failure of ${builtin} with variously shaped and typed arguments`) + .params(u => u.combine('arg', keysOf(kArgCases))) + .fn(t => { + t.expectCompileResult( + t.params.arg === 'good', + `const c = ${builtin}${kArgCases[t.params.arg]};` + ); + }); + +g.test('must_use') + .desc(`Result of ${builtin} must be used`) + .params(u => u.combine('use', [true, false])) + .fn(t => { + const use_it = t.params.use ? '_ = ' : ''; + t.expectCompileResult(t.params.use, `fn f() { ${use_it}${builtin}${kArgCases['good']}; }`); + }); diff --git a/src/webgpu/shader/validation/expression/call/builtin/sqrt.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/sqrt.spec.ts index 7e983adf188c..cabb0d59fb22 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/sqrt.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/sqrt.spec.ts @@ -88,3 +88,36 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}() 'constant' ); }); + +const kArgCases = { + good: '(1.1)', + bad_no_parens: '', + // Bad number of args + bad_too_few: '()', + bad_too_many: '(1.0,2.0)', + // Bad value type for arg 0 + bad_0i32: '(1i)', + bad_0u32: '(1u)', + bad_0bool: '(false)', + bad_0vec2u: '(vec2u())', + bad_0array: '(array(1.1,2.2))', + bad_0struct: '(modf(2.2))', +}; + +g.test('args') + .desc(`Test compilation failure of ${builtin} with variously shaped and typed arguments`) + .params(u => u.combine('arg', keysOf(kArgCases))) + .fn(t => { + t.expectCompileResult( + t.params.arg === 'good', + `const c = ${builtin}${kArgCases[t.params.arg]};` + ); + }); + +g.test('must_use') + .desc(`Result of ${builtin} must be used`) + .params(u => u.combine('use', [true, false])) + .fn(t => { + const use_it = t.params.use ? '_ = ' : ''; + t.expectCompileResult(t.params.use, `fn f() { ${use_it}${builtin}${kArgCases['good']}; }`); + });