[Mesa-dev] [PATCH 04/10] winsys/radeon: fold cs_set_flush_callback into cs_create

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


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

---
 src/gallium/drivers/r300/r300_context.c       |  4 +---
 src/gallium/drivers/r600/r600_pipe.c          | 11 +++++------
 src/gallium/drivers/radeon/r600_pipe_common.c |  5 +++--
 src/gallium/drivers/radeon/radeon_uvd.c       |  2 +-
 src/gallium/drivers/radeon/radeon_vce.c       |  3 +--
 src/gallium/drivers/radeonsi/si_pipe.c        |  5 +++--
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 22 ++++++++--------------
 src/gallium/winsys/radeon/drm/radeon_winsys.h | 16 ++++------------
 8 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index e28dbfb..0116d6c 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -379,7 +379,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
                      sizeof(struct pipe_transfer), 64,
                      UTIL_SLAB_SINGLETHREADED);
 
-    r300->cs = rws->cs_create(rws, RING_GFX, NULL);
+    r300->cs = rws->cs_create(rws, RING_GFX, r300_flush_callback, r300, NULL);
     if (r300->cs == NULL)
         goto fail;
 
@@ -420,8 +420,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         goto fail;
     r300->blitter->draw_rectangle = r300_blitter_draw_rectangle;
 
-    rws->cs_set_flush_callback(r300->cs, r300_flush_callback, r300);
-
     /* The KIL opcode needs the first texture unit to be enabled
      * on r3xx-r4xx. In order to calm down the CS checker, we bind this
      * dummy texture there. */
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 6b2fcaf..677f414 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -167,6 +167,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 {
 	struct r600_context *rctx = CALLOC_STRUCT(r600_context);
 	struct r600_screen* rscreen = (struct r600_screen *)screen;
+	struct radeon_winsys *ws = rscreen->b.ws;
 
 	if (rctx == NULL)
 		return NULL;
@@ -231,13 +232,11 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 		goto fail;
 	}
 
-	if (rscreen->b.trace_bo) {
-		rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, rscreen->b.trace_bo->cs_buf);
-	} else {
-		rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, NULL);
-	}
+	rctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX,
+					     r600_flush_gfx_ring, rctx,
+					     rscreen->b.trace_bo ?
+						     rscreen->b.trace_bo->cs_buf : NULL);
 	rctx->b.rings.gfx.flush = r600_flush_gfx_ring;
-	rctx->b.ws->cs_set_flush_callback(rctx->b.rings.gfx.cs, r600_flush_gfx_ring, rctx);
 	rctx->b.rings.gfx.flushing = false;
 
 	rctx->allocator_fetch_shader = u_suballocator_create(&rctx->b.b, 64 * 1024, 256,
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index c5e85f5..efb78cf 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -109,9 +109,10 @@ bool r600_common_context_init(struct r600_common_context *rctx,
 		return false;
 
 	if (rscreen->info.r600_has_dma && !(rscreen->debug_flags & DBG_NO_ASYNC_DMA)) {
-		rctx->rings.dma.cs = rctx->ws->cs_create(rctx->ws, RING_DMA, NULL);
+		rctx->rings.dma.cs = rctx->ws->cs_create(rctx->ws, RING_DMA,
+							 r600_flush_dma_from_winsys,
+							 rctx, NULL);
 		rctx->rings.dma.flush = r600_flush_dma_ring;
-		rctx->ws->cs_set_flush_callback(rctx->rings.dma.cs, r600_flush_dma_from_winsys, rctx);
 	}
 
 	return true;
diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c
index 6c54cee..88573c1 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -806,7 +806,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
 	dec->set_dtb = set_dtb;
 	dec->stream_handle = rvid_alloc_stream_handle();
 	dec->ws = ws;
-	dec->cs = ws->cs_create(ws, RING_UVD, NULL);
+	dec->cs = ws->cs_create(ws, RING_UVD, NULL, NULL, NULL);
 	if (!dec->cs) {
 		RVID_ERR("Can't get command submission context.\n");
 		goto error;
diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c
index a7dfcda..5778dd1 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -308,13 +308,12 @@ struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context,
 	enc->get_buffer = get_buffer;
 
 	enc->ws = ws;
-	enc->cs = ws->cs_create(ws, RING_VCE, NULL);
+	enc->cs = ws->cs_create(ws, RING_VCE, rvce_cs_flush, enc, NULL);
 	if (!enc->cs) {
 		RVID_ERR("Can't get command submission context.\n");
 		goto error;
 	}
 
-	enc->ws->cs_set_flush_callback(enc->cs, rvce_cs_flush, enc);
 	templat.buffer_format = PIPE_FORMAT_NV12;
 	templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
 	templat.width = enc->base.width;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index ec03d6c..bd7670d 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -122,6 +122,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void *
 {
 	struct si_context *sctx = CALLOC_STRUCT(si_context);
 	struct si_screen* sscreen = (struct si_screen *)screen;
+	struct radeon_winsys *ws = sscreen->b.ws;
 	int shader, i;
 
 	if (sctx == NULL)
@@ -147,9 +148,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 = sctx->b.ws->cs_create(sctx->b.ws, RING_GFX, NULL);
+	sctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX, si_flush_gfx_ring,
+					     sctx, NULL);
 	sctx->b.rings.gfx.flush = si_flush_gfx_ring;
-	sctx->b.ws->cs_set_flush_callback(sctx->b.rings.gfx.cs, si_flush_gfx_ring, sctx);
 
 	si_init_all_descriptors(sctx);
 
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 4ce1717..91db6b7 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -137,9 +137,12 @@ static void radeon_destroy_cs_context(struct radeon_cs_context *csc)
 }
 
 
-static struct radeon_winsys_cs *radeon_drm_cs_create(struct radeon_winsys *rws,
-                                                     enum ring_type ring_type,
-                                                     struct radeon_winsys_cs_handle *trace_buf)
+static struct radeon_winsys_cs *
+radeon_drm_cs_create(struct radeon_winsys *rws,
+                     enum ring_type ring_type,
+                     void (*flush)(void *ctx, unsigned flags),
+                     void *flush_ctx,
+                     struct radeon_winsys_cs_handle *trace_buf)
 {
     struct radeon_drm_winsys *ws = radeon_drm_winsys(rws);
     struct radeon_drm_cs *cs;
@@ -151,6 +154,8 @@ static struct radeon_winsys_cs *radeon_drm_cs_create(struct radeon_winsys *rws,
     pipe_semaphore_init(&cs->flush_completed, 1);
 
     cs->ws = ws;
+    cs->flush_cs = flush;
+    cs->flush_data = flush_ctx;
     cs->trace_buf = (struct radeon_bo*)trace_buf;
 
     if (!radeon_init_cs_context(&cs->csc1, cs->ws)) {
@@ -551,16 +556,6 @@ static void radeon_drm_cs_destroy(struct radeon_winsys_cs *rcs)
     FREE(cs);
 }
 
-static void radeon_drm_cs_set_flush(struct radeon_winsys_cs *rcs,
-                                    void (*flush)(void *ctx, unsigned flags),
-                                    void *user)
-{
-    struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
-
-    cs->flush_cs = flush;
-    cs->flush_data = user;
-}
-
 static boolean radeon_bo_is_referenced(struct radeon_winsys_cs *rcs,
                                        struct radeon_winsys_cs_handle *_buf,
                                        enum radeon_bo_usage usage)
@@ -646,7 +641,6 @@ void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
     ws->base.cs_validate = radeon_drm_cs_validate;
     ws->base.cs_memory_below_limit = radeon_drm_cs_memory_below_limit;
     ws->base.cs_flush = radeon_drm_cs_flush;
-    ws->base.cs_set_flush_callback = radeon_drm_cs_set_flush;
     ws->base.cs_is_buffer_referenced = radeon_bo_is_referenced;
     ws->base.cs_sync_flush = radeon_drm_cs_sync_flush;
     ws->base.cs_create_fence = radeon_cs_create_fence;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 320989c..469c79b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -418,10 +418,14 @@ struct radeon_winsys {
      *
      * \param ws        The winsys this function is called from.
      * \param ring_type The ring type (GFX, DMA, UVD)
+     * \param flush     Flush callback function associated with the command stream.
+     * \param user      User pointer that will be passed to the flush callback.
      * \param trace_buf Trace buffer when tracing is enabled
      */
     struct radeon_winsys_cs *(*cs_create)(struct radeon_winsys *ws,
                                           enum ring_type ring_type,
+                                          void (*flush)(void *ctx, unsigned flags),
+                                          void *flush_ctx,
                                           struct radeon_winsys_cs_handle *trace_buf);
 
     /**
@@ -489,18 +493,6 @@ struct radeon_winsys {
     void (*cs_flush)(struct radeon_winsys_cs *cs, unsigned flags, uint32_t cs_trace_id);
 
     /**
-     * Set a flush callback which is called from winsys when flush is
-     * required.
-     *
-     * \param cs        A command stream to set the callback for.
-     * \param flush     A flush callback function associated with the command stream.
-     * \param user      A user pointer that will be passed to the flush callback.
-     */
-    void (*cs_set_flush_callback)(struct radeon_winsys_cs *cs,
-                                  void (*flush)(void *ctx, unsigned flags),
-                                  void *ctx);
-
-    /**
      * Return TRUE if a buffer is referenced by a command stream.
      *
      * \param cs        A command stream.
-- 
1.8.3.2



More information about the mesa-dev mailing list