GpuAtomic¶
Import: import system.gpu;
This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation. Shader-only declarations can be used only inside shader entry points and helpers reached from them; using them elsewhere is a compile error.
GpuAtomic¶
Atomic read-modify-write operations on buffer elements, safe when many threads update the same element at once. Each returns the element's value from before the operation. Integer forms work on GpuBuffer<int> and GpuBuffer<uint>; add_float on GpuBuffer<float>.
add¶
Adds value to element index.
add_float¶
Adds value to the float element index. WebGPU has no float atomics, so there it is emulated with a compare-and-swap loop.
sub¶
Subtracts value from element index.
min¶
Stores the smaller of element index and value.
max¶
Stores the larger of element index and value.
and¶
Stores the bitwise AND of element index and value.
or¶
Stores the bitwise OR of element index and value.
xor¶
Stores the bitwise exclusive OR of element index and value.
exchange¶
Stores value in element index.
compare_exchange¶
Stores value in element index only if the element equals expected.