Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fixes for alignment validation landing #4016

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/webgpu/shader/validation/shader_io/align.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const kTests = {
},
one: {
src: '@align(1)',
pass: true,
pass: false,
// EXCEPTION: Error: Unexpected validation error occurred:
// Error while parsing WGSL: :6:10 error: alignment must be a
// multiple of '4' bytes for the 'uniform' address space @align(1) a: i32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, no this is wrong.

The real check is whether the offset if incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our discussion it sounds like this change is correct.
Shall i remove the extraneous comment in the source

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, after a bunch of discussion, we agreed to change Tint to be more in line with Naga and WebKit.

crbug.com/379760170 is the Tint change.

But also clarify the spec: gpuweb/gpuweb#4978

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Given the proposed spec change, additional tests will be needed. For followup.

},
four_a: {
src: '@align(4)',
Expand Down Expand Up @@ -45,6 +48,14 @@ const kTests = {
},
const_expr: {
src: '@align(i_val + 4 - 6)',
pass: false,
// EXCEPTION: Error: Unexpected validation error occurred:
dneto0 marked this conversation as resolved.
Show resolved Hide resolved
// Error while parsing WGSL: :6:10 error: alignment must be a
// multiple of '4' bytes for the 'uniform' address space
// @align(i_val + 4 - 6) a: i32
},
const_expr_2: {
src: '@align(i_val + 8 - 4)',
dneto0 marked this conversation as resolved.
Show resolved Hide resolved
pass: true,
},
large: {
Expand Down Expand Up @@ -185,7 +196,7 @@ g.test('required_alignment')
{ name: 'mat3x4<f16>', storage: 8, uniform: 8 },
{ name: 'mat4x4<f16>', storage: 8, uniform: 8 },
{ name: 'array<vec2<i32>, 2>', storage: 8, uniform: 16 },
{ name: 'array<vec4<i32>, 2>', storage: 8, uniform: 16 },
{ name: 'array<vec4<i32>, 2>', storage: 16, uniform: 16 },
dneto0 marked this conversation as resolved.
Show resolved Hide resolved
{ name: 'S', storage: 8, uniform: 16 },
])
.beginSubcases()
Expand Down Expand Up @@ -218,15 +229,12 @@ g.test('required_alignment')
`;
}

let align = t.params.align;
if (t.params.align === 'alignment') {
// Alignment value listed in the spec
if (t.params.address_space === 'storage') {
align = `${t.params.type.storage}`;
} else {
align = `${t.params.type.uniform}`;
}
}
// Alignment value listed in the spec
const min_align =
t.params.address_space === 'storage'
? `${t.params.type.storage}`
: `${t.params.type.uniform}`;
const align = t.params.align === 'alignment' ? min_align : t.params.align;

let address_space = 'uniform';
if (t.params.address_space === 'storage') {
Expand All @@ -252,7 +260,8 @@ g.test('required_alignment')
// requires that inner vec2 to have an align 16 which can only be done by specifying `vec4`
// instead.
const fails =
t.params.address_space === 'uniform' && t.params.type.name.startsWith('array<vec2');
(t.params.address_space === 'uniform' && t.params.type.name.startsWith('array<vec2')) ||
align < min_align;

t.expectCompileResult(!fails, code);
});
Expand Down
Loading