atomicStore
Function
An atomic store writes one shared integer as an indivisible operation. It returns no value.
Compare examples
Compare the returned value with the stored value. Each case starts from its own initial state.
Model assumptionslocation: atomic<u32>
Example 1atomicStore(location, 3)
- Stored value before
5- Returned value
void- Stored value after
3
Example 2atomicStore(location, 1)
- Stored value before
0- Returned value
void- Stored value after
1
Example 3atomicStore(location, 1)
- Stored value before
4294967295- Returned value
void- Stored value after
1
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it for resetting a shared counter.
Inputs and limits
The model uses an unsigned integer and one serialized operation. Real invocation order is unspecified. Atomicity does not synchronize unrelated memory; these calls require WebGPU in this compiler.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Writes value to an atomic location in a read-write storage binding (atomicStore(bins[i], 0)); returns nothing.
Syntax
declare function atomicStore<T extends u32 | i32>(location: atomic<T>, value: T): voidParameters
-
locationatomic<T> -
valueT
Return value
void
Description
Compiles to atomicStore(&bins[i], v) on WGSL; the GLSL lowering in a render entry is not supported yet (Rule 10.5), and a @compute entry that reaches no texture runs on WebGL2 as its pass program (Rule 8.24, Rule 11.8).
Targets
- WGSL
-
atomicStore(&a, b) - GLSL ES 3.00
-
atomicStoreis not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a@computeentry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)