radeonsi: don't flush an empty IB if the only thing we need is a fence
authorMarek Olšák <marek.olsak@amd.com>
Sat, 27 Jun 2015 12:03:46 +0000 (14:03 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 5 Jul 2015 13:08:59 +0000 (15:08 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/radeonsi/si_hw_context.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h

index 313ced7f5d1990b1711659d834717a9665a8fb5c..08cc08e64feabe800d31a6f1961feb80f5189b66 100644 (file)
@@ -82,9 +82,15 @@ void si_context_gfx_flush(void *context, unsigned flags,
 {
        struct si_context *ctx = context;
        struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
+       struct radeon_winsys *ws = ctx->b.ws;
 
-       if (cs->cdw == ctx->b.initial_gfx_cs_size && !fence)
+       if (cs->cdw == ctx->b.initial_gfx_cs_size) {
+               if (fence)
+                       ws->fence_reference(fence, ctx->last_gfx_fence);
+               if (!(flags & RADEON_FLUSH_ASYNC))
+                       ws->cs_sync_flush(cs);
                return;
+       }
 
        ctx->b.rings.gfx.flushing = true;
 
@@ -101,9 +107,13 @@ void si_context_gfx_flush(void *context, unsigned flags,
        flags |= RADEON_FLUSH_KEEP_TILING_FLAGS;
 
        /* Flush the CS. */
-       ctx->b.ws->cs_flush(cs, flags, fence, ctx->screen->b.cs_count++);
+       ws->cs_flush(cs, flags, &ctx->last_gfx_fence,
+                    ctx->screen->b.cs_count++);
        ctx->b.rings.gfx.flushing = false;
 
+       if (fence)
+               ws->fence_reference(fence, ctx->last_gfx_fence);
+
 #if SI_TRACE_CS
        if (ctx->screen->b.trace_bo) {
                struct si_screen *sscreen = ctx->screen;
@@ -111,7 +121,7 @@ void si_context_gfx_flush(void *context, unsigned flags,
 
                for (i = 0; i < 10; i++) {
                        usleep(5);
-                       if (!ctx->b.ws->buffer_is_busy(sscreen->b.trace_bo->buf, RADEON_USAGE_READWRITE)) {
+                       if (!ws->buffer_is_busy(sscreen->b.trace_bo->buf, RADEON_USAGE_READWRITE)) {
                                break;
                        }
                }
index 77b8d7d3a6abde07efbefc258d414a4f7054bf48..13b67d210fde3b56c0c95994ac37e4ce0269f996 100644 (file)
@@ -44,6 +44,7 @@ static void si_destroy_context(struct pipe_context *context)
        pipe_resource_reference(&sctx->null_const_buf.buffer, NULL);
        r600_resource_reference(&sctx->border_color_table, NULL);
        r600_resource_reference(&sctx->scratch_buffer, NULL);
+       sctx->b.ws->fence_reference(&sctx->last_gfx_fence, NULL);
 
        si_pm4_free_state(sctx, sctx->init_config, ~0);
        si_pm4_delete_state(sctx, gs_rings, sctx->gs_rings);
index 2d67342f1608dc8aad026766afb5bbbaa3629f18..67cb035723143de9047cc3656f2001c9320a1a0e 100644 (file)
@@ -137,6 +137,7 @@ struct si_context {
        void                            *pstipple_sampler_state;
        struct si_screen                *screen;
        struct si_pm4_state             *init_config;
+       struct pipe_fence_handle        *last_gfx_fence;
 
        union {
                struct {