-
Notifications
You must be signed in to change notification settings - Fork 151
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
What is the push-constant size of OpTypePointer
?
#170
Comments
Hi - thanks for for the complete backstory and repro case :) Answering your questions:
|
Quick update thanks to (@s-perron): This case is not currently handled by spirv-reflect, so to answer the question you posed in #2. Yes, it can and will need to be added. |
@chaoticbob thanks! So according to https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_physical_storage_buffer.asciidoc#overview:
There's a single addressing model provided by this extension and it always uses 64-bit pointers. However, the docs don't mention Then, the user asked this question in the context of
So the size will be defined by an API extension. Though that "API extension" probably isn't very relevant since it is said to map to
In short, for |
The API extension is https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_buffer_device_address.html. It says 64-bit addresses, but does not mention the alignment, but it references https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDeviceAddress.html, which says the device address is a
I would rephrase as "Other combinations are not allowed to be in interface variable in Vulkan shader, so they are irrelevant to sprv-reflect." |
Right, Compiling: layout(push_constant) uniform Registers
{
uint foo;
MeshBuffer mesh_buffer;
IndexBuffer index_buffer;
}
registers; results in:
So I assume the alignment is 8 too.
Ensuring the |
Over at
rspirv-reflect
(Rust version ofSPIRV-Reflect
built on top ofrspirv
) we received a report about not computing the right/expected push constant size for GLSL buffer references (our version ofspvReflectEnumeratePushConstantBlocks()
andParseDescriptorBlockVariableSizes()
). For the time being I hardcoded a size of8
but now decided to confirm with SPIRV-Reflect before committing to that, given that the SPIR-V spec doesn't mention anything in this area.And as it turns out SPIRV-Reflect doesn't handle this case either. It seemed to work at first (surprisingly given there's no
SpvOpTypePointer
handling insideParseDescriptorBlockVariableSizes()
) with the provided test-case returning16
which is expected if the pointer size is8
:But soon found out that SPIRV-Reflect is using the same trick to grab the offset of the last member (
8
here) so that it only has to compute the size of the last member... and rounds that up toSPIRV_DATA_SIZE=16
(on a related note: this alignment is something we should handle inrspirv-reflect
😅):SPIRV-Reflect/spirv_reflect.c
Line 2413 in a7c7b8a
This of course falls flat on its face when the offset becomes equal to the rounding (and
p_member_var->size
remains zero), also returning a push constant size of16
for the following even though it should be24
:Effectively this unnecessarily-verbose backstory boils down to two questions:
OpTypePointer
(the shader compiler knows because it can compute the offsets)?case SpvOpTypePointer:
to SPIRV-Reflect to support this use-case?The text was updated successfully, but these errors were encountered: