I am reading the OpenGL SuperBible 7th edition which covers atomic operations on memory specifically within shader storage blocks.
It says (about atomic operations):
If two invocations access the same memory locations... then they will be serialized and only one will get to go at one time.
Great. However, it then goes on to cover Synchronizing Access to Memory specifically and the use of
As I understand it, you need to use
glMemoryBarrier once you start writing to buffers from shaders.
However, the distinction is not made clear to me about why I need to use a barrier if the operations I am doing within my shader are atomic operations.
It's possible I am conflating atomic operations and general memory access, but, in the book the line is not clearly drawn.
When is it that a
glMemoryBarrier is required? Is it everytime a shader writes to memory (whether the operations are atomic or not)?