ATOMICXOR(3G)

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

πŸ’… ATOMICXOR(3G) β€” the atomicXor glow-up ✨

okay bestie, buckle up, we're doing atomic logical exclusive OR today and honestly? it's giving main character energy. this is atomicXor from the 3G manual, and no cap, it's lowkey one of the most useful little gremlins in your shader toolkit. πŸ¦‹


πŸŽ€ NAME πŸŽ€

atomicXor β€” perform an atomic logical exclusive OR operation to a variable. periodt. πŸ’…


✨ DECLARATION ✨

here's the signature, bestie, copy it exactly, do NOT freestyle:

int atomicXor(inout int mem, int data);

uint atomicXor(inout uint mem, uint data);

two flavors: int and uint. pick your fighter. πŸ‘‘


🌸 PARAMETERS 🌸

  • mem β€” the variable you're using as the target of the operation. this is the thing getting XORed, the it-girl of the function. 🫢
  • data β€” the data that gets logically exclusive ORed with mem. that's the other half of the equation, literally. πŸ’–

πŸ’« DESCRIPTION πŸ’«

so here's the tea. atomicXor performs an atomic logical exclusive OR with data to the contents of mem, and it returns the original contents of mem from before the logical operation occured. yes, it gives you the old value back. iconic behavior tbh.

and the "atomic" part? that's the whole point, bestie. the contents of the memory being updated by the atomic operation are guaranteed not to be modified by any other assignment or atomic memory function in any shader invocation between the time the original value is read and the time the new value is written. so no sneaky little gremlins can slide in and mess with your value mid-operation. it's locked in. πŸ”₯

⚠️ okay but listen β€” atomic memory functions are supported only for a limited set of variables. a shader will fail to compile if the value you pass to the mem argument of an atomic memory function does not correspond to a buffer or shared variable. so don't be out here passing random stuff and then acting surprised when the compiler yells at you. 😭

and before you panic β€” it is acceptable to pass an element of an array or a single component of a vector to the mem argument of an atomic memory function, as long as the underlying array or vector is a buffer or shared variable. so like, you're fine. breathe. πŸ’œ


πŸ‘‘ VERSION SUPPORT πŸ‘‘

which OpenGL Shading Language versions are we talking about? let's do a vibe check on atomicXor, because the answer is not all of them, bestie. here's the full rundown, function by function, version by version β€” no skipping, i know the table was cute but we're listing it all:

Function name: atomicXor

  • OpenGL Shading Language 1.10 β€” - (nope, not a thing yet πŸ™ˆ)
  • OpenGL Shading Language 1.20 β€” - (still nope)
  • 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 β€” βœ” (FINALLY, she has arrived πŸ’…)
  • OpenGL Shading Language 4.40 β€” βœ”
  • OpenGL Shading Language 4.50 β€” βœ”

so basically: everything before 4.30 said "not me" and everything from 4.30 onward said "me, hi, i'm the problem, it's me." slay. ⭐


🌈 SEE ALSO 🌈

go read your sisters, bestie, they're all in the same family:

  • atomicAdd()
  • atomicAnd()
  • atomicOr()
  • atomicMin()
  • atomicMax()
  • atomicExchange()
  • atomicCompSwap()

iykyk. 🧚


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 Β© 2012-2014 Khronos Group


okay that's the whole page, bestie πŸ’– so this whole thing came from [FIXME: source] and it's dated 01/03/2018, and it's the ATOMICXOR(3G) page from [FIXME: manual] β€” and yeah, that header/footer being full of [FIXME] placeholders is very much its own mood, we don't make the rules. πŸŽ€ bye ily, go XOR something atomically. 🫢

πŸ“¦ where this page comes from