[Mesa-dev] [PATCH 07/10] radeonsi: merge si_flush with si_context_flush

Marek Olšák maraeo at gmail.com
Sat Apr 12 09:34:21 PDT 2014


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

This also removes si_flush_gfx_ring.
---
 src/gallium/drivers/radeon/r600_pipe_common.h |  4 +++
 src/gallium/drivers/radeonsi/si_hw_context.c  | 26 +++++++++++++++++--
 src/gallium/drivers/radeonsi/si_pipe.c        | 37 +++------------------------
 src/gallium/drivers/radeonsi/si_pipe.h        |  4 +--
 4 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 36a4fb1..a87efdc 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -352,6 +352,10 @@ struct r600_common_context {
 	unsigned			current_render_cond_mode;
 	boolean				current_render_cond_cond;
 	boolean				predicate_drawing;
+	/* For context flushing. */
+	struct pipe_query		*saved_render_cond;
+	boolean				saved_render_cond_cond;
+	unsigned			saved_render_cond_mode;
 
 	/* Copy one resource to another using async DMA. */
 	void (*dma_copy)(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c
index f527781..37ca290 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -77,14 +77,28 @@ void si_need_cs_space(struct si_context *ctx, unsigned num_dw,
 	}
 }
 
-void si_context_flush(struct si_context *ctx, unsigned flags,
-		      struct pipe_fence_handle **fence)
+void si_context_gfx_flush(void *context, unsigned flags,
+			  struct pipe_fence_handle **fence)
 {
+	struct si_context *ctx = context;
 	struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
 
 	if (cs->cdw == ctx->b.initial_gfx_cs_size)
 		return;
 
+	ctx->b.rings.gfx.flushing = true;
+
+	/* Disable render condition. */
+	ctx->b.saved_render_cond = NULL;
+	ctx->b.saved_render_cond_cond = FALSE;
+	ctx->b.saved_render_cond_mode = 0;
+	if (ctx->b.current_render_cond) {
+		ctx->b.saved_render_cond = ctx->b.current_render_cond;
+		ctx->b.saved_render_cond_cond = ctx->b.current_render_cond_cond;
+		ctx->b.saved_render_cond_mode = ctx->b.current_render_cond_mode;
+		ctx->b.b.render_condition(&ctx->b.b, NULL, FALSE, 0);
+	}
+
 	/* suspend queries */
 	ctx->b.nontimer_queries_suspended = false;
 	if (ctx->b.num_cs_dw_nontimer_queries_suspend) {
@@ -125,6 +139,7 @@ void si_context_flush(struct si_context *ctx, unsigned flags,
 
 	/* Flush the CS. */
 	ctx->b.ws->cs_flush(cs, flags, fence, 0);
+	ctx->b.rings.gfx.flushing = false;
 
 #if SI_TRACE_CS
 	if (ctx->screen->b.trace_bo) {
@@ -177,6 +192,13 @@ void si_begin_new_cs(struct si_context *ctx)
 		r600_resume_nontimer_queries(&ctx->b);
 	}
 
+	/* Re-enable render condition. */
+	if (ctx->b.saved_render_cond) {
+		ctx->b.b.render_condition(&ctx->b.b, ctx->b.saved_render_cond,
+					  ctx->b.saved_render_cond_cond,
+					  ctx->b.saved_render_cond_mode);
+	}
+
 	ctx->framebuffer.atom.dirty = true;
 	ctx->b.streamout.enable_atom.dirty = true;
 	si_all_descriptors_begin_new_cs(ctx);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index d434064..7f3b0c2 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -33,30 +33,6 @@
 /*
  * pipe_context
  */
-static void si_flush(struct pipe_context *ctx, unsigned flags,
-		     struct pipe_fence_handle **fence)
-{
-	struct si_context *sctx = (struct si_context *)ctx;
-	struct pipe_query *render_cond = NULL;
-	boolean render_cond_cond = FALSE;
-	unsigned render_cond_mode = 0;
-
-	/* Disable render condition. */
-	if (sctx->b.current_render_cond) {
-		render_cond = sctx->b.current_render_cond;
-		render_cond_cond = sctx->b.current_render_cond_cond;
-		render_cond_mode = sctx->b.current_render_cond_mode;
-		ctx->render_condition(ctx, NULL, FALSE, 0);
-	}
-
-	si_context_flush(sctx, flags, fence);
-
-	/* Re-enable render condition. */
-	if (render_cond) {
-		ctx->render_condition(ctx, render_cond, render_cond_cond, render_cond_mode);
-	}
-}
-
 static void si_flush_from_st(struct pipe_context *ctx,
 			     struct pipe_fence_handle **fence,
 			     unsigned flags)
@@ -70,14 +46,7 @@ static void si_flush_from_st(struct pipe_context *ctx,
 	if (sctx->b.rings.dma.cs) {
 		sctx->b.rings.dma.flush(sctx, rflags, NULL);
 	}
-
-	si_flush(ctx, rflags, fence);
-}
-
-static void si_flush_gfx_ring(void *ctx, unsigned flags,
-			      struct pipe_fence_handle **fence)
-{
-	si_flush(ctx, flags, fence);
+	sctx->b.rings.gfx.flush(sctx, rflags, fence);
 }
 
 static void si_destroy_context(struct pipe_context *context)
@@ -145,9 +114,9 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void *
 		sctx->b.b.create_video_buffer = vl_video_buffer_create;
 	}
 
-	sctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX, si_flush_gfx_ring,
+	sctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX, si_context_gfx_flush,
 					     sctx, NULL);
-	sctx->b.rings.gfx.flush = si_flush_gfx_ring;
+	sctx->b.rings.gfx.flush = si_context_gfx_flush;
 
 	si_init_all_descriptors(sctx);
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 8930f2b..a74bbcf 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -177,8 +177,8 @@ void si_dma_copy(struct pipe_context *ctx,
 		 const struct pipe_box *src_box);
 
 /* si_hw_context.c */
-void si_context_flush(struct si_context *ctx, unsigned flags,
-		      struct pipe_fence_handle **fence);
+void si_context_gfx_flush(void *context, unsigned flags,
+			  struct pipe_fence_handle **fence);
 void si_begin_new_cs(struct si_context *ctx);
 void si_need_cs_space(struct si_context *ctx, unsigned num_dw, boolean count_draw_in);
 
-- 
1.8.3.2



More information about the mesa-dev mailing list