[Mesa-dev] [PATCH] radeonsi: don't return NULL fence if no fence is available

Marek Olšák maraeo at gmail.com
Thu Jul 16 14:03:36 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

An alternative (and ugly) solution to the current clover issue.
---
 src/gallium/drivers/radeon/r600_pipe_common.c | 12 ++++++++++++
 src/gallium/drivers/radeon/r600_pipe_common.h |  3 +++
 src/gallium/drivers/radeonsi/si_hw_context.c  | 10 ++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 94a7535..858404d 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -718,6 +718,15 @@ static void r600_fence_reference(struct pipe_screen *screen,
 {
 	struct radeon_winsys *rws = ((struct r600_common_screen*)screen)->ws;
 
+	if (*ptr == R600_SIGNALLED_FENCE)
+		*ptr = NULL;
+
+	if (fence == R600_SIGNALLED_FENCE) {
+		rws->fence_reference(ptr, NULL);
+		*ptr = R600_SIGNALLED_FENCE;
+		return;
+	}
+
 	rws->fence_reference(ptr, fence);
 }
 
@@ -727,6 +736,9 @@ static boolean r600_fence_finish(struct pipe_screen *screen,
 {
 	struct radeon_winsys *rws = ((struct r600_common_screen*)screen)->ws;
 
+	if (fence == R600_SIGNALLED_FENCE)
+		return true;
+
 	return rws->fence_wait(rws, fence, timeout);
 }
 
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index aeb1e7a..ab8cabb 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -43,6 +43,9 @@
 #include "util/u_suballoc.h"
 #include "util/u_transfer.h"
 
+/* A dummy fence handle used as a special fence that's always signalled. */
+#define R600_SIGNALLED_FENCE ((struct pipe_fence_handle*)1)
+
 #define R600_RESOURCE_FLAG_TRANSFER		(PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
 #define R600_RESOURCE_FLAG_FLUSHED_DEPTH	(PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
 #define R600_RESOURCE_FLAG_FORCE_TILING		(PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c
index c75def5..29576f3 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -98,8 +98,14 @@ void si_context_gfx_flush(void *context, unsigned flags,
 	struct radeon_winsys *ws = ctx->b.ws;
 
 	if (cs->cdw == ctx->b.initial_gfx_cs_size) {
-		if (fence)
-			ws->fence_reference(fence, ctx->last_gfx_fence);
+		if (fence) {
+			if (ctx->last_gfx_fence)
+				ws->fence_reference(fence, ctx->last_gfx_fence);
+			else {
+				ws->fence_reference(fence, NULL);
+				*fence = R600_SIGNALLED_FENCE;
+			}
+		}
 		if (!(flags & RADEON_FLUSH_ASYNC))
 			ws->cs_sync_flush(cs);
 		return;
-- 
2.1.0



More information about the mesa-dev mailing list