From 0558564200466878f1a86e7a192d085b551079c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Fri, 6 May 2016 17:02:30 -0500 Subject: [PATCH] gallium/radeon: add radeon_emitted to check for non-trivial IBs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/gallium/drivers/r600/evergreen_compute.c | 2 +- src/gallium/drivers/r600/r600_hw_context.c | 6 ++---- src/gallium/drivers/r600/r600_state_common.c | 2 +- src/gallium/drivers/radeon/r600_buffer_common.c | 7 +++---- src/gallium/drivers/radeon/r600_pipe_common.c | 6 +++--- src/gallium/drivers/radeon/radeon_vce.c | 2 +- src/gallium/drivers/radeon/radeon_winsys.h | 4 ++++ src/gallium/drivers/radeonsi/si_hw_context.c | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index c9643fcf2ee..8db525e0bf6 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -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); } diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index 6534d8bc4ab..1f7bed824b0 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -33,10 +33,8 @@ 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); diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 42838c28d93..b3814fb478f 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -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); } diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c index c6429bff37b..9e8384d628f 100644 --- a/src/gallium/drivers/radeon/r600_buffer_common.c +++ b/src/gallium/drivers/radeon/r600_buffer_common.c @@ -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) { diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index a5966d95d97..8d9c5a5b7af 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -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); diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c index 99b82ca9409..e16e0cf0536 100644 --- a/src/gallium/drivers/radeon/radeon_vce.c +++ b/src/gallium/drivers/radeon/radeon_vce.c @@ -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); diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h index e73fa14a17e..792bacb5499 100644 --- a/src/gallium/drivers/radeon/radeon_winsys.h +++ b/src/gallium/drivers/radeon/radeon_winsys.h @@ -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) { diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c index 7fc58a60453..dcf206df216 100644 --- a/src/gallium/drivers/radeonsi/si_hw_context.c +++ b/src/gallium/drivers/radeonsi/si_hw_context.c @@ -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); -- 2.30.2