summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2013-02-25 12:22:29 -0800
committerKenneth Graunke <kenneth@whitecape.org>2013-03-01 22:09:03 -0800
commit3d71f4fbac2e0337a1881cef93a220c36f9875f5 (patch)
treefd957f855b8f7b3de9d11ee449ef2e180a630b2f
parentdfb056b8926cff0f96cb181630092236ab0e8f81 (diff)
downloadexternal_mesa3d-3d71f4fbac2e0337a1881cef93a220c36f9875f5.zip
external_mesa3d-3d71f4fbac2e0337a1881cef93a220c36f9875f5.tar.gz
external_mesa3d-3d71f4fbac2e0337a1881cef93a220c36f9875f5.tar.bz2
i965: Implement the new QueryCounter() hook.
This moves the GL_TIMESTAMP handling out of EndQuery. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r--src/mesa/drivers/dri/i965/brw_queryobj.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
index cd9c848..0310479 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -307,12 +307,6 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q)
struct brw_query_object *query = (struct brw_query_object *)q;
switch (query->Base.Target) {
- case GL_TIMESTAMP:
- drm_intel_bo_unreference(query->bo);
- query->bo = drm_intel_bo_alloc(intel->bufmgr, "timer query",
- 4096, 4096);
- /* FALLTHROUGH */
-
case GL_TIME_ELAPSED_EXT:
write_timestamp(intel, query->bo, 1);
break;
@@ -468,6 +462,26 @@ brw_emit_query_end(struct brw_context *brw)
brw->query.index++;
}
+/**
+ * Driver hook for glQueryCounter().
+ *
+ * This handles GL_TIMESTAMP queries, which perform a pipelined read of the
+ * current GPU time. This is unlike GL_TIME_ELAPSED, which measures the
+ * time while the query is active.
+ */
+static void
+brw_query_counter(struct gl_context *ctx, struct gl_query_object *q)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct brw_query_object *query = (struct brw_query_object *) q;
+
+ assert(q->Target == GL_TIMESTAMP);
+
+ drm_intel_bo_unreference(query->bo);
+ query->bo = drm_intel_bo_alloc(intel->bufmgr, "timestamp query", 4096, 4096);
+ write_timestamp(intel, query->bo, 1);
+}
+
static uint64_t
brw_get_timestamp(struct gl_context *ctx)
{
@@ -490,6 +504,7 @@ void brw_init_queryobj_functions(struct dd_function_table *functions)
functions->DeleteQuery = brw_delete_query;
functions->BeginQuery = brw_begin_query;
functions->EndQuery = brw_end_query;
+ functions->QueryCounter = brw_query_counter;
functions->CheckQuery = brw_check_query;
functions->WaitQuery = brw_wait_query;
functions->GetTimestamp = brw_get_timestamp;