GLSL memoryBarrierShared() usefulness?
<p>I am wondering about the usefulness of memoryBarrierShared.</p>

<p>Indeed, when I am looking the documentation for barrier function : I read :</p>

<blockquote>
  <p>For any given static instance of barrier in a compute shader, all invocations within a single work group must enter it before any are allowed to continue beyond it. This ensures that values written by one invocation prior to a given static instance of barrier can be safely read by other invocations after their call to the same static instance of barrier. Because invocations may execute in undefined order between these barrier calls, the values of a per-vertex or per-patch output variable, or any shared variable will be undefined in a number of cases.</p>
</blockquote>

<p>So, if we can safely read values after using barrier, why do we see in some code</p>

<pre><code>memoryBarrierShared();
barrier();
</code></pre>

<p>or something wrong like</p>

<pre><code>barrier();
memoryBarrierShared();
</code></pre>

<p>So, my question is : What is the purpose of memoryBarrier{Shared,...} if using barrier is enough?</p>

<p>For memoryBarrierBuffer/Image I can understand if we use multiple stage, but for shared, I don't have any idea...</p>