Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path test_module
3var<workgroup> atom: atomic<u32>;
5fn entry_point() -> f32 {
6 atomicStore(&atom, 1u); // atom = 1
7 var y = atomicLoad(&atom); // y = 1, atom = 1
8 y += atomicAdd(&atom, 2u); // y = 2, atom = 3
9 y += atomicSub(&atom, 1u); // y = 5, atom = 2
10 y += atomicMax(&atom, 5u); // y = 7, atom = 5
11 y += atomicMin(&atom, 4u); // y = 12, atom = 4
12 y += atomicExchange(&atom, y); // y = 16, atom = 12
13 let exchange = atomicCompareExchangeWeak(&atom, 12u, 0u);
14 if exchange.exchanged {
15 y += exchange.old_value; // y = 28, atom = 0
16 }
18 return f32(y); // 28.0
Contents