-
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] Always give structs with runtime arrays a Block decoration #2455
Conversation
…untimeArray must be decorated with Block or BufferBlock."
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 good but I think we can now remove:
Lines 1657 to 1669 in 0491d39
// This is a global variable in the Storage address space. The only | |
// way it could have `global_needs_wrapper() == false` is if it has | |
// a runtime-sized array. In this case, we need to decorate it with | |
// Block. | |
if let crate::AddressSpace::Storage { .. } = global_variable.space { | |
let decorated_id = match ir_module.types[global_variable.ty].inner { | |
crate::TypeInner::BindingArray { base, .. } => { | |
self.get_type_id(LookupType::Handle(base)) | |
} | |
_ => inner_type_id, | |
}; | |
self.decorate(decorated_id, Decoration::Block, &[]); | |
} |
Although:
Do the validation layers not require that the struct is used by a variable in the storage address space despite it seemingly being required by the VUID?
…Array`, removes the extra block decorations
Removing the entire block decorating chunk would cause a problem, because this
as an error. Instead, I removed the extra decorating of the non- For your other comment, from what I can tell (minus
from Lines 18 to 20 in 0491d39
|
I see, that makes sense; the comment was out of date. Can you update it or remove it?
Right but what I meant is if the struct doesn't get used at all; is it fine to always decorate them with In your example in #2322, the VUID gets triggered because we are missing the |
Wait, I don't understand why the VUID gets triggered, the validation code for this VUID is inside It only checks global variables. And we already decorate structs that have a runtime array if they are used by a global variable. Can you share a WGSL shader that when ran through naga's SPV backend fails validation with the VUID? Or even better, add it as a snapshot test to the PR. |
Oh I didn't make it clear, but initially I followed your recommendation and removed the entire chunk of code you thought could be removed. When I did, it caused So instead, in the new commit I pushed a755828, I modified that chunk of code to still Should I still make another wgsl shader in snapshot if |
My main question is why does the current code in master trigger the validation error at all? The current code already writes the Maybe I'm missing something and wanted to reproduce it locally. |
Ahh I misunderstood, I see what you mean now. Yeah it does seem to only trigger when it's not used by a global variable. The bevy issue is from this bevy file mesh_view_types.wgsl, where the file doesn't use I didn't realize my code just ended up moving the I added runtime-array-in-unused-struct.wgsl to the snapshots and changed the comment of the storage binding array decorating. |
@teoxoy I found out why it doesn't matter if it's in a variable, because the error from the issues is spit out when checking the types, in The link you sent was for a different validation error when checking variables
|
Ah, I see! Thank you for tracking it down! I think we can go ahead with this PR and omit unused structs in the future if it becomes an issue that we are decorating them despite them being unused. Related: |
Fixes #2322, and so will fix bevyengine/bevy#8733 and fix webonnx/wonnx#161
I'm sure the code can be polished and expanded on to take
BufferBlock
s into account, but I just based it off of https://vulkan.lunarg.com/doc/view/1.3.246.1/windows/1.3-extensions/vkspec.html#interfaces-resources-descset, table 21. Where uniform buffers, storage buffers, and inline uniform blocks all use theBlock
decoration.