Skip to content

Commit

Permalink
wgsl: Test mixing stage attributes on the same function (#3341)
Browse files Browse the repository at this point in the history
Add to the existing tests for parsing stage attributes @compute,
@Fragment, @vertex
  • Loading branch information
dneto0 authored Jan 29, 2024
1 parent bc32dbc commit eeb30fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,9 +1924,9 @@
"webgpu:shader,validation,parse,must_use:declaration:*": { "subcaseMS": 1.523 },
"webgpu:shader,validation,parse,must_use:ignore_result_of_non_must_use_that_returns_call_of_must_use:*": { "subcaseMS": 0.0 },
"webgpu:shader,validation,parse,pipeline_stage:compute_parsing:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,parse,pipeline_stage:duplicate_compute_on_function:*": { "subcaseMS": 2.651 },
"webgpu:shader,validation,parse,pipeline_stage:duplicate_fragment_on_function:*": { "subcaseMS": 1.001 },
"webgpu:shader,validation,parse,pipeline_stage:duplicate_vertex_on_function:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,parse,pipeline_stage:extra_on_compute_function:*": { "subcaseMS": 2.651 },
"webgpu:shader,validation,parse,pipeline_stage:extra_on_fragment_function:*": { "subcaseMS": 1.001 },
"webgpu:shader,validation,parse,pipeline_stage:extra_on_vertex_function:*": { "subcaseMS": 1.000 },
"webgpu:shader,validation,parse,pipeline_stage:fragment_parsing:*": { "subcaseMS": 2.600 },
"webgpu:shader,validation,parse,pipeline_stage:multiple_entry_points:*": { "subcaseMS": 1.100 },
"webgpu:shader,validation,parse,pipeline_stage:placement:*": { "subcaseMS": 1.388 },
Expand Down
42 changes: 27 additions & 15 deletions src/webgpu/shader/validation/parse/pipeline_stage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,46 @@ g.test('multiple_entry_points')
t.expectCompileResult(true, code);
});

g.test('duplicate_compute_on_function')
.desc(`Test that duplcate @compute attributes are not allowed.`)
.params(u => u.combine('dupe', ['', '@compute']))
g.test('extra_on_compute_function')
.desc(`Test that an extra stage attribute on @compute functions are not allowed.`)
.params(u =>
u.combine('extra', ['', '@compute', '@fragment', '@vertex']).combine('before', [false, true])
)
.fn(t => {
const before = t.params.before ? t.params.extra : '';
const after = t.params.before ? '' : t.params.extra;
const code = `
@compute ${t.params.dupe} @workgroup_size(1) fn compute_1() {}
${before} @compute ${after} @workgroup_size(1) fn main() {}
`;
t.expectCompileResult(t.params.dupe === '', code);
t.expectCompileResult(t.params.extra === '', code);
});

g.test('duplicate_fragment_on_function')
.desc(`Test that duplcate @fragment attributes are not allowed.`)
.params(u => u.combine('dupe', ['', '@fragment']))
g.test('extra_on_fragment_function')
.desc(`Test that an extra stage attribute on @fragment functions are not allowed.`)
.params(u =>
u.combine('extra', ['', '@compute', '@fragment', '@vertex']).combine('before', [false, true])
)
.fn(t => {
const before = t.params.before ? t.params.extra : '';
const after = t.params.before ? '' : t.params.extra;
const code = `
@fragment ${t.params.dupe} fn vtx() -> @location(0) vec4f { return vec4f(1); }
${before} @fragment ${after} fn main() -> @location(0) vec4f { return vec4f(1); }
`;
t.expectCompileResult(t.params.dupe === '', code);
t.expectCompileResult(t.params.extra === '', code);
});

g.test('duplicate_vertex_on_function')
.desc(`Test that duplcate @vertex attributes are not allowed.`)
.params(u => u.combine('dupe', ['', '@vertex']))
g.test('extra_on_vertex_function')
.desc(`Test that an extra stage attribute on @vertex functions are not allowed.`)
.params(u =>
u.combine('extra', ['', '@compute', '@fragment', '@vertex']).combine('before', [false, true])
)
.fn(t => {
const before = t.params.before ? t.params.extra : '';
const after = t.params.before ? '' : t.params.extra;
const code = `
@vertex ${t.params.dupe} fn vtx() -> @builtin(position) vec4f { return vec4f(1); }
${before} @vertex ${after} fn main() -> @builtin(position) vec4f { return vec4f(1); }
`;
t.expectCompileResult(t.params.dupe === '', code);
t.expectCompileResult(t.params.extra === '', code);
});

g.test('placement')
Expand Down

0 comments on commit eeb30fb

Please sign in to comment.