IMAGEATOMICCOMPSWAP(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

πŸ’– IMAGEATOMICCOMPSWAP πŸ’–

okay bestie, welcome to IMAGEATOMICCOMPSWAP(3G) β€” the manual page, but make it fashion. this is the GLSL glow-up you didn't know you needed. sit down, hydrate, let's go 🫢


✨ NAME ✨

imageAtomicCompSwap β€” atomically compares supplied data with that in memory and conditionally stores it to memory

like... it peeks at what's in memory, checks if it matches, and only then decides whether to write. commitment issues? no. it's just careful. πŸ’…


πŸŽ€ DECLARATION πŸŽ€

here's the full roster, no skips, no cuts. every single one of these is iconic in its own way:

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);

twenty-two overloads. twenty-two. the range of image types is giving "collect them all" energy and honestly? we love the consistency. πŸ’œ


🌸 PARAMETERS 🌸

  • image β€” the image unit you're comparing into and conditionally storing data into. this is your main character. πŸ‘‘
  • P β€” the coordinate where the comparing and the conditional storing happens. tell it where, bestie. πŸ“
  • sample β€” when it's present, it names the sample within the image that you're comparing and conditionally storing into. only the multisampled ones get to have this. πŸ™ˆ
  • compare β€” the value you're checking against whatever's already sitting in the image. the vibe check value. 🧚
  • data β€” the value that gets stored into the image if compare is equal to the existing image content. otherwise it just... doesn't. πŸ’€

πŸ’… DESCRIPTION πŸ’…

so here's the tea. imageAtomicCompSwap atomically compares the value of compare with that of the texel at coordinate P and sample (for the multisampled forms, obviously β€” they're the special ones) in the image bound to uint image.

if the values are equal β†’ data gets stored into the texel. slay. ✨

if they're not equal β†’ data is discarded. no cap, it just evaporates. gone. bye. πŸ¦‹

and here's the part everyone forgets: it returns the original value of the texel regardless of the result of the comparison operation. so even when the swap doesn't happen, you still walk away knowing what was there before. it's giving generous. it's giving transparent communication. 🌈


πŸ‘‘ VERSION SUPPORT πŸ‘‘

here's the timeline of when imageAtomicCompSwap said "hi, i exist now" β€” and spoiler, it took a minute. literally every version before 4.20 is a -, and then it's straight βœ”βœ”βœ”βœ” to the end. late bloomer behavior, honestly iconic.

  • OpenGL Shading Language 1.10 β€” -
  • OpenGL Shading Language 1.20 β€” -
  • OpenGL Shading Language 1.30 β€” -
  • OpenGL Shading Language 1.40 β€” -
  • OpenGL Shading Language 1.50 β€” -
  • OpenGL Shading Language 3.30 β€” -
  • OpenGL Shading Language 4.00 β€” -
  • OpenGL Shading Language 4.10 β€” -
  • OpenGL Shading Language 4.20 β€” βœ”
  • OpenGL Shading Language 4.30 β€” βœ”
  • OpenGL Shading Language 4.40 β€” βœ”
  • OpenGL Shading Language 4.50 β€” βœ”

so if you're on anything below 4.20, this function is not available to you. sorry babe, that's just the lore. πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, they're all in the same friend group:

  • imageLoad()
  • imageStore()
  • imageAtomicAdd()
  • imageAtomicMin()
  • imageAtomicMax()
  • imageAtomicXor()
  • imageAtomicOr()
  • imageAtomicAnd()
  • imageAtomicCompSwap()

(yes, it links to itself. self-love is important. πŸ’œ)


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/.

Copyright Β© 2011-2014 Khronos Group


okay that's the whole page, you ate it, you read it, you understood it. no notes. πŸ’…

source situation: [FIXME: source], and this whole thing is dated 01/03/2018. shoutout to whoever wrote it, you're a legend, mwah. πŸŽ€βœ¨

πŸ“¦ where this page comes from