In a Geometry Shader, I need the index of the current triangle within the patch being currently tessellated by the Tessellation Control Shader.
Since gl_PrimitiveIDIn is called per-primitive, and reading here :"The GS can also be instanced ... This causes the GS to execute multiple times for the same input primitive. Each invocation of the GS for a particular input primitive will get a different gl_InvocationID value."
knowing that a patch is always being tessellated into n triangles, I am finding the index of the current triangle within a patch as index = gl_PrimitiveIDIn * n + gl_InvocationID;
It works. But I am not comfortable beacuse the same link also states:
"To use instancing, there must be an input layout qualifier: layout(invocations = num_instances​) in;"
which is not my case, because I have no layout qualifier like this. Yet the Geometry Shader is invoked multiple times on the same primitive in case of a tessellation, at least in my case, and gl_InvocationID is updated accordingly.
Can I safely assume that a Geometry Shader following a Tessellation Control Shader will be instanced multiple times?