I'm a bit overwhelmed learning this stuff, but i was looking at a piece of code and was super confused how the compute shader was executing over the data.
On the CPU side they had:
public void render()
{
shader.bind();
bitReversedSSBO.bindBufferBase(1);
shader.updateUniforms(N);
glBindImageTexture(0, texture.getHandle(), 0, false, 0, GL_WRITE_ONLY, GL_RGBA32F);
glDispatchCompute(log_2_N,N/16,1);
}
Then the compute shader in simple terms has:
void main(void)
{
vec2 x = gl_GlobalInvocationID.xy;
imageStore(texture, ivec2(x),vec4(0,1,0.25,1) );
}
So how does the compute shader know how many invocation Ids to run for this image? Does it just instinctively know that it has to do it for the full image dimensions ? But if that is true what if you had multiple images ? Does it just then go up to what ever the largest image is... but that would then cause accessing invalid pixels on smaller images...
What if you only wanted the top quarter of the image to change... i am very confused how the Global ID is working here to coincide with image pixels.
In short is the vector2 ranging from [0,0] to [imageWidth-1, imageHeight-1] ? If not how are they informing the compute shader how many pixels to process on the image?
Hope you can clear up my confusions here, thanks.