atomicCompareExchangeWeak
On this page

atomicCompareExchangeWeak

Function

Stores the third argument into the atomic location only when it holds the second, as one indivisible step.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function atomicCompareExchangeWeak<T extends u32 | i32>(location: atomic<T>, compare: T, value: T): { old_value: T; exchanged: bool }

Parameters

  • location atomic<T>
  • compare T
  • value T

Return value

{ old_value: T; exchanged: bool }

Description

Answers a struct: old_value is what the location held before the call and exchanged says whether the store happened. WGSL gives that struct no writable name, so bind the result with const and read its fields.

Targets

WGSL
atomicCompareExchangeWeak(&a, b, c)
GLSL ES 3.00
atomicCompareExchangeWeak has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

Examples

See also

Edit this page Report a problem