-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[naga msl-out] Fix truncation of pulled vertices #7458
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
Conversation
| if needs_padding_or_truncation != Ordering::Equal { | ||
| writeln!( | ||
| self.out, | ||
| "{}// {attribute_ty_name} <- {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the swizzle selector tends to be buried at the end of a very long argument list, this comment helps to call out what's going on, but if it's preferred not to add anything extraneous to the generated shaders, I'd be fine removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We sometimes add these sort of comments to help debugging - it should be fine.
naga/src/back/msl/writer.rs
Outdated
|
|
||
| // Check dimensionality of the attribute compared to the unpacking | ||
| // function. If attribute dimension is < unpack dimension, then | ||
| // we need to explicitly cast down the result. Otherwise, if attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc is now out of date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated.
teoxoy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
The vertex pulling transform transforms vertex shaders:
It is possible for the vertices to require truncation upon loading. For example, the vertex buffer could define the texture coordinate as a
vec3, but the vertex shader might not care about the z value and load the texture coordinate as avec2. Before this change, the generated code would do this by casting, which seems to be allowed fromfloat4tofloat3, but not fromfloat3tofloat2. This PR changes the truncation to use a swizzle selector to select the appropriate number of components.Fixes #7410
Testing
Adds more snapshot tests for the vertex pulling transform. I also tested that this fix does resolve the issue seen on the website linked from the original bugzilla issue.
Review note: there are four new snapshot tests, with suffixes
-x1through-x4, for loading vertices into a scalar,vec2,vec3, orvec4. The TOML files for all four are identical since they are describing the source vertex formats. The WGSL files are the same except for the type of variable that the vertex is loaded to.Squash or Rebase? Squash
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.