DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
[SPIR-V] ByteAddressBuffer can not get row-major matrix
Compile this example with "-Zpr" which enable row-major matrix:
ByteAddressBuffer byte_buffer;
void foo() {
float4x4 matrix = byte_buffer.Load<float4x4>(id);
}
variable "matrix" is not treated as row-major matrix.
To make this more concrete: https://godbolt.org/z/1Pn3Kf1jM.
ByteAddressBuffer byte_buffer;
RWBuffer<float> b;
void main() {
float4x4 matrix = byte_buffer.Load<float4x4>(2);
b[0] = matrix[2][3];
}
The access to the matrix could come from the byte_buffer as offset 11, that is (2 * 4 + 3). However, we generate:
%18 = OpAccessChain %_ptr_Uniform_uint %byte_buffer %uint_0 %uint_14
%19 = OpLoad %uint %18
%20 = OpBitcast %float %19
We are getting 14, which is (3*4+2).