-
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
spv-out: Decorate integer builtins as Flat in the spirv writer #2035
Conversation
It does not fix the |
src/back/spv/writer.rs
Outdated
let is_flat = match built_in { | ||
Bi::Position { .. } => false, | ||
_ => true, | ||
}; |
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 actual rule from the Vulkan spec is:
- VUID-StandaloneSpirv-Flat-04744
Any variable with integer or double-precision floating-point type and with Input storage class in a fragment shader, must be decorated Flat
It's true that spirv-val
doesn't complain about (say):
@fragment
fn fs_main(@location(0) index: u32) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
but since the background story is that these validations are just being implemented piecemeal as somebody's interest leads them, I think we should assume the above might well stop passing validation at some point in the future.
Anyway, that is too many words to say: Let's implement the rule as expressed in the Vulkan spec and attach Decoration::Flat
to everything whose type is Sint
, Uint
, or 64-bit Float
.
547c2cc
to
6ab06fd
Compare
6ab06fd
to
390fcd9
Compare
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.
Looks fantastic. Two small changes, but then this can land.
390fcd9
to
fb3d626
Compare
(I made the minor changes I requested.) |
The Vulkan decoration rules require us to distinguish vertex shader inputs, fragment shader inputs, and everything else, so just pass the stage to `Writer::write_varying`. Together with the SPIRV storage class, this is sufficient to distinguish all the cases in a way that closely follows the spec language.
The Vulkan decoration rules require us to distinguish vertex shader inputs, fragment shader inputs, and everything else, so just pass the stage to `Writer::write_varying`. Together with the SPIRV storage class, this is sufficient to distinguish all the cases in a way that closely follows the spec language.
The Vulkan decoration rules require us to distinguish vertex shader inputs, fragment shader inputs, and everything else, so just pass the stage to `Writer::write_varying`. Together with the SPIRV storage class, this is sufficient to distinguish all the cases in a way that closely follows the spec language.
Fixes #2032
Take what I write in this PR with a whole handful off salt, I'm new enough to naga and spirv that there's a decent chance I am jumping to conclusions.
See the investigation in #2032. My uneducated guess is that spirv wants the integer input builtins such as
primitive_index
to have the flat decoration. So I added that in fairly naive way.This PR fixes the
primitive_index.wgsl
test case and doesn't appear to cause regressions as far ascargo test --all
can tell.