Skip to content

Commit

Permalink
Improve 'args' and 'must_use' validation tests for several builtins
Browse files Browse the repository at this point in the history
Responds to review feedback on sin, cos tests.

Updates:
 dot4IPacked
 dot4UPacked
 flor
 pack4xI8
 pack4xI8Clamp
 pack4xU8
 pack4xU8Clamp
 unpack4xI8
 unpack4xU8
  • Loading branch information
dneto0 committed Mar 14, 2024
1 parent f1aa942 commit 420dc16
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 169 deletions.
18 changes: 9 additions & 9 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1869,19 +1869,19 @@
"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 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:bad_args:*": { "subcaseMS": 0.302 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:args:*": { "subcaseMS": 48.785 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:must_use:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:supported:*": { "subcaseMS": 1.100 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:unsupported:*": { "subcaseMS": 7.250 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:bad_args:*": { "subcaseMS": 0.401 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:args:*": { "subcaseMS": 45.347 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:must_use:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:supported:*": { "subcaseMS": 0.401 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:unsupported:*": { "subcaseMS": 3.200 },
"webgpu:shader,validation,expression,call,builtin,exp2:integer_argument:*": { "subcaseMS": 0.967 },
"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:args:*": { "subcaseMS": 4.221 },
"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 },
Expand All @@ -1898,19 +1898,19 @@
"webgpu:shader,validation,expression,call,builtin,log:values:*": { "subcaseMS": 0.291 },
"webgpu:shader,validation,expression,call,builtin,modf:integer_argument:*": { "subcaseMS": 1.089 },
"webgpu:shader,validation,expression,call,builtin,modf:values:*": { "subcaseMS": 1.866 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:bad_args:*": { "subcaseMS": 40.750 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:args:*": { "subcaseMS": 36.226 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:must_use:*": { "subcaseMS": 6.500 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:supported:*": { "subcaseMS": 113.501 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:unsupported:*": { "subcaseMS": 739.400 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:bad_args:*": { "subcaseMS": 39.240 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:args:*": { "subcaseMS": 21.994 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:must_use:*": { "subcaseMS": 34.301 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:supported:*": { "subcaseMS": 100.450 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:unsupported:*": { "subcaseMS": 751.101 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:bad_args:*": { "subcaseMS": 37.770 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:args:*": { "subcaseMS": 24.783 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:must_use:*": { "subcaseMS": 5.300 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:supported:*": { "subcaseMS": 449.800 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:unsupported:*": { "subcaseMS": 773.702 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:bad_args:*": { "subcaseMS": 124.860 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:args:*": { "subcaseMS": 26.118 },
"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 },
Expand All @@ -1934,11 +1934,11 @@
"webgpu:shader,validation,expression,call,builtin,textureSample:coords_argument:*": { "subcaseMS": 1.342 },
"webgpu:shader,validation,expression,call,builtin,textureSample:offset_argument,non_const:*": { "subcaseMS": 1.604 },
"webgpu:shader,validation,expression,call,builtin,textureSample:offset_argument:*": { "subcaseMS": 1.401 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:bad_args:*": { "subcaseMS": 121.263 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:args:*": { "subcaseMS": 23.923 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:must_use:*": { "subcaseMS": 35.200 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:supported:*": { "subcaseMS": 24.150 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:unsupported:*": { "subcaseMS": 615.301 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:bad_args:*": { "subcaseMS": 40.113 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:args:*": { "subcaseMS": 21.830 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:must_use:*": { "subcaseMS": 32.800 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:supported:*": { "subcaseMS": 98.501 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:unsupported:*": { "subcaseMS": 346.801 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'dot4I8Packed';
const kGoodArgs = '(1u,2u)';
const kBadArgs = {
'0args': '()',
'1args': '(1u)',
'3args': '(1u,2u,3u)',
'0i32': '(1i,2u)',
'0f32': '(1f,2u)',
'0bool': '(false,2u)',
'0vec2u': '(vec2u(),2u)',
'1i32': '(1u,2i)',
'1f32': '(1u,2f)',
'1bool': '(1u,true)',
'1vec2u': '(1u,vec2u())',
bool_bool: '(false,true)',
bool2_bool2: '(vec2<bool>(),vec2(false,true))',
const kArgCases = {
good: '(1u,2u)',
bad_0args: '()',
bad_1args: '(1u)',
bad_3args: '(1u,2u,3u)',
bad_0i32: '(1i,2u)',
bad_0f32: '(1f,2u)',
bad_0bool: '(false,2u)',
bad_0vec2u: '(vec2u(),2u)',
bad_1i32: '(1u,2i)',
bad_1f32: '(1u,2f)',
bad_1bool: '(1u,true)',
bad_1vec2u: '(1u,vec2u())',
bad_bool_bool: '(false,true)',
bad_bool2_bool2: '(vec2<bool>(),vec2(false,true))',
bad_0array: '(array(1))',
bad_0struct: '(modf(1.1))',
};
const kGoodArgs = kArgCases['good'];

export const g = makeTestGroup(ShaderValidationTest);

Expand All @@ -45,17 +48,19 @@ g.test('supported')
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
g.test('args')
.desc(`Test compilation failure of ${kFn} with various numbers of and types of arguments`)
.params(u => u.combine('arg', keysOf(kArgCases)))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
t.expectCompileResult(t.params.arg === 'good', `const c = ${kFn}${kArgCases[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.params(u => u.combine('use', [true, false]))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
const use_it = t.params.use ? '_ = ' : '';
t.expectCompileResult(t.params.use, `fn f() { ${use_it}${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'dot4U8Packed';
const kGoodArgs = '(1u,2u)';
const kBadArgs = {
'0args': '()',
'1args': '(1u)',
'3args': '(1u,2u,3u)',
'0i32': '(1i,2u)',
'0f32': '(1f,2u)',
'0bool': '(false,2u)',
'0vec2u': '(vec2u(),2u)',
'1i32': '(1u,2i)',
'1f32': '(1u,2f)',
'1bool': '(1u,true)',
'1vec2u': '(1u,vec2u())',
bool_bool: '(false,true)',
bool2_bool2: '(vec2<bool>(),vec2(false,true))',
const kArgCases = {
good: '(1u,2u)',
bad_0args: '()',
bad_1args: '(1u)',
bad_3args: '(1u,2u,3u)',
bad_0i32: '(1i,2u)',
bad_0f32: '(1f,2u)',
bad_0bool: '(false,2u)',
bad_0vec2u: '(vec2u(),2u)',
bad_1i32: '(1u,2i)',
bad_1f32: '(1u,2f)',
bad_1bool: '(1u,true)',
bad_1vec2u: '(1u,vec2u())',
bad_bool_bool: '(false,true)',
bad_bool2_bool2: '(vec2<bool>(),vec2(false,true))',
bad_0array: '(array(1))',
bad_0struct: '(modf(1.1))',
};
const kGoodArgs = kArgCases['good'];

export const g = makeTestGroup(ShaderValidationTest);

Expand All @@ -45,17 +48,19 @@ g.test('supported')
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
g.test('args')
.desc(`Test compilation failure of ${kFn} with various numbers of and types of arguments`)
.params(u => u.combine('arg', keysOf(kArgCases)))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
t.expectCompileResult(t.params.arg === 'good', `const c = ${kFn}${kArgCases[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.params(u => u.combine('use', [true, false]))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
const use_it = t.params.use ? '_ = ' : '';
t.expectCompileResult(t.params.use, `fn f() { ${use_it}${kFn}${kGoodArgs}; }`);
});
40 changes: 22 additions & 18 deletions src/webgpu/shader/validation/expression/call/builtin/floor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,35 @@ Validates that scalar and vector integer arguments are rejected by ${builtin}()
);
});

const kGoodArgs = '(1.1)';
const kBadArgs = {
no_parens: '',
const kArgCases = {
good: '(1.1)',
bad_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))',
bad_0args: '()',
bad_2args: '(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('bad_args')
.desc(`Test compilation failure of ${builtin} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
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(false, `const c = ${builtin}${kBadArgs[t.params.arg]};`);
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 => {
t.expectCompileResult(false, `fn f() { ${builtin}${kGoodArgs}; }`);
const use_it = t.params.use ? '_ = ' : '';
t.expectCompileResult(t.params.use, `fn f() { ${use_it}${builtin}${kArgCases['good']}; }`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'pack4xI8';
const kGoodArgs = '(vec4i())';
const kBadArgs = {
'0args': '()',
'2args': '(vec4i(),vec4i())',
'0i32': '(1i)',
'0f32': '(1f)',
'0bool': '(false)',
'0vec4u': '(vec4u())',
'0vec4f': '(vec4f())',
'0vec4b': '(vec4<bool>())',
'0vec2i': '(vec2i())',
'0vec3i': '(vec3i())',
const kArgCases = {
good: '(vec4i())',
bad_0args: '()',
bad_2args: '(vec4i(),vec4i())',
bad_0i32: '(1i)',
bad_0f32: '(1f)',
bad_0bool: '(false)',
bad_0vec4u: '(vec4u())',
bad_0vec4f: '(vec4f())',
bad_0vec4b: '(vec4<bool>())',
bad_0vec2i: '(vec2i())',
bad_0vec3i: '(vec3i())',
bad_0array: '(array(1))',
bad_0struct: '(modf(1.1))',
};
const kGoodArgs = kArgCases['good'];

export const g = makeTestGroup(ShaderValidationTest);

Expand All @@ -42,17 +45,18 @@ g.test('supported')
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
g.test('args')
.desc(`Test compilation failure of ${kFn} with various numbers of and types of arguments`)
.params(u => u.combine('arg', keysOf(kArgCases)))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
t.expectCompileResult(t.params.arg === 'good', `const c = ${kFn}${kArgCases[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.params(u => u.combine('use', [true, false]))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
const use_it = t.params.use ? '_ = ' : '';
t.expectCompileResult(t.params.use, `fn f() { ${use_it}${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'pack4xI8Clamp';
const kGoodArgs = '(vec4i())';
const kBadArgs = {
'0args': '()',
'2args': '(vec4i(),vec4i())',
'0i32': '(1i)',
'0f32': '(1f)',
'0bool': '(false)',
'0vec4u': '(vec4u())',
'0vec4f': '(vec4f())',
'0vec4b': '(vec4<bool>())',
'0vec2i': '(vec2i())',
'0vec3i': '(vec3i())',
const kArgCases = {
good: '(vec4i())',
bad_0args: '()',
bad_2args: '(vec4i(),vec4i())',
bad_0i32: '(1i)',
bad_0f32: '(1f)',
bad_0bool: '(false)',
bad_0vec4u: '(vec4u())',
bad_0vec4f: '(vec4f())',
bad_0vec4b: '(vec4<bool>())',
bad_0vec2i: '(vec2i())',
bad_0vec3i: '(vec3i())',
bad_0array: '(array(1))',
bad_0struct: '(modf(1.1))',
};
const kGoodArgs = kArgCases['good'];

export const g = makeTestGroup(ShaderValidationTest);

Expand All @@ -42,17 +45,18 @@ g.test('supported')
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
g.test('args')
.desc(`Test compilation failure of ${kFn} with various numbers of and types of arguments`)
.params(u => u.combine('arg', keysOf(kArgCases)))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
t.expectCompileResult(t.params.arg === 'good', `const c = ${kFn}${kArgCases[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.params(u => u.combine('use', [true, false]))
.fn(t => {
t.skipIfLanguageFeatureNotSupported(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
const use_it = t.params.use ? '_ = ' : '';
t.expectCompileResult(t.params.use, `fn f() { ${use_it}${kFn}${kGoodArgs}; }`);
});
Loading

0 comments on commit 420dc16

Please sign in to comment.