mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-13 00:26:00 +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
440 B
HLSL
23 lines
440 B
HLSL
uint atomicMin_1(RWByteAddressBuffer buffer, uint offset, uint value) {
|
|
uint original_value = 0;
|
|
buffer.InterlockedMin(offset, value, original_value);
|
|
return original_value;
|
|
}
|
|
|
|
RWByteAddressBuffer sb_rw : register(u0, space0);
|
|
|
|
void atomicMin_c67a74() {
|
|
uint res = atomicMin_1(sb_rw, 0u, 1u);
|
|
}
|
|
|
|
void fragment_main() {
|
|
atomicMin_c67a74();
|
|
return;
|
|
}
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void compute_main() {
|
|
atomicMin_c67a74();
|
|
return;
|
|
}
|