From ac83c5b55ba56d686c08129c895abf56dcc2c642 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 3 Dec 2014 11:52:51 +0000 Subject: [PATCH] bug86969 --- src/mesa/drivers/dri/i965/brw_context.h | 1 + src/mesa/drivers/dri/i965/brw_queryobj.c | 10 ++++++++-- src/mesa/drivers/dri/i965/gen6_queryobj.c | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 7cfb286..739ccad 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -820,6 +820,7 @@ struct brw_query_object { /** Last index in bo with query data for this object. */ int last_index; + int pending; }; struct intel_sync_object { diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index c053c34..0a1c183 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -97,8 +97,10 @@ brw_queryobj_get_results(struct gl_context *ctx, * 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)) + if (query->pending) { intel_batchbuffer_flush(brw); + query->pending = false; + } if (unlikely(brw->perf_debug)) { if (drm_intel_bo_busy(query->bo)) { @@ -278,6 +280,7 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) struct brw_query_object *query = (struct brw_query_object *)q; assert(brw->gen < 6); + query->pending = true; switch (query->Base.Target) { case GL_TIME_ELAPSED_EXT: @@ -356,8 +359,10 @@ static void brw_check_query(struct gl_context *ctx, struct gl_query_object *q) * not ready yet on the first time it is queried. This ensures that * the async query will return true in finite time. */ - if (query->bo && drm_intel_bo_references(brw->batch.bo, query->bo)) + if (query->pending) { intel_batchbuffer_flush(brw); + query->pending = false; + } if (query->bo == NULL || !drm_intel_bo_busy(query->bo)) { brw_queryobj_get_results(ctx, query); @@ -456,6 +461,7 @@ brw_emit_query_end(struct brw_context *brw) brw->query.begin_emitted = false; query->last_index++; + query->pending = true; } /** diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c index 130236e..a8c6b7b 100644 --- a/src/mesa/drivers/dri/i965/gen6_queryobj.c +++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c @@ -125,8 +125,10 @@ gen6_queryobj_get_results(struct gl_context *ctx, * 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)) + if (query->pending) { intel_batchbuffer_flush(brw); + query->pending = false; + } if (unlikely(brw->perf_debug)) { if (drm_intel_bo_busy(query->bo)) { @@ -270,6 +272,8 @@ gen6_end_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; + query->pending = true; + switch (query->Base.Target) { case GL_TIME_ELAPSED: brw_write_timestamp(brw, query->bo, 1); @@ -326,8 +330,10 @@ static void gen6_check_query(struct gl_context *ctx, struct gl_query_object *q) * not ready yet on the first time it is queried. This ensures that * the async query will return true in finite time. */ - if (query->bo && drm_intel_bo_references(brw->batch.bo, query->bo)) + if (query->pending) { intel_batchbuffer_flush(brw); + query->pending = false; + } if (query->bo == NULL || !drm_intel_bo_busy(query->bo)) { gen6_queryobj_get_results(ctx, query); -- 2.1.3