imageAtomicCompSwap - OpenGL 4 Reference Pages

## Name

imageAtomicCompSwap — atomically compares supplied data with that in memory and conditionally stores it to memory

## Declaration

`uint imageAtomicCompSwap(` | gimage1D image,
| int P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage2D image,
| ivec2 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage3D image,
| ivec3 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage2DRect image,
| ivec2 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimageCube image,
| ivec3 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gbufferImage image,
| int P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage1DArray image,
| ivec2 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage2DArray image,
| ivec3 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimageCubeArray image,
| ivec3 P,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage2DMS image,
| ivec2 P,
| int sample,
| uint compare,
| uint data`)`;

`uint imageAtomicCompSwap(` | gimage2DMSArray image,
| ivec3 P,
| int sample,
| uint compare,
| uint data`)`;

`int imageAtomicCompSwap(` | gimage1D image,
| int P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage2D image,
| ivec2 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage3D image,
| ivec3 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage2DRect image,
| ivec2 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimageCube image,
| ivec3 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gbufferImage image,
| int P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage1DArray image,
| ivec2 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage2DArray image,
| ivec3 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimageCubeArray image,
| ivec3 P,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage2DMS image,
| ivec2 P,
| int sample,
| int compare,
| int data`)`;

`int imageAtomicCompSwap(` | gimage2DMSArray image,
| ivec3 P,
| int sample,
| int compare,
| int data`)`;

## Parameters

`image`

  Specify the image unit into which to compare and conditionally store `data`.

`P`

  Specify the coordinate at which to compare and conditionally store the data.

`sample`

  When present, specifies the sample within the image to compare and conditionally store into.

`compare`

  Specifies the value to compare with the content of the image.

`data`

  Specifies the value to store in the image if `compare` is equal to the existing image content.

## Description

`imageAtomicCompSwap` atomically compares the value of `compare` with that of the texel at coordinate `P` and `sample` (for multisampled forms) in the image bound to uint `image`. If the values are equal, `data` is stored into the texel, otherwise it is discarded. It returns the original value of the texel regardless of the result of the comparison operation.

## Version Support

| OpenGL Shading Language Version
--- | ---
Function Name | 1.10 | 1.20 | 1.30 | 1.40 | 1.50 | 3.30 | 4.00 | 4.10 | 4.20 | 4.30 | 4.40 | 4.50
imageAtomicCompSwap | - | - | - | - | - | - | - | - | ✔ | ✔ | ✔ | ✔

## See Also

imageLoad, imageStore, imageAtomicAdd, imageAtomicMin, imageAtomicMax, imageAtomicXor, imageAtomicOr, imageAtomicAnd, imageAtomicCompSwap

## Copyright

Copyright © 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.