InterlockedCompareStore

Description

Perform an atomic compare and store operation on dest.

Signature

void InterlockedCompareStore<T>(
    T dest,
    T compare_value,
    T 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.

Remarks

When targeting HLSL, a call to this function with T being float will translate to a call to InterlockedCompareStoreFloatBitwise, which means the comparison is done as a bitwise comparison.

On SPIR-V (Vulkan), this function maps to OpAtomicCompareExchange.

On Metal and WGSL, this function is not available.

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.