Mesa (master): r600g: fix occlusion query results.

Dave Airlie airlied at kemper.freedesktop.org
Mon Jan 31 06:09:18 UTC 2011


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jan 31 16:03:29 2011 +1000

r600g: fix occlusion query results.

Like on some r5xx, there are multiple DB backends on the r600,
we need to add up the query results from each of these to get the
final correct value.

So far I'm not 100% sure how to calculate the num_db, value
setting it to 4 should be harmless enough until we do.

This fixes occulsion_query piglit test on my rv740.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/drivers/r600/r600.h               |    1 +
 src/gallium/winsys/r600/drm/r600_hw_context.c |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index b8888be..15cfb7f 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -250,6 +250,7 @@ struct r600_context {
 	struct list_head	query_list;
 	unsigned		num_query_running;
 	struct list_head	fenced_bo;
+	unsigned                num_db; /* for OQ */
 };
 
 struct r600_draw {
diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c
index 6b7e4d8..53879a5 100644
--- a/src/gallium/winsys/r600/drm/r600_hw_context.c
+++ b/src/gallium/winsys/r600/drm/r600_hw_context.c
@@ -751,6 +751,10 @@ int r600_context_init(struct r600_context *ctx, struct radeon *radeon)
 
 	/* init dirty list */
 	LIST_INITHEAD(&ctx->dirty);
+
+	/* TODO update this value correctly */
+	ctx->num_db = 4;
+
 	return 0;
 out_err:
 	r600_context_fini(ctx);
@@ -1252,6 +1256,7 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu
 	u64 start, end;
 	u32 *results;
 	int i;
+	int size;
 
 	if (wait)
 		results = r600_bo_map(ctx->radeon, query->buffer, PB_USAGE_CPU_READ, NULL);
@@ -1260,7 +1265,8 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu
 	if (!results)
 		return FALSE;
 
-	for (i = 0; i < query->num_results; i += 4) {
+	size = query->num_results * (query->type == PIPE_QUERY_OCCLUSION_COUNTER ? ctx->num_db : 1);
+	for (i = 0; i < size; i += 4) {
 		start = (u64)results[i] | (u64)results[i + 1] << 32;
 		end = (u64)results[i + 2] | (u64)results[i + 3] << 32;
 		if (((start & 0x8000000000000000UL) && (end & 0x8000000000000000UL))
@@ -1338,7 +1344,7 @@ void r600_query_end(struct r600_context *ctx, struct r600_query *query)
 	ctx->pm4[ctx->pm4_cdwords++] = 0;
 	r600_context_bo_reloc(ctx, &ctx->pm4[ctx->pm4_cdwords - 1], query->buffer);
 
-	query->num_results += 4;
+	query->num_results += 4 * (query->type == PIPE_QUERY_OCCLUSION_COUNTER ? ctx->num_db : 1);
 	query->state ^= R600_QUERY_STATE_STARTED;
 	query->state |= R600_QUERY_STATE_ENDED;
 	ctx->num_query_running--;




More information about the mesa-commit mailing list