mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-03 18:55:39 +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>
20 lines
525 B
HLSL
20 lines
525 B
HLSL
uint atomicAdd_1(RWByteAddressBuffer buffer, uint offset, uint value) {
|
|
uint original_value = 0;
|
|
buffer.InterlockedAdd(offset, value, original_value);
|
|
return original_value;
|
|
}
|
|
|
|
RWByteAddressBuffer drawOut : register(u5, space0);
|
|
static uint cubeVerts = 0u;
|
|
|
|
struct tint_symbol_1 {
|
|
uint3 global_id : SV_DispatchThreadID;
|
|
};
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void computeMain(tint_symbol_1 tint_symbol) {
|
|
const uint3 global_id = tint_symbol.global_id;
|
|
const uint firstVertex = atomicAdd_1(drawOut, 0u, cubeVerts);
|
|
return;
|
|
}
|