mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-04 03:05:42 +00:00
Storage buffers are emitted as `ByteAddressBuffer`s in HLSL, so we have to jump through hoops to support atomic ops on storage buffer atomics. Workgroup atomics are far more conventional, but very little code can be shared between these two code paths. Bug: tint:892 Change-Id: If10ea866e3b67a093e87aca689d34065fd49b705 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54651 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
21 lines
502 B
HLSL
21 lines
502 B
HLSL
RWByteAddressBuffer sb_rw : register(u0, space0);
|
|
|
|
void atomicCompareExchangeWeak_12871c() {
|
|
int2 atomic_result = int2(0, 0);
|
|
int atomic_compare_value = 1;
|
|
sb_rw.InterlockedCompareExchange(0u, atomic_compare_value, 1, atomic_result.x);
|
|
atomic_result.y = atomic_result.x == atomic_compare_value;
|
|
int2 res = atomic_result;
|
|
}
|
|
|
|
void fragment_main() {
|
|
atomicCompareExchangeWeak_12871c();
|
|
return;
|
|
}
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void compute_main() {
|
|
atomicCompareExchangeWeak_12871c();
|
|
return;
|
|
}
|