Reputation: 8238
TES shader provides a built-in input variable gl_PrimitiveID
, which is the index of the current patch in the series of patches being processed for this draw call.
How can I know the total number of patches in this draw call, besides setting uniform variable? And why is there no such input? It seems pretty logical to have something like gl_NumPrimitives
built-in, if we already have gl_PrimitiveID
counter.
Motivation: I want to index a 1D sampler from 0.0 to 1.0 based on gl_PrimitiveID
, so that the first primitive in the draw call corresponds to 0.0 and the last one corresponds to 1.0.
Upvotes: 4
Views: 245
Reputation: 72479
How can I know the total number of patches in this draw call, besides setting uniform variable?
You cannot other than setting a uniform variable.
And why is there no such input?
I'm not part of Khronos, but I speculate that:
The underlying hardware is very stream oriented. As a matter of fact you can't know beforehand the number of primitives in the general case (e.g. when you are using a primitive restart index), which means that calculating it would require a separate step to be done which wouldn't fit into the current stream-based architecture.
They are trying to keep the latest OpenGL versions to the bare minimum. It means that any features that could be as-efficiently implemented by means of the existing features are out.
Upvotes: 4