Khronos public bugtracker – Bug 754
Meaning of gl_PrimitiveID in TES
Last modified: 2013-08-08 12:52:19 PDT
In the Tessellation Evaluation Shader, it is unclear what gl_PrimitiveID refers to. The 4.3 specification says:
> The variables gl_PatchVerticesIn and gl_PrimitiveID are filled
with the number of the vertices in the input patch and a primitive number,
respectively. They behave exactly as the identically named inputs for tessel-lation control shaders.
In the TCS section, it says:
> The variable gl_PrimitiveID is filled with the number of primitives pro-cessed by the drawing command which generated the input vertices. The
first primitive generated by a drawing command is numbered zero, and the
primitive ID counter is incremented after every individual point, line, or tri-angle primitive is processed. Restarting a primitive topology using the prim-itive restart index has no effect on the primitive ID counter.
This makes sense in the context of a TCS. This makes much less sense in the context of a TES, because patches can be discarded by the tessellation primitive generator. Are discarded patches counted by the gl_PrimitiveID or not?
The 4.4 specification did not seem to clear this up. Does "primitive is processed" mean processed by the TCS or processed by the TES?
The intent is that the primitive ID in TES is the number of the patch from which the primitive was produced. When TCS is present, it will take an input patch (from the API) and produce a new output path -- that output patch should be considered to have the same primitive ID number as the input patch for the purposes of this test. If a patch is consumed by the tessellation primitive generator, it should still be counted.
This is definitely worth clarifying.