Closed halli2 closed 1 year ago
Your example does not compile, lowercase registers
and Registers
should be swapped in the layout(push_constants) uniform <type> { ... } <identifier>;
declaration.
Root-caused to: https://github.com/Traverse-Research/rspirv-reflect/blob/8894d3570cd738c61e26b08349f55277092b9e3c/src/lib.rs#L602
Turns out we were treating any unknown type as zero-sized, when we should obviously panic on encountering something unknown (so that it can be reported and implemented). In your case it was OpTypePointer
, which I hardcoded to 8
for now in #5.
@halli2 as it turns out this isn't a supported use-case by upstream SPIR-V Reflect either. It just "happens to work" because they round up a struct to SPIRV_DATA_ALIGNMENT
(which we don't do in this crate :sweat_smile:), but we can very easily break it. Consider the following GLSL snippet:
layout(push_constant) uniform Registers
{
uint test; // off=0, size=4
MeshBuffer mesh_buffer; // off=8, size=8?
IndexBuffer index_buffer; // off=16, size=8?
}
registers;
This bit of code:
Simply finds the offset of index_buffer
at 16
, doesn't know a size, and finally rounds up to a multiple of 16 and returns a push-constant size of 16 instead of 24 :)
If you don't mind I'd like to ask about this on the SPIRV-Reflect repo before merging #5 and releasing it :)
Using push constant for buffer references gives wrong push constant range size.
Glsl shader:
Should give size of 16, but reflection gives size of 8.