mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-13 08:36:08 +00:00
By generating a helper function for these, we can keep the atomic expression pre-statement-free. This can help prevent for-loops from being transformed into while loops, which can upset FXC. We can't do the same for workgroup storage atomics, as the InterlockedXXX() methods have the workgroup-storage expression as the first argument, and I'm not aware of any way to make a user-declared parameter be `groupshared`. Change-Id: I8669127a58dc9cae95ce316523029064b5c9b5fa Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57462 Commit-Queue: James Price <jrprice@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
23 lines
435 B
HLSL
23 lines
435 B
HLSL
int atomicXor_1(RWByteAddressBuffer buffer, uint offset, int value) {
|
|
int original_value = 0;
|
|
buffer.InterlockedXor(offset, value, original_value);
|
|
return original_value;
|
|
}
|
|
|
|
RWByteAddressBuffer sb_rw : register(u0, space0);
|
|
|
|
void atomicXor_c1b78c() {
|
|
int res = atomicXor_1(sb_rw, 0u, 1);
|
|
}
|
|
|
|
void fragment_main() {
|
|
atomicXor_c1b78c();
|
|
return;
|
|
}
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void compute_main() {
|
|
atomicXor_c1b78c();
|
|
return;
|
|
}
|