From 9c47653d3202b166efb51bac00ae84f9d03b2a40 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 11 Dec 2014 01:43:52 -0800 Subject: [PATCH] i965/query: Remove redundant drm_intel_bo_references call in CheckQuery. CheckQuery calls drm_intel_bo_references to see if the batch references the query BO, and if so, flushes. It then checks if the query BO is busy, and if not, calls gen6_queryobj_get_results(). Stupidly, gen6_queryobj_get_results() immediately did a second redundant drm_intel_bo_references check, even though we know the buffer is not referenced and in fact idle. This patch moves the batch-flush check out of gen6_queryobj_get_results and into WaitQuery() (the other caller). That way, both callers do a single batch-flush check. This should only be a minor improvement, since it would only affect the first CheckQuery call where the result is actually available. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86969 Signed-off-by: Kenneth Graunke Reviewed-by: Ben Widawsky Reviewed-by: Ian Romanick --- src/mesa/drivers/dri/i965/gen6_queryobj.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c index 537c1d992cc..9d2e5c44f8d 100644 --- a/src/mesa/drivers/dri/i965/gen6_queryobj.c +++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c @@ -121,13 +121,6 @@ gen6_queryobj_get_results(struct gl_context *ctx, if (query->bo == NULL) return; - /* If the application has requested the query result, but this batch is - * still contributing to it, flush it now so the results will be present - * when mapped. - */ - if (drm_intel_bo_references(brw->batch.bo, query->bo)) - intel_batchbuffer_flush(brw); - if (unlikely(brw->perf_debug)) { if (drm_intel_bo_busy(query->bo)) { perf_debug("Stalling on the GPU waiting for a query object.\n"); @@ -304,8 +297,16 @@ gen6_end_query(struct gl_context *ctx, struct gl_query_object *q) */ static void gen6_wait_query(struct gl_context *ctx, struct gl_query_object *q) { + struct brw_context *brw = brw_context(ctx); struct brw_query_object *query = (struct brw_query_object *)q; + /* If the application has requested the query result, but this batch is + * still contributing to it, flush it now to finish that work so the + * result will become available (eventually). + */ + if (drm_intel_bo_references(brw->batch.bo, query->bo)) + intel_batchbuffer_flush(brw); + gen6_queryobj_get_results(ctx, query); } -- 2.30.2