Use the source from the previous tutorial 1.
1 invokation call delivers this result:
glUseProgram(program);
glDispatchCompute(10, 1, 1);
glUseProgram(0);
However, calling the Compute Shader multiple times without synchronizing between the calls, the result will be undefined:
glUseProgram(program);
for (unsigned int i = 0; i < 50; i++)
{
glDispatchCompute(10, 1, 1);
}
glUseProgram(0);
To fix this, we have to synchronize between each invokation call:
glUseProgram(program);
for (unsigned int i = 0; i < 50; i++)
{
glDispatchCompute(10, 1, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
}
glUseProgram(0);
Read more about it here:
https://www.opengl.org/wiki/GLAPI/glMemoryBarrier
If (for example) the compute shader writes into buffer object and you want to use those buffer objects as sources for vertex attributes to render a triangle, you will have to use:
GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT