What does the "invocations" input layout qualifier of a geometry shader do?
The OpenGL wiki just says that it causes the GS to be executed multiple times for each primitive, and goes on to say that:
The output primitives from instances are ordered by the gl_InvocationID. So 2 primitives written from 3 instances will create a primitive stream of: (prim0, inst0), (prim0, inst1), (prim0, inst2), (prim1, inst0)
Does each invocation operate on the data of the previous invocation for, say, iteratively refining the geometry? Or is gl_InvocationID supposed to be used in order to do something different in each invocation? Or am I on completely the wrong track?
It's instancing within the shader; It works in a manor almost exactly like instancing with glDrawArraysInstanced
and such. The same input primitive is processed by num_instances
invocations of the GS. Each invocation is completely separate, just like each instance in instanced rendering is completely separate.
The only way to tell the difference between one GS invocation and another for the same primitive input is with the gl_InvocationID
. This will be different for each invocation, within the same primitive.