Compute Space:
https://www.opengl.org/wiki/Compute_Shader#Compute_space
An abstract (3-dimensional) space in which the shader operates.
By calling "glDispatchCompute(X, Y, Z)" we define the compute space: X x Y x Z:
Each of those cubes can be considered as a "work group".
There are X times Y times Z workgroups in the compute space, in this picture 24 different work groups.
The order in which the different work groups are computed is not defined, the system can process them in any order.
A "work group" (1 cube) cant be considered as a compute shader invocation, because a work group can be subdivided in its "local size".
Computed Data cant be shared between work groups.
Work Group:
A work group has itself a "local size" (3-dimensional, again).
Now, each of those small cubes is 1 compute shader invocation. Here there are 5 x 6 x 7 = 210 different invocations per work group.
All compute shader invocations within 1 work group can share processed data. Each invocation can be considered as 1 thread which is executed in parallel to all the other invocations within that work group.
Total number of compute shader invocations = Number of Work Groups x Local Size
In this example: 24 x 210 = 5040
Dispatch:
A compute shader cant be executed on its own, it must first be linked to a "program object":
https://www.opengl.org/wiki/GLSL_Object#Program_objects
To start the compute shader, we call:
glDispatchCompute(2, 3, 4);
https://www.opengl.org/wiki/GLAPI/glDispatchCompute
That creates 2 x 3 x 4 = 24 different work groups, as shows in the picture above.
The local size of all work groups is defined in the compute shader source code:
layout (local_size_x = 5, local_size_y = 6, local_size_z = 7) in;
https://www.opengl.org/wiki/Compute_Shader#Local_size
Limitations: (OpenGL 4.5)
https://www.opengl.org/wiki/Compute_Shader#Limitations
Max. Compute Space: 65535 x 65535 x 65535
Max Local Size: 1024 x 1024 x 64
Max Local Size: < GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS (which is at least 1024)
Max Shared Memory: < GL_MAX_COMPUTE_SHARED_MEMORY_SIZE (which is at least 32KB)
The "do-nothing" Compute Shader:
#version 450 core
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
// ... do nothing ...
}