From f1aa9428a23f53c98aaa9588af36e319b37ed94e Mon Sep 17 00:00:00 2001 From: David Neto Date: Wed, 13 Mar 2024 16:36:50 -0400 Subject: [PATCH] wgsl: validate floor negative test cases (#3492) - use without parens - bad arguments - @must_use Issue: #3283 --- src/webgpu/listing_meta.json | 2 ++ .../expression/call/builtin/floor.spec.ts | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 3ac0ab414253..6e30934e818c 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1881,7 +1881,9 @@ "webgpu:shader,validation,expression,call,builtin,exp2:values:*": { "subcaseMS": 0.410 }, "webgpu:shader,validation,expression,call,builtin,exp:integer_argument:*": { "subcaseMS": 1.356 }, "webgpu:shader,validation,expression,call,builtin,exp:values:*": { "subcaseMS": 0.311 }, + "webgpu:shader,validation,expression,call,builtin,floor:bad_args:*": { "subcaseMS": 14.467 }, "webgpu:shader,validation,expression,call,builtin,floor:integer_argument:*": { "subcaseMS": 48.400 }, + "webgpu:shader,validation,expression,call,builtin,floor:must_use:*": { "subcaseMS": 0.170 }, "webgpu:shader,validation,expression,call,builtin,floor:values:*": { "subcaseMS": 29.668 }, "webgpu:shader,validation,expression,call,builtin,inverseSqrt:integer_argument:*": { "subcaseMS": 1.356 }, "webgpu:shader,validation,expression,call,builtin,inverseSqrt:values:*": { "subcaseMS": 0.315 }, diff --git a/src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts index b65fafc74466..e43c6fa3fe43 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts @@ -73,3 +73,32 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}() 'constant' ); }); + +const kGoodArgs = '(1.1)'; +const kBadArgs = { + no_parens: '', + // Bad number of args + '0args': '()', + '2args': '(1.0,2.0)', + // Bad value for arg 0 + '0aint': '(1)', + '0i32': '(1i)', + '0u32': '(1u)', + '0bool': '(false)', + '0vec2u': '(vec2u())', + '0array': '(array(1.1,2.2))', + '0struct': '(modf(2.2))', +}; + +g.test('bad_args') + .desc(`Test compilation failure of ${builtin} with bad arguments`) + .params(u => u.combine('arg', keysOf(kBadArgs))) + .fn(t => { + t.expectCompileResult(false, `const c = ${builtin}${kBadArgs[t.params.arg]};`); + }); + +g.test('must_use') + .desc(`Result of ${builtin} must be used`) + .fn(t => { + t.expectCompileResult(false, `fn f() { ${builtin}${kGoodArgs}; }`); + });