winsys/radeon: fold cs_set_flush_callback into cs_create
authorMarek Olšák <marek.olsak@amd.com>
Fri, 11 Apr 2014 20:14:27 +0000 (22:14 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 16 Apr 2014 12:02:51 +0000 (14:02 +0200)
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/radeon_uvd.c
src/gallium/drivers/radeon/radeon_vce.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/winsys/radeon/drm/radeon_drm_cs.c
src/gallium/winsys/radeon/drm/radeon_winsys.h

index e28dbfb4034182eb0b77eab99891190760bca8ff..0116d6c0683e884199c6ce592310762775e69301 100644 (file)
@@ -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. */
index 6b2fcaf9bb4f866fe2ca3b206a6a90b3511f4d74..677f414226dd825f25586659ccb52a6d3c49df6e 100644 (file)
@@ -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,
index c5e85f52a0058784414a7b382ff838d3e98636ab..efb78cf0caa7378a827f28bc912f42670abcff2d 100644 (file)
@@ -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;
index 6c54cee4a404a077763b551b7227be275e122256..88573c1a941f5ba5033d7bd25feab666e0587dd4 100644 (file)
@@ -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;
index a7dfcda481650f0f2c8b3e7d812e1b45daae132b..5778dd1b3bfd62a704acbef6e7e51bef8b95a6e3 100644 (file)
@@ -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;
index ec03d6c232c5238fca750d6987499b2dc0605343..bd7670d07be0058668a57723ff01d9ad316e76ad 100644 (file)
@@ -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);
 
index 4ce1717ecc9e9c7d6a6b9597514b97b8ddd58faa..91db6b7f365d88dd60f3ef16a1a14e067ecfaf94 100644 (file)
@@ -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;
index 320989c078845b2192554aaed1772b1959221dfa..469c79beccc3f6039b1882dc61ceb06f047f40ac 100644 (file)
@@ -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);
 
     /**
@@ -488,18 +492,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.
      *