PDA

View Full Version : Number of invocation of vertex shader



qweefb
09-09-2013, 01:49 AM
Hi, I would like to if there is any way for me to get the number of invocation of vertex shader after rendering a model.

For example in D3D11, I can have this struct. Inside the struct, there is an attribute VSInvocations.

typedef struct D3D11_QUERY_DATA_PIPELINE_STATISTICS {
UINT64 IAVertices;
UINT64 IAPrimitives;
UINT64 VSInvocations;
UINT64 GSInvocations;
UINT64 GSPrimitives;
UINT64 CInvocations;
UINT64 CPrimitives;
UINT64 PSInvocations;
UINT64 HSInvocations;
UINT64 DSInvocations;
UINT64 CSInvocations;
} D3D11_QUERY_DATA_PIPELINE_STATISTICS;

Are there anything similar in OpenGL?

menzel
09-09-2013, 02:13 AM
Hello,

a Query (look up glBeginQuery) with the target of GL_PRIMITIVES_GENERATED might be what you are looking for.

thokra
09-09-2013, 02:26 AM
Or an atomic counter - for this approach, check this (http://www.lighthouse3d.com/tutorials/opengl-short-tutorials/opengl-atomic-counters/) Lighthouse3D article. With an atomic counter you can track the actual number of invocations, which excludes already processed and cached vertices. Pretty neat for profiling.

menzel
09-09-2013, 03:09 AM
Good point, while the query is likely to be faster, the actual shader invocations can only be counted with a atomic counter (but those numbers will only differ for indexed rendering).

thokra
09-09-2013, 03:15 AM
but those numbers will only differ for indexed rendering

Good point, sir! :)

qweefb
09-09-2013, 06:22 PM
Thanks all for your answer!

tksuoran
09-11-2013, 12:49 PM
but those numbers will only differ for indexed rendering). That might not be accurate:
"While a vertex or tessellation evaluation shader will be executed at least once for each unique vertex specified by the application (vertex shaders) or generated by the tessellation primitive generator (tessellation evaluation shaders), it may be executed more than once for implementation-dependent reasons. Additionally, if the same vertex is specified multiple times in a collection of primitives (e.g., repeating an index in DrawElements), the vertex shader might be run only once."