Mesa (master): mesa: Add a new QueryCounter() hook for TIMESTAMP queries.
Kenneth Graunke
kwg at kemper.freedesktop.org
Sat Mar 2 09:19:08 UTC 2013
Module: Mesa
Branch: master
Commit: dfb056b8926cff0f96cb181630092236ab0e8f81
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfb056b8926cff0f96cb181630092236ab0e8f81
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Mon Feb 25 11:21:17 2013 -0800
mesa: Add a new QueryCounter() hook for TIMESTAMP queries.
In OpenGL, most queries record statistics about operations performed
between a defined beginning and ending point. However, TIMESTAMP
queries are different: they immediately return a single value, and there
is no start/stop mechanism.
Previously, Mesa implemented TIMESTAMP queries by calling EndQuery
without first calling BeginQuery. Apparently this is DirectX
convention, and Gallium followed suit. I personally find the asymmetry
jarring, however---having BeginQuery and EndQuery handle a different set
of enum values looks like a bug. It's also a bit confusing to mix the
one-shot query with the start/stop model.
So, add a new QueryCounter driver hook for implementing TIMESTAMP. For
now, fall back to EndQuery to support drivers that don't do the new
mechanism.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/main/dd.h | 1 +
src/mesa/main/queryobj.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 4907116..4860d4d 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -638,6 +638,7 @@ struct dd_function_table {
struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id);
void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*QueryCounter)(struct gl_context *ctx, struct gl_query_object *q);
void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q);
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index d0c5a25..f0db740 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -486,9 +486,14 @@ _mesa_QueryCounter(GLuint id, GLenum target)
q->Result = 0;
q->Ready = GL_FALSE;
- /* QueryCounter is implemented using EndQuery without BeginQuery
- * in drivers. This is actually Direct3D and Gallium convention. */
- ctx->Driver.EndQuery(ctx, q);
+ if (ctx->Driver.QueryCounter) {
+ ctx->Driver.QueryCounter(ctx, q);
+ } else {
+ /* QueryCounter is implemented using EndQuery without BeginQuery
+ * in drivers. This is actually Direct3D and Gallium convention.
+ */
+ ctx->Driver.EndQuery(ctx, q);
+ }
}
More information about the mesa-commit
mailing list