Implement the InterlockedCompareExchange
HLSL Function
#99130
Labels
backend:DirectX
backend:SPIR-V
bot:HLSL
HLSL
HLSL Language Support
metabug
Issue to collect references to a group of similar or related issues.
InterlockedCompareExchange
clang builtin,InterlockedCompareExchange
clang builtin withhlsl_intrinsics.h
InterlockedCompareExchange
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
InterlockedCompareExchange
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/InterlockedCompareExchange.hlsl
clang/test/SemaHLSL/BuiltIns/InterlockedCompareExchange-errors.hlsl
int_dx_InterlockedCompareExchange
intrinsic inIntrinsicsDirectX.td
DXILOpMapping
ofint_dx_InterlockedCompareExchange
to160
inDXIL.td
InterlockedCompareExchange.ll
andInterlockedCompareExchange_errors.ll
tests inllvm/test/CodeGen/DirectX/
int_spv_InterlockedCompareExchange
intrinsic inIntrinsicsSPIRV.td
InterlockedCompareExchange
lowering and map it toint_spv_InterlockedCompareExchange
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/InterlockedCompareExchange.ll
DirectX
SPIR-V
OpAtomicCompareExchange:
Description:
Perform the following steps atomically with respect to any other atomic
accesses within Scope to the same location:
Comparator, and
equaled Comparator.
The instruction’s result is the Original Value.
Result Type must be an integer type scalar.
Use Equal for the memory semantics of this instruction when Value
and Original Value compare equal.
Use Unequal for the memory semantics of this instruction when Value
and Original Value compare unequal. Unequal must not be set to
Release or Acquire and Release. In addition, Unequal cannot be
set to a stronger memory-order then Equal.
The type of Value must be the same as Result Type. The type of the
value pointed to by Pointer must be the same as Result Type. This
type must also match the type of Comparator.
Memory is a memory Scope.
9
230
<id>
Result Type
Result <id>
<id>
Pointer
Scope <id>
Memory
Memory Semantics <id>
Equal
Memory Semantics <id>
Unequal
<id>
Value
<id>
Comparator
Test Case(s)
Example 1
Example 2
HLSL:
Atomically compares the destination with the comparison value. If they are identical, the destination is overwritten with the input value. The original value is set to the destination's original value.
Syntax
Parameters
dest [in]
Type: R
The destination address.
compare_value [in]
Type: T
The comparison value.
value [in]
Type: T
The input value.
original_value [out]
Type: T
The original value.
Return value
This function does not return a value.
Remarks
Atomically compares the value referenced by dest with compare_value, stores value in the location referenced by dest if the values match, returns the original value of dest in original_value. This operation can only be performed on int or uint typed resources and shared memory variables. There are two possible uses for this function. The first is when R is a shared memory variable type. In this case, the function performs the operation on the shared memory register referenced by dest. The second scenario is when R is a resource variable type. In this scenario, the function performs the operation on the resource location referenced by dest. This operation is only available when R is readable and writable.
Interlocked operations do not imply any memory fence/barrier.
Note
If you call InterlockedCompareExchange in a for or while compute shader loop, to properly compile, you must use the [allow_uav_condition] attribute on that loop.
Minimum Shader Model
This function is supported in the following shader models.
This function is supported in the following types of shaders:
See also
Intrinsic Functions
Shader Model 5
The text was updated successfully, but these errors were encountered: