-
Notifications
You must be signed in to change notification settings - Fork 722
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] ByteAddressBuffer doesn't emit RowMaj or ColMaj decorations for templated loads #3370
Comments
Looking at the generated SPIR-V, the matrix type is only used for an intermediate value. It's not used to describe the contents of a buffer. So there is no obligation to apply layout decorations to it. In fact, it should not have layout decorations. I think this is not a bug. I recommend closing. |
@dneto0 Note that the loads should probably get vectorized as per #3372, then this becomes relevant? Generated SPIR-V remains identical regardless of |
Notice that not doing this leads to subtle SPIR-V specific bugs when converting for example from a StructuredBuffer to a ByteAddressBuffer. Though this could also point to a codegen bug for the SPIRV path that just loads the matrices in the incorrect order. |
Hi, I'm actually facing the exact same issue... |
Also ran into this issue. Matrices are stored column-major in ByteAddressBuffer, but the load results in row-major.
From looking at the spirv, think the issue is: |
cc @kuhar |
Hi @Jasper-Bekkers, @gjaegy, @MarijnS95, and @jbmcgee, I looked into this issue and came up with a draft PR: #4526.
I compiled the example from the first comment to DXIL, annotating the load with both
Do you know of some documentation that states how matrices are stored in |
I checked with @chaoticbob who suggested we introduce a new flag to control the default matrix order. I updated the PR in the following way: |
Assume that matrices are stored in the column major order in raw buffers, e.g., `ByteAddressBuffer` and `RWByteAddressBuffer`. Add a new flag,`-fspv-use-legacy-buffer-matrix-order`, so that shaders that depend on the previous matrix order (row major) can opt-out of this change. Fixes: microsoft#3370
Update: I further checked with @tex3d. We will keep the behavior consistent with HLSL/DXIL and assume the matrix order in raw buffers to be column major, and provide a compatibility flag to opt-out of the change: |
Assume that matrices are stored in the column major order in raw buffers, e.g., `ByteAddressBuffer` and `RWByteAddressBuffer`. Add a new flag,`-fspv-use-legacy-buffer-matrix-order`, so that shaders that depend on the previous matrix order (row major) can opt-out of this change. Fixes: #3370
I'm not sure if this is done explicitly or not, however when converting some of our ConstantBuffer's to ByteAddressBuffers we noticed that Load doesn't OpDecorate the matrix it's loading, nor do
column_major
orrow_major
attributes get respected when used like this:.Load<column_major float4x4>(...)
.Example: http://shader-playground.timjones.io/e8c49c3276e111e220873d91c937bb2b
I'm not sure if it's intentional or not, but at least I wanted to raise the issue that it's inconsistent.
The text was updated successfully, but these errors were encountered: