MEMORYBARRIER(3G)

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

πŸ’– MEMORYBARRIER β€” the 3G manual page, but make it cute πŸ’–

okay bestie, pull up a chair, we're talking about memoryBarrier from the OpenGL Shading Language section 3G and honestly? she's short, she's powerful, and she's about to rearrange your whole understanding of memory ordering. no cap. ✨


🌸 NAME 🌸

memoryBarrier β€” controls the ordering of memory transactions issued by a single shader invocation

like... it's the bouncer at the club of memory access. one shader invocation walks in, everything gets in line. periodt. πŸ’…


πŸŽ€ DECLARATION πŸŽ€

uint memoryBarrier(void);

look at her. no arguments. no drama. just vibes and a uint return. iconic. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: memoryBarrier waits on the completion of all memory accesses that came from using image variables or atomic counters, and then it just... returns. that's it. no other effect. she does her one job and leaves. main character energy, honestly.

but the important part β€” the part you actually need to remember for the exam β€” is this:

  • when this function returns, the results of any memory stores you did using coherent variables prior to the call will be visible to any future coherent memory access to the same addresses from other shader invocations.

and like, specifically specifically: the values you write this way in one shader stage are guaranteed to be visible to coherent memory accesses performed by shader invocations in subsequent stages, as long as those invocations were triggered by the execution of the original shader invocation. the manpage's own example is fragment shader invocations for a primitive that resulted from a particular geometry shader invocation. so yeah. pipeline stages. they talk. they sync. we love to see it. 🫢

ngl bestie, if you skip the barrier and expect your writes to show up downstream, you're gonna have a bad time. the memory doesn't just know you wrote something. you gotta tell it. 😭

✨ VERSION SUPPORT ✨

the vibe check across GLSL versions, in list form because we don't do tables in this house (they don't render cute):

  • OpenGL Shading Language 1.10 β€” - (not supported, sorry babe)
  • 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 memoryBarrier was out here living her best life from 4.00 onward. before that? she simply did not exist. she was a rumor. a dream. πŸ’€


πŸ’œ SEE ALSO πŸ’œ

the friend group, the whole squad, the group chat:

  • imageLoad()
  • imageStore()
  • imageAtomicAdd()
  • imageAtomicMin()
  • imageAtomicMax()
  • imageAtomicXor()
  • imageAtomicOr()
  • imageAtomicAnd()
  • imageAtomicExchange()
  • imageAtomicCompSwap()
  • groupMemoryBarrier()
  • memoryBarrierImage()
  • memoryBarrierBuffer()
  • memoryBarrierShared()

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


okay that's the whole page, bestie!! you ate that. go forth and order your memory transactions responsibly. πŸŒˆπŸ’–

tiny sign-off: this lil rewrite comes from [FIXME: source], dated 01/03/2018, and lives in the MEMORYBARRIER(3G) manual page. mwah. πŸŽ€

πŸ“¦ where this page comes from