Skip to content

Commit

Permalink
Address feedback from @dneto
Browse files Browse the repository at this point in the history
  • Loading branch information
toji committed Mar 14, 2024
1 parent a3de10e commit 7e9fdbb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
2 changes: 2 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1904,9 +1904,11 @@
"webgpu:shader,validation,expression,call,builtin,log2:values:*": { "subcaseMS": 0.398 },
"webgpu:shader,validation,expression,call,builtin,log:integer_argument:*": { "subcaseMS": 1.134 },
"webgpu:shader,validation,expression,call,builtin,log:values:*": { "subcaseMS": 0.291 },
"webgpu:shader,validation,expression,call,builtin,max:args:*": { "subcaseMS": 77.529 },
"webgpu:shader,validation,expression,call,builtin,max:bad_args:*": { "subcaseMS": 79.423 },
"webgpu:shader,validation,expression,call,builtin,max:must_use:*": { "subcaseMS": 8.286 },
"webgpu:shader,validation,expression,call,builtin,max:values:*": { "subcaseMS": 260241.074 },
"webgpu:shader,validation,expression,call,builtin,min:args:*": { "subcaseMS": 67.260 },
"webgpu:shader,validation,expression,call,builtin,min:bad_args:*": { "subcaseMS": 40.137 },
"webgpu:shader,validation,expression,call,builtin,min:must_use:*": { "subcaseMS": 3.899 },
"webgpu:shader,validation,expression,call,builtin,min:values:*": { "subcaseMS": 246733.594 },
Expand Down
40 changes: 23 additions & 17 deletions src/webgpu/shader/validation/expression/call/builtin/max.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,37 @@ Validates that constant evaluation and override evaluation of ${builtin}() never
);
});

const kGoodArgs = '(1.1, 2.2)';
const kBadArgs = {
no_parens: '',
const kArgCases = {
'good': '(1.1, 2.2)',
bad_no_parens: '',
// Bad number of args
'0args': '()',
'1arg': '(1.0)',
'bad_0args': '()',
'bad_1arg': '(1.0)',
'bad_3arg': '(1.0, 2.0, 3.0)',
// Bad value for arg 0
'0bool': '(false, 1.0)',
'0array': '(array(1.1,2.2), 1.0)',
'0struct': '(modf(2.2), 1.0)',
// Bad value for arg 1
'1bool': '(1.0, true)',
'1array': '(1.0, array(1.1,2.2))',
'1struct': '(1.0, modf(2.2))',
'bad_0bool': '(false, 1.0)',
'bad_0array': '(array(1.1,2.2), 1.0)',
'bad_0struct': '(modf(2.2), 1.0)',
// Bad value type for arg 1
'bad_1bool': '(1.0, true)',
'bad_1array': '(1.0, array(1.1,2.2))',
'bad_1struct': '(1.0, 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']}; }`);
});
40 changes: 23 additions & 17 deletions src/webgpu/shader/validation/expression/call/builtin/min.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,37 @@ Validates that constant evaluation and override evaluation of ${builtin}() never
);
});

const kGoodArgs = '(1.1, 2.2)';
const kBadArgs = {
no_parens: '',
const kArgCases = {
'good': '(1.1, 2.2)',
bad_no_parens: '',
// Bad number of args
'0args': '()',
'1arg': '(1.0)',
'bad_0args': '()',
'bad_1arg': '(1.0)',
'bad_3arg': '(1.0, 2.0, 3.0)',
// Bad value for arg 0
'0bool': '(false, 1.0)',
'0array': '(array(1.1,2.2), 1.0)',
'0struct': '(modf(2.2), 1.0)',
// Bad value for arg 1
'1bool': '(1.0, true)',
'1array': '(1.0, array(1.1,2.2))',
'1struct': '(1.0, modf(2.2))',
'bad_0bool': '(false, 1.0)',
'bad_0array': '(array(1.1,2.2), 1.0)',
'bad_0struct': '(modf(2.2), 1.0)',
// Bad value type for arg 1
'bad_1bool': '(1.0, true)',
'bad_1array': '(1.0, array(1.1,2.2))',
'bad_1struct': '(1.0, 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']}; }`);
});

0 comments on commit 7e9fdbb

Please sign in to comment.