gallium/radeon: add radeon_emitted to check for non-trivial IBs
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 6 May 2016 22:02:30 +0000 (17:02 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 17 May 2016 20:28:39 +0000 (15:28 -0500)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/radeon_vce.c
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/drivers/radeonsi/si_hw_context.c

index c9643fcf2eeab24986c4aa0a28a296608994cc4c..8db525e0bf6844ef4fb1d4d07c03f0d46ba76da1 100644 (file)
@@ -452,7 +452,7 @@ static void compute_emit_cs(struct r600_context *rctx,
        unsigned i;
 
        /* make sure that the gfx ring is only one active */
-       if (rctx->b.dma.cs && rctx->b.dma.cs->cdw) {
+       if (radeon_emitted(rctx->b.dma.cs, 0)) {
                rctx->b.dma.flush(rctx, RADEON_FLUSH_ASYNC, NULL);
        }
 
index 6534d8bc4ab971e72c91231ccbd42af08c9917ff..1f7bed824b00b896806bd2f1181aee527b7a2fe2 100644 (file)
 void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw,
                        boolean count_draw_in)
 {
-       struct radeon_winsys_cs *dma = ctx->b.dma.cs;
-
        /* Flush the DMA IB if it's not empty. */
-       if (dma && dma->cdw)
+       if (radeon_emitted(ctx->b.dma.cs, 0))
                ctx->b.dma.flush(ctx, RADEON_FLUSH_ASYNC, NULL);
 
        if (!ctx->b.ws->cs_memory_below_limit(ctx->b.gfx.cs, ctx->b.vram, ctx->b.gtt)) {
@@ -250,7 +248,7 @@ void r600_context_gfx_flush(void *context, unsigned flags,
        struct r600_context *ctx = context;
        struct radeon_winsys_cs *cs = ctx->b.gfx.cs;
 
-       if (cs->cdw == ctx->b.initial_gfx_cs_size && !fence)
+       if (!radeon_emitted(cs, ctx->b.initial_gfx_cs_size) && !fence)
                return;
 
        r600_preflush_suspend_features(&ctx->b);
index 42838c28d9366f6d890aba0e607f72655de79f79..b3814fb478f7906344918b0502a72e9cf344401b 100644 (file)
@@ -1681,7 +1681,7 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
        }
 
        /* make sure that the gfx ring is only one active */
-       if (rctx->b.dma.cs && rctx->b.dma.cs->cdw) {
+       if (radeon_emitted(rctx->b.dma.cs, 0)) {
                rctx->b.dma.flush(rctx, RADEON_FLUSH_ASYNC, NULL);
        }
 
index c6429bff37b269878899b9aa91a24fbadbfa66d2..9e8384d628f13e92f0896746d55b17772dda726e 100644 (file)
@@ -37,7 +37,7 @@ boolean r600_rings_is_buffer_referenced(struct r600_common_context *ctx,
        if (ctx->ws->cs_is_buffer_referenced(ctx->gfx.cs, buf, usage)) {
                return TRUE;
        }
-       if (ctx->dma.cs && ctx->dma.cs->cdw &&
+       if (radeon_emitted(ctx->dma.cs, 0) &&
            ctx->ws->cs_is_buffer_referenced(ctx->dma.cs, buf, usage)) {
                return TRUE;
        }
@@ -60,7 +60,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                rusage = RADEON_USAGE_WRITE;
        }
 
-       if (ctx->gfx.cs->cdw != ctx->initial_gfx_cs_size &&
+       if (radeon_emitted(ctx->gfx.cs, ctx->initial_gfx_cs_size) &&
            ctx->ws->cs_is_buffer_referenced(ctx->gfx.cs,
                                             resource->buf, rusage)) {
                if (usage & PIPE_TRANSFER_DONTBLOCK) {
@@ -71,8 +71,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                        busy = true;
                }
        }
-       if (ctx->dma.cs &&
-           ctx->dma.cs->cdw &&
+       if (radeon_emitted(ctx->dma.cs, 0) &&
            ctx->ws->cs_is_buffer_referenced(ctx->dma.cs,
                                             resource->buf, rusage)) {
                if (usage & PIPE_TRANSFER_DONTBLOCK) {
index a5966d95d97d2efae725c632761e7bc8889b60fc..8d9c5a5b7affa114cc900bef4bc1f1a1e5bab872 100644 (file)
@@ -155,7 +155,7 @@ void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw,
        }
 
        /* Flush the GFX IB if DMA depends on it. */
-       if (ctx->gfx.cs->cdw > ctx->initial_gfx_cs_size &&
+       if (radeon_emitted(ctx->gfx.cs, ctx->initial_gfx_cs_size) &&
            ((dst &&
              ctx->ws->cs_is_buffer_referenced(ctx->gfx.cs, dst->buf,
                                               RADEON_USAGE_READWRITE)) ||
@@ -212,7 +212,7 @@ void r600_dma_emit_wait_idle(struct r600_common_context *rctx)
 
        r600_need_dma_space(rctx, 1, NULL, NULL);
 
-       if (cs->cdw == 0) /* empty queue */
+       if (!radeon_emitted(cs, 0)) /* empty queue */
                return;
 
        /* NOP waits for idle on Evergreen and later. */
@@ -295,7 +295,7 @@ static void r600_flush_dma_ring(void *ctx, unsigned flags,
        struct r600_common_context *rctx = (struct r600_common_context *)ctx;
        struct radeon_winsys_cs *cs = rctx->dma.cs;
 
-       if (cs->cdw)
+       if (radeon_emitted(cs, 0))
                rctx->ws->cs_flush(cs, flags, &rctx->last_sdma_fence);
        if (fence)
                rctx->ws->fence_reference(fence, rctx->last_sdma_fence);
index 99b82ca940935b00f27dbaccb09e920ba0c788a8..e16e0cf05360c2373ca2efd01c2bd4c71f4e20f0 100644 (file)
@@ -313,7 +313,7 @@ static void rvce_encode_bitstream(struct pipe_video_codec *encoder,
                RVID_ERR("Can't create feedback buffer.\n");
                return;
        }
-       if (!enc->cs->cdw)
+       if (!radeon_emitted(enc->cs, 0))
                enc->session(enc);
        enc->encode(enc);
        enc->feedback(enc);
index e73fa14a17e61be1b763591f16b40215f30dd0a2..792bacb549995d17af149f31131db8ebfa63531a 100644 (file)
@@ -775,6 +775,10 @@ struct radeon_winsys {
                            unsigned num_registers, uint32_t *out);
 };
 
+static inline bool radeon_emitted(struct radeon_winsys_cs *cs, unsigned num_dw)
+{
+    return cs && cs->cdw > num_dw;
+}
 
 static inline void radeon_emit(struct radeon_winsys_cs *cs, uint32_t value)
 {
index 7fc58a6045389340ed54be6c8cf6b2e0bfb93c38..dcf206df216a1702d54272dd287a94c70018d9f3 100644 (file)
@@ -64,7 +64,7 @@ void si_need_cs_space(struct si_context *ctx)
        struct radeon_winsys_cs *dma = ctx->b.dma.cs;
 
        /* Flush the DMA IB if it's not empty. */
-       if (dma && dma->cdw)
+       if (radeon_emitted(dma, 0))
                ctx->b.dma.flush(ctx, RADEON_FLUSH_ASYNC, NULL);
 
        /* There are two memory usage counters in the winsys for all buffers
@@ -102,7 +102,7 @@ void si_context_gfx_flush(void *context, unsigned flags,
 
        ctx->gfx_flush_in_progress = true;
 
-       if (cs->cdw == ctx->b.initial_gfx_cs_size &&
+       if (!radeon_emitted(cs, ctx->b.initial_gfx_cs_size) &&
            (!fence || ctx->last_gfx_fence)) {
                if (fence)
                        ws->fence_reference(fence, ctx->last_gfx_fence);