wgpu
wgpu copied to clipboard
Naga emits wrong HLSL for atomicMax() on u64 buffer
Description
Naga should be emitting buffer.InterlockedMax64, not buffer.InterlockedMax.
This only applies to RWByteAddressBuffer according to the spec.
This issue also applies to the other atomic functions.
Repro steps
@group(0) @binding(0) var<storage, read_write> buf: atomic<u64>;
atomicMax(&buf, 3147483647lu);
Platform
Naga rev 82210e1c
Changing https://github.com/gfx-rs/wgpu/blob/92c8cf415c6c0d6dc9a89f60e36c4dc0bcb5a4b5/naga/src/back/hlsl/writer.rs#L1958 To
let width = match func_ctx.resolve_type(value, &module.types) {
TypeInner::Scalar(Scalar { width: 8, .. }) => "64",
_ => "",
};
write!(self.out, "{var_name}.Interlocked{fun_str}{width}(")?;
I think fixes it. Probably needs a test, and consideration for how it will work for texture atomics.