CAS_RESULT_STRUCTS
Constant in Types
The struct atomicCompareExchangeWeak answers: the contents the location held before the call, and whether the exchange happened.
import { CAS_RESULT_STRUCTS } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const CAS_RESULT_STRUCTS: readonly { readonly name: string; readonly fields: readonly { readonly name: string; readonly type: ShaderType; }[]; }[]Description
WGSL calls the type
__atomic_compare_exchange_result<T> and gives no way to write that name — measured on
Tint, a variable declared with it is “invalid type for variable declaration” — so the
result is bound by inference and its fields read.
It is a struct the IR types and no backend declares: WGSL’s is built in, so emitting a
struct for it would shadow the builtin one, and the emitted code never names the type
(let r = atomicCompareExchangeWeak(&x, a, b); infers it). That is why these two decls are
constants here rather than entries in a module’s structs.
Source
src/core/ir/types.ts, line 151, at commit 26de7be8