-
Notifications
You must be signed in to change notification settings - Fork 195
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
[msl-out] Generated metal uses packed_float3 in an expression #1561
Comments
I'm not sure when this got fixed but it's no longer an issue as can be seen here: a335188 |
Given the example at the top (fixed for the struct semicolon change), with naga master as of a3d968e $ cargo run naga -- test.wgsl test.metal
$ xcrun metal test.metal still yields exactly the same error, the struct field is of a packed type, but it is used in an expression that expects non-packed. I believe in the example you gave, it is merely doing an assignment with the field, which I suppose is fine, but the arithmetic is not. In fact in the example above, assigning the field to a local variable first is a valid workaround. But thanks for looking in to it! |
Ah, I see what's going on. The test I added takes advantage of baking the load expression. Lines 139 to 142 in a3d968e
However the issue with the example shared in this issue is that the load happens when the struct Test {
v: vec3<f32>,
s: u32,
};
var<private> global: Test;
fn foo() {
let data = global; // <- if you change this to a `var` you can see it will work (since the load will happen later)
let foo = mat3x3<f32>() * data.v;
} I'll mark the PR as a draft and see if there is a better solution tomorrow. |
With this wgsl
the converted struct ends up as
and the expression uses it directly
But I believe it should be cast first, like
float3(data.inv_squared_scale)
A workaround can be to not have something with align(4) (like the u32 here) next to vec3. Just moving the u32 to first member works, or having some vec4 or mat4x4 in between also works. Then it won't be generated as packed_float3.
Originally found with rend3 trunk version of
opaque.vert.cpu.wgsl
, cc @cwfitzgeraldThe text was updated successfully, but these errors were encountered: