Hello,
I’m currently reading Part 6 of the Superbible and struggle a bit with glMemoryBarrier.
While i do understand what a Memorybarrier is, i’m not totally sure when i need to use it.
So glMemoryBarrier is introduced in the Chapter about Storage Buffer Blocks and Atomic Counters. It’s quite clear that Barriers are necessary together with these writeable buffers, so that later shaders indeed see the results for sure.
But what about other cases without Storage Buffers or Atomic Counters?
Here are two examples:
-
Transform Feedback. I’ve lately written a shader for skinning of models to speed things up. It works perfectely fine. The update-shader performs all the necessary calculations to animate the model and writes the values with transform feedback back into a buffer. Then this buffer is used as a vertex buffer to actually render the model.
Do i need to call glMemoryBarrier (with MemoryBarrierFlags.VertexAttribArrayBarrierBit because the buffer will then be used as a vertex attribute) between both the update- and rendershader? -
Rendering to texture. There are several ways for rendering to a texture. Let’s say with a FBO and in the next renderpass this texture is glued on some geometry. Again, do i need to set a Barrier (with MemoryBarrierFlags.TextureFetchBarrierBit i guess) in this case?
(Consider: Both examples do not use Storage Buffers or Atomic Counters. But the book doesn’t say anything about other cases so far)
Some time ago I actually asked myself, before even knowing anything about GLs memorybarriers, if the necessary data are really available in cases like the both examples. Now, i’m even more puzzled.
Thanks