diff options
author | Petri Latvala <petri.latvala@intel.com> | 2014-04-23 11:08:52 +0300 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2014-05-02 10:07:04 -0700 |
commit | dac82ceac5d726ff8851051f671396cfbd1abc63 (patch) | |
tree | bdc4d8190e5fbe5d82990a5fa06ead42838c6ea4 /src/mesa/main/performance_monitor.c | |
parent | 6ccb98e88c3589dd8f09737ea0c47682bb19e4d3 (diff) | |
download | external_mesa3d-dac82ceac5d726ff8851051f671396cfbd1abc63.zip external_mesa3d-dac82ceac5d726ff8851051f671396cfbd1abc63.tar.gz external_mesa3d-dac82ceac5d726ff8851051f671396cfbd1abc63.tar.bz2 |
mesa: Add core support for the GL_INTEL_performance_query extension.
Like AMD_performance_monitor, this extension provides an interface for
applications (and OpenGL-based tools) to access GPU performance
counters. Since the exact performance counters available vary between
vendors and hardware generations, the extension provides an API the
application can use to get the names, types, and minimum/maximum
values of all available counters.
Applications create performance queries based on available query
types, and begin/end measurement collection. Multiple queries can be
measuring simultaneously.
v2: Whitespace changes
v3: src/mapi/glapi/gen/gl_API.xml: Also expose the functions to GLES2.
v4: Whitespace changes, static_dispatch="false" for all functions, fix
dispatch_sanity test for GLES2 functions
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/main/performance_monitor.c')
-rw-r--r-- | src/mesa/main/performance_monitor.c | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/src/mesa/main/performance_monitor.c b/src/mesa/main/performance_monitor.c index e62f770..597f633 100644 --- a/src/mesa/main/performance_monitor.c +++ b/src/mesa/main/performance_monitor.c @@ -639,3 +639,222 @@ _mesa_perf_monitor_counter_size(const struct gl_perf_monitor_counter *c) return 0; } } + +extern void GLAPIENTRY +_mesa_GetFirstPerfQueryIdINTEL(GLuint *queryId) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If queryId pointer is equal to 0, INVALID_VALUE error is generated." + */ + if (!queryId) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetFirstPerfQueryIdINTEL(queryId == NULL)"); + return; + } + + /* The GL_INTEL_performance_query spec says: + * + * "If the given hardware platform doesn't support any performance + * queries, then the value of 0 is returned and INVALID_OPERATION error + * is raised." + */ + + *queryId = 0; + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetFirstPerfQueryIdINTEL(no queries supported)"); +} + +extern void GLAPIENTRY +_mesa_GetNextPerfQueryIdINTEL(GLuint queryId, GLuint *nextQueryId) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If nextQueryId pointer is equal to 0, an INVALID_VALUE error is + * generated." + */ + if (!nextQueryId) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetNextPerfQueryIdINTEL(nextQueryId == NULL)"); + return; + } + + /* The GL_INTEL_performance_query spec says: + * + * "If the specified performance query identifier is invalid then + * INVALID_VALUE error is generated. Whenever error is generated, the + * value of 0 is returned." + * + * No queries are supported, so all queries are invalid. + */ + *nextQueryId = 0; + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetNextPerfQueryIdINTEL(invalid query)"); +} + +extern void GLAPIENTRY +_mesa_GetPerfQueryIdByNameINTEL(char *queryName, GLuint *queryId) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If queryName does not reference a valid query name, an INVALID_VALUE + * error is generated." + * + * No queries are supported, so all query names are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetPerfQueryIdByNameINTEL(invalid query name)"); +} + +extern void GLAPIENTRY +_mesa_GetPerfQueryInfoINTEL(GLuint queryId, + GLuint queryNameLength, char *queryName, + GLuint *dataSize, GLuint *noCounters, + GLuint *noActiveInstances, + GLuint *capsMask) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If queryId does not reference a valid query type, an INVALID_VALUE + * error is generated." + * + * No queries are supported, so all queries are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetPerfQueryInfoINTEL(invalid query)"); +} + +extern void GLAPIENTRY +_mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId, + GLuint counterNameLength, char *counterName, + GLuint counterDescLength, char *counterDesc, + GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, + GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If the pair of queryId and counterId does not reference a valid + * counter, an INVALID_VALUE error is generated." + * + * No queries are supported, so all queries are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetPerfCounterInfoINTEL(invalid counterId)"); +} + +extern void GLAPIENTRY +_mesa_CreatePerfQueryINTEL(GLuint queryId, GLuint *queryHandle) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If queryId does not reference a valid query type, an INVALID_VALUE + * error is generated." + * + * No queries are supported, so all queries are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glCreatePerfQueryINTEL(invalid queryId)"); +} + +extern void GLAPIENTRY +_mesa_DeletePerfQueryINTEL(GLuint queryHandle) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If a query handle doesn't reference a previously created performance + * query instance, an INVALID_VALUE error is generated." + * + * No queries are supported, so all queries are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glDeletePerfQueryINTEL(invalid queryHandle)"); +} + +extern void GLAPIENTRY +_mesa_BeginPerfQueryINTEL(GLuint queryHandle) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If a query handle doesn't reference a previously created performance + * query instance, an INVALID_VALUE error is generated." + * + * No queries are supported, so all queries are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glBeginPerfQueryINTEL(invalid queryHandle)"); +} + +extern void GLAPIENTRY +_mesa_EndPerfQueryINTEL(GLuint queryHandle) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If a performance query is not currently started, an + * INVALID_OPERATION error will be generated." + * + * The specification doesn't state that an invalid handle would be an + * INVALID_VALUE error. Regardless, query for such a handle will not be + * started, so we generate an INVALID_OPERATION in that case. + * + * No queries are supported, so all handles are invalid. + */ + + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndPerfQueryINTEL(query not started)"); +} + +extern void GLAPIENTRY +_mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags, + GLsizei dataSize, void *data, GLuint *bytesWritten) +{ + GET_CURRENT_CONTEXT(ctx); + + /* The GL_INTEL_performance_query spec says: + * + * "If bytesWritten or data pointers are NULL then an INVALID_VALUE + * error is generated." + */ + if (!bytesWritten || !data) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetPerfQueryDataINTEL(bytesWritten or data is NULL)"); + return; + } + + /* The specification doesn't state that an invalid handle generates an + * error. We could interpret that to mean the case should be handled as + * "measurement not ready for this query", but what should be done if + * `flags' equals PERFQUERY_WAIT_INTEL? + * + * To resolve this, we just generate an INVALID_VALUE from an invalid query + * handle. + * + * No queries are supported, so all handles are invalid. + */ + + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetPerfQueryDataINTEL(invalid queryHandle)"); +} |