InterlockedCompareExchange
Description
Perform an atomic compare and exchange operation on dest.
Signature
void InterlockedCompareExchange<T>( T dest, T compare_value, T value, out T original_value) where T : IAtomicable;
Generic Parameters
T: IAtomicable
The type of the value to perform the atomic operation on.
Parameters
dest : T
The value to perform the atomic operation on.
compare_value : T
The value to compare dest with.
value : T
The value to store into dest if the compare result is equal.
original_value : T
The value of dest before the operation.
Remarks
When targeting HLSL, a call to this function with T being float will translate to a call to InterlockedCompareExchangeFloatBitwise, which means the comparison is done as a bitwise comparison.
On SPIR-V (Vulkan), this function maps to OpAtomicCompareExchange.
On Metal and WGSL, all floating-point types are not supported.
On CUDA, this function maps to atomicCAS.
Availability and Requirements
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cuda
Available in all stages.
metal
Available in all stages.
spirv
Available in all stages.