InterlockedExchange

Description

Perform an atomic exchange operation on dest.

Signature

void InterlockedExchange<T>(
    T dest,
    T value)
    where T : IAtomicable;

void InterlockedExchange<T>(
    T dest,
    T value,
    out T original_value)
    where T : IAtomicable;

void InterlockedExchange(
    uint dest,
    int value);

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.

value : T

The operand to the atomic operation.

original_value : T

The value of dest before the operation.

dest : uint

The value to perform the atomic operation on.

value : int

The operand to the atomic operation.

Remarks

When targeting HLSL, it is invalid to call this function with T being a floating-point type, since HLSL does not allow atomic operations on floating point types. For InterlockedAdd, consider using RWByteAddressBuffer.InterlockedAddF32 or RWByteAddressBuffer.InterlockedAddF16 instead when NVAPI is available. On SPIR-V (Vulkan), all integer and floating point types are supported. On Metal and WGSL, all floating-point types are not supported.

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.