[Mesa-dev] [PATCH] r600g/radeonsi: unreference previous fence in flush

j.glisse at gmail.com j.glisse at gmail.com
Mon Mar 4 10:17:03 PST 2013


From: Jerome Glisse <jglisse at redhat.com>

Some code calling the flush function gave a fence pointer that point
to an old fence and should be unreference to avoid leaking fence.

Candidate for 9.1

Signed-off-by: Jerome Glisse <jglisse at redhat.com>
---
 src/gallium/drivers/r600/r600_pipe.c         | 8 +++++---
 src/gallium/drivers/radeonsi/radeonsi_pipe.c | 9 ++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 78002ae..4bcfc67 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -145,12 +145,14 @@ static void r600_flush_from_st(struct pipe_context *ctx,
 			       enum pipe_flush_flags flags)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
-	struct r600_fence **rfence = (struct r600_fence**)fence;
+	struct r600_fence *rfence;
 	unsigned fflags;
 
 	fflags = flags & PIPE_FLUSH_END_OF_FRAME ? RADEON_FLUSH_END_OF_FRAME : 0;
-	if (rfence) {
-		*rfence = r600_create_fence(rctx);
+	if (fence) {
+		rfence = r600_create_fence(rctx);
+		ctx->screen->fence_reference(ctx->screen, fence,
+						(struct pipe_fence_handle *)rfence);
 	}
 	/* flush gfx & dma ring, order does not matter as only one can be live */
 	if (rctx->rings.dma.cs) {
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index acf3e2d..3272fe2 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -135,12 +135,15 @@ void radeonsi_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
 		    unsigned flags)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
-	struct r600_fence **rfence = (struct r600_fence**)fence;
+	struct r600_fence *rfence;
 	struct pipe_query *render_cond = NULL;
 	unsigned render_cond_mode = 0;
 
-	if (rfence)
-		*rfence = r600_create_fence(rctx);
+	if (fence) {
+		rfence = r600_create_fence(rctx);
+		ctx->screen->fence_reference(ctx->screen, fence,
+						(struct pipe_fence_handle *)rfence);
+	}
 
 	/* Disable render condition. */
 	if (rctx->current_render_cond) {
-- 
1.7.11.7



More information about the mesa-dev mailing list