Mesa (master): freedreno: query fixes

Rob Clark robclark at kemper.freedesktop.org
Fri Oct 3 18:20:48 UTC 2014


Module: Mesa
Branch: master
Commit: 7297bdbd50eb039878fe9e472dc736e1259710fb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7297bdbd50eb039878fe9e472dc736e1259710fb

Author: Rob Clark <robclark at freedesktop.org>
Date:   Fri Oct  3 12:48:31 2014 -0400

freedreno: query fixes

Fixes a few issues, including a potential empty-IB (which triggers gpu
hangs in piglit occlusion_query_meta_no_fragments)

Signed-off-by: Rob Clark <robclark at freedesktop.org>

---

 src/gallium/drivers/freedreno/a3xx/fd3_query.c     |    4 ++--
 src/gallium/drivers/freedreno/freedreno_query_hw.c |   11 ++++++-----
 src/gallium/drivers/freedreno/freedreno_util.h     |    6 +++++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_query.c b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
index 34e0b5a..bc3a3ec 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_query.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
@@ -119,14 +119,14 @@ occlusion_predicate_accumulate_result(struct fd_context *ctx,
 
 static const struct fd_hw_sample_provider occlusion_counter = {
 		.query_type = PIPE_QUERY_OCCLUSION_COUNTER,
-		.active = FD_STAGE_DRAW, /* | FD_STAGE_CLEAR ??? */
+		.active = FD_STAGE_DRAW,
 		.get_sample = occlusion_get_sample,
 		.accumulate_result = occlusion_counter_accumulate_result,
 };
 
 static const struct fd_hw_sample_provider occlusion_predicate = {
 		.query_type = PIPE_QUERY_OCCLUSION_PREDICATE,
-		.active = FD_STAGE_DRAW, /* | FD_STAGE_CLEAR ??? */
+		.active = FD_STAGE_DRAW,
 		.get_sample = occlusion_get_sample,
 		.accumulate_result = occlusion_predicate_accumulate_result,
 };
diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c
index 38bd3de..b29f9d4 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_hw.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c
@@ -183,12 +183,16 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
 		return false;
 
 	/* if the app tries to read back the query result before the
-	 * back is submitted, that forces us to flush so that there
+	 * batch is submitted, that forces us to flush so that there
 	 * are actually results to wait for:
 	 */
 	if (!LIST_IS_EMPTY(&hq->list)) {
+		/* if app didn't actually trigger any cmdstream, then
+		 * we have nothing to do:
+		 */
+		if (!ctx->needs_flush)
+			return true;
 		DBG("reading query result forces flush!");
-		ctx->needs_flush = true;
 		fd_context_render(&ctx->base);
 	}
 
@@ -201,9 +205,6 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
 	assert(LIST_IS_EMPTY(&hq->current_periods));
 	assert(!hq->period);
 
-	if (LIST_IS_EMPTY(&hq->periods))
-		return true;
-
 	/* if !wait, then check the last sample (the one most likely to
 	 * not be ready yet) and bail if it is not ready:
 	 */
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h
index a762c8f..f1a1e6e 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -209,6 +209,10 @@ static inline void
 OUT_IB(struct fd_ringbuffer *ring, struct fd_ringmarker *start,
 		struct fd_ringmarker *end)
 {
+	uint32_t dwords = fd_ringmarker_dwords(start, end);
+
+	assert(dwords > 0);
+
 	/* for debug after a lock up, write a unique counter value
 	 * to scratch6 for each IB, to make it easier to match up
 	 * register dumps to cmdstream.  The combination of IB and
@@ -219,7 +223,7 @@ OUT_IB(struct fd_ringbuffer *ring, struct fd_ringmarker *start,
 
 	OUT_PKT3(ring, CP_INDIRECT_BUFFER_PFD, 2);
 	fd_ringbuffer_emit_reloc_ring(ring, start, end);
-	OUT_RING(ring, fd_ringmarker_dwords(start, end));
+	OUT_RING(ring, dwords);
 
 	emit_marker(ring, 6);
 }




More information about the mesa-commit mailing list