diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index b3081b5763dd..95851c200be1 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -1807,6 +1807,7 @@ "webgpu:shader,validation,expression,binary,bitwise_shift:shift_left_vec_size_mismatch:*": { "subcaseMS": 1.367 }, "webgpu:shader,validation,expression,binary,bitwise_shift:shift_right_concrete:*": { "subcaseMS": 1.237 }, "webgpu:shader,validation,expression,binary,bitwise_shift:shift_right_vec_size_mismatch:*": { "subcaseMS": 1.334 }, + "webgpu:shader,validation,expression,call,builtin,abs:parameters:*": { "subcaseMS": 10.133 }, "webgpu:shader,validation,expression,call,builtin,abs:values:*": { "subcaseMS": 0.391 }, "webgpu:shader,validation,expression,call,builtin,acos:integer_argument:*": { "subcaseMS": 1.512 }, "webgpu:shader,validation,expression,call,builtin,acos:values:*": { "subcaseMS": 0.342 }, diff --git a/src/webgpu/shader/validation/expression/call/builtin/abs.spec.ts b/src/webgpu/shader/validation/expression/call/builtin/abs.spec.ts index f09b47264f33..b51fc02ade0d 100644 --- a/src/webgpu/shader/validation/expression/call/builtin/abs.spec.ts +++ b/src/webgpu/shader/validation/expression/call/builtin/abs.spec.ts @@ -56,3 +56,107 @@ Validates that constant evaluation and override evaluation of ${builtin}() never t.params.stage ); }); + +const kTests = { + valid: { + src: `_ = abs(1);`, + pass: true, + }, + alias: { + src: `_ = abs(i32_alias(1));`, + pass: true, + }, + + bool: { + src: `_ = abs(false);`, + pass: false, + }, + vec_bool: { + src: `_ = abs(vec2(false, true));`, + pass: false, + }, + matrix: { + src: `_ = abs(mat2x2(1, 1, 1, 1));`, + pass: false, + }, + atomic: { + src: ` _ = abs(a);`, + pass: false, + }, + array: { + src: `var a: array; + _ = abs(a);`, + pass: false, + }, + array_runtime: { + src: `_ = abs(k.arry);`, + pass: false, + }, + struct: { + src: `var a: A; + _ = abs(a);`, + pass: false, + }, + enumerant: { + src: `_ = abs(read_write);`, + pass: false, + }, + ptr: { + src: `var a = 1u; + let p: ptr = &a; + _ = abs(p);`, + pass: false, + }, + ptr_deref: { + src: `var a = 1u; + let p: ptr = &a; + _ = abs(*p);`, + pass: true, + }, + sampler: { + src: `_ = abs(s);`, + pass: false, + }, + texture: { + src: `_ = abs(t);`, + pass: false, + }, + no_params: { + src: `_ = abs();`, + pass: false, + }, + too_many_params: { + src: `_ = abs(1, 2);`, + pass: false, + }, +}; + +g.test('parameters') + .desc(`Test that ${builtin} is validated correctly.`) + .params(u => u.combine('test', keysOf(kTests))) + .fn(t => { + const src = kTests[t.params.test].src; + const code = ` +alias i32_alias = i32; + +@group(0) @binding(0) var s: sampler; +@group(0) @binding(1) var t: texture_2d; + +var a: atomic; + +struct A { + i: u32, +} +struct B { + arry: array, +} +@group(0) @binding(3) var k: B; + + +@vertex +fn main() -> @builtin(position) vec4 { + ${src} + return vec4(.4, .2, .3, .1); +}`; + t.expectCompileResult(kTests[t.params.test].pass, code); + });