-
Notifications
You must be signed in to change notification settings - Fork 718
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
[SPIR-V] Matrices in constant buffers are unnecessarily padded when using DirectX memory layout #3463
Comments
We are considering this as one of important issues. We are working on it, but it would take a few weeks because it is not a trivial issue. I will get back to you when we have some clear progress about this issue. |
#3672 fixes this issue. @Dredhog Could you please check your shader with the top-of-tree? Note that for
in the shader should generate the following memory layout with
Based on the SPIR-V semantics, spirv-val reports |
Since we checked it is working fine, let me close this issue. Please let us know if you find any issues. |
Sorry, @jaebaek, completely forgot about this over the weekend. The shader I posted was an artificial example, we did not yet encounter this in a real shader (as far as I know). I guess there's no extra rush since it's already merged, I'll report any new issues I find once we update our version of DXC |
Thanks! |
Title
[SPIR-V] Matrices in constant buffers are unnecessarily padded when using DirectX memory layout
Functional impact
Certain constant buffers which contain matrices are not compatible with DirectX when using the
-fvk-use-dx-layout
argument. This is because-fvk-use-dx-layout
does not account for the fact that with DX layout constants are supposed to be placed immediately after the end of matrices if the constants are small enough to fit into the remaining part of the 16B block (i.e. into CBuffer memory regions that would normally be reserved for matrix padding with the default Vk CBuffer layout)Minimal repro steps
dxc.exe -T ps_6_0 -E PSMain -fvk-use-dx-layout -spirv issue_shader.txt
:Expected result
padding_0
should be placed at offset of44
;padding_1
should be placed at offset40
;padding_2
should be placed at offset28
;as they would be when compiling for the DXIL backend
dxc.exe -T ps_6_0 -E PSMain issue_shader.txt
:Actual result
Offsets of CB members following matrices are aligned to offsets at the next multiple of 16B i.e.
padding_0
is placed at offset48
;padding_1
is placed at offset48
;padding_2
is placed at offset32
;Further technical details
Ran this on shader playground with DXC from 2020 12 16
The text was updated successfully, but these errors were encountered: