DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
[spirv] Invalid codegen in RWByteAddressBuffer InterlockedMin and Max
Description
When an atomic operation is done on a RWByteAddressBuffer, the operands are passed without casting to the correct type. This causes a spir-v validation error.
Steps to Reproduce https://godbolt.org/z/PodTdWEvq
RWByteAddressBuffer rwbab: register(u0);
[numthreads(4, 16, 1)]
void main(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThreadID, uint3 wg_id : SV_GroupID)
{
int k = 100;
rwbab.InterlockedMax(0, k);
return;
}
There is an error because rwbab is an array of uints in SPIR-V. The atomic operation must be done using uints for the parameters.
Actual Behavior
We get a validation error because the OpAtomicSMax instruction has incorrect types.
Environment
- DXC version trunk
- Host Operating System all
There want an attempt to fix this with https://github.com/microsoft/DirectXShaderCompiler/pull/5707, but it does not seem to be correct. Since no work has been done on the PR in a while, I opened the issues, so we can better track the bug.
Closing this as a duplicate of an earlier bug (#3196), but ack that this has now been reported several times and we should up the priority, so I'll try to take another look.