You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SPIRV] ByteAddressBuffer templated load generates incorrect spirv when not using dx-layout/scalar-layout #5122
Due to the lack of scalar block support on low-end devices, we have to use the std430 layout for storage buffers. Rather than converting all structures to follow the std430 layout and increase memory usage, we decided to utilize the templated load functionality of raw buffers.
But the generated spirv is inconsistent. The following code explains the issue
uint _28 = (gl_GlobalInvocationID.x * 24u) >> 2u;
This is correct as sizeof(Bounds) is indeed 24 _40 = _28 + 4;
This is the problem as it assumes 1 uint implicit padding between Bounds::pos and Bounds::scale even when sizeof(Bounds) = 24. This breaks the consistency as sizeof treats Bounds as arbitrary blob of data (correct behavior) while the templated load treats it as std430 layout
It looks like our implementation of std430 here does match the behavior of glslang, so we'll consider the padding correct in practice as modifying it (even if it would technically follow the spec) would break longstanding assumptions and backwards compatibility. Ideally, we would like to create consistency with a change to sizeof, but due to the way it's implemented here it's not feasible to fix without major changes to introduce the additional context that would be needed to calculate it correctly.
Unfortunately due to those inherent design issues I don't think we can offer a solution, so I'm going to close this issue.
Activity
[SPIR-V] Fix default layout behavior
sudonatalie commentedon Jul 27, 2023
It looks like our implementation of std430 here does match the behavior of glslang, so we'll consider the padding correct in practice as modifying it (even if it would technically follow the spec) would break longstanding assumptions and backwards compatibility. Ideally, we would like to create consistency with a change to
sizeof, but due to the way it's implemented here it's not feasible to fix without major changes to introduce the additional context that would be needed to calculate it correctly.Unfortunately due to those inherent design issues I don't think we can offer a solution, so I'm going to close this issue.