Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

InterlockedAdd function

Adds the value, atomically.


void InterlockedAdd(
  in  UINT dest,
  in  UINT value,
  out UINT original_value


dest [in]

Type: UINT

The destination address.

value [in]

Type: UINT

The input value.

original_value [out]

Type: UINT

The original value.

Return value

This function does not return a value.


This operation can be performed only on int or uint typed resources and shared memory variables. There are three possible uses for this function. The first is when R is a shared memory variable type. In this case, the function performs an atomic add of value to the shared memory register referenced by dest. The second scenario is when R is a resource variable type. In this scenario, the function performs an atomic add of the value to the resource location referenced by dest. Finally, the third scenario is when R is a local variable type. In this scenario, the function reduces to a sum of the value of dest and value, stored in dest. The overloaded function has an additional output variable which will be set to the original value of dest. This overloaded operation is only available when R is readable and writable.

This function is supported in the following types of shaders:



See also

Shader Model 5



Community Additions

© 2015 Microsoft