diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c index 85ab44688b2..9c837a5a01b 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c @@ -460,7 +460,7 @@ fd5_blitter_blit(struct fd_context *ctx, } fd_resource(info->dst.resource)->valid = true; - batch->needs_flush = true; + fd_batch_needs_flush(batch); fd_batch_flush(batch); fd_batch_reference(&batch, NULL); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 9896d1f6da2..23da2dd788a 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -926,11 +926,11 @@ handle_rgba_blit(struct fd_context *ctx, ASSERTED bool ret = fd_batch_lock_submit(batch); assert(ret); - /* Clearing last_fence must come after the batch dependency tracking - * (resource_read()/resource_write()), as that can trigger a flush, - * re-populating last_fence + /* Marking the batch as needing flush must come after the batch + * dependency tracking (resource_read()/resource_write()), as that + * can trigger a flush */ - fd_fence_ref(&ctx->last_fence, NULL); + fd_batch_needs_flush(batch); fd_batch_update_queries(batch); @@ -961,7 +961,6 @@ handle_rgba_blit(struct fd_context *ctx, fd_batch_unlock_submit(batch); fd_resource(info->dst.resource)->valid = true; - batch->needs_flush = true; fd_batch_flush(batch); fd_batch_reference(&batch, NULL); diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index b79ffc9f418..42cbf6c8de0 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -34,6 +34,7 @@ #include "util/u_trace.h" #include "freedreno_context.h" +#include "freedreno_fence.h" #include "freedreno_util.h" #ifdef DEBUG @@ -360,6 +361,17 @@ fd_batch_lock_submit(struct fd_batch *batch) return ret; } +/** + * Mark the batch as having something worth flushing (rendering, blit, query, + * etc) + */ +static inline void +fd_batch_needs_flush(struct fd_batch *batch) +{ + batch->needs_flush = true; + fd_fence_ref(&batch->ctx->last_fence, NULL); +} + /* Since we reorder batches and can pause/resume queries (notably for disabling * queries dueing some meta operations), we update the current query state for * the batch before each draw. diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.c b/src/gallium/drivers/freedreno/freedreno_blitter.c index c188d17cd86..d3d1002c4c6 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.c +++ b/src/gallium/drivers/freedreno/freedreno_blitter.c @@ -80,8 +80,6 @@ static void fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard) assert_dt { - fd_fence_ref(&ctx->last_fence, NULL); - util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vtx.vertexbuf.vb); util_blitter_save_vertex_elements(ctx->blitter, ctx->vtx.vtx); util_blitter_save_vertex_shader(ctx->blitter, ctx->prog.vs); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index b01e77c2c06..114d1648791 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -229,7 +229,7 @@ fd_emit_string_marker(struct pipe_context *pctx, const char *string, struct fd_batch *batch = fd_context_batch_locked(ctx); - ctx->batch->needs_flush = true; + fd_batch_needs_flush(batch); if (ctx->screen->gpu_id >= 500) { fd_emit_string5(batch->draw, string, len); diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 9342f3ed225..d86a0b38b88 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -346,11 +346,11 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, batch->back_blit = ctx->in_shadow; batch->num_draws++; - /* Clearing last_fence must come after the batch dependency tracking - * (resource_read()/resource_written()), as that can trigger a flush, - * re-populating last_fence + /* Marking the batch as needing flush must come after the batch + * dependency tracking (resource_read()/resource_write()), as that + * can trigger a flush */ - fd_fence_ref(&ctx->last_fence, NULL); + fd_batch_needs_flush(batch); struct pipe_framebuffer_state *pfb = &batch->framebuffer; DBG("%p: %ux%u num_draws=%u (%s/%s)", batch, pfb->width, pfb->height, @@ -361,8 +361,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, batch->cost += ctx->draw_cost; for (unsigned i = 0; i < num_draws; i++) { - if (ctx->draw_vbo(ctx, info, indirect, &draws[i], index_offset)) - batch->needs_flush = true; + ctx->draw_vbo(ctx, info, indirect, &draws[i], index_offset); batch->num_vertices += draws[i].count * info->instance_count; } @@ -413,7 +412,6 @@ batch_clear_tracking(struct fd_batch *batch, unsigned buffers) assert_dt batch->invalidated |= cleared_buffers; batch->resolve |= buffers; - batch->needs_flush = true; fd_screen_lock(ctx->screen); @@ -467,11 +465,11 @@ fd_clear(struct pipe_context *pctx, unsigned buffers, assert(ctx->batch == batch); } - /* Clearing last_fence must come after the batch dependency tracking - * (resource_read()/resource_written()), as that can trigger a flush, - * re-populating last_fence + /* Marking the batch as needing flush must come after the batch + * dependency tracking (resource_read()/resource_write()), as that + * can trigger a flush */ - fd_fence_ref(&ctx->last_fence, NULL); + fd_batch_needs_flush(batch); struct pipe_framebuffer_state *pfb = &batch->framebuffer; DBG("%p: %x %ux%u depth=%f, stencil=%u (%s/%s)", batch, buffers, pfb->width, @@ -574,7 +572,7 @@ fd_launch_grid(struct pipe_context *pctx, fd_screen_unlock(ctx->screen); - batch->needs_flush = true; + fd_batch_needs_flush(batch); ctx->launch_grid(ctx, info); fd_batch_flush(batch); diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index a4603f24e12..63c695c0d72 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -53,7 +53,7 @@ get_sample(struct fd_batch *batch, struct fd_ringbuffer *ring, ctx->hw_sample_providers[idx]->get_sample(batch, ring); fd_hw_sample_reference(ctx, &batch->sample_cache[idx], new_samp); util_dynarray_append(&batch->samples, struct fd_hw_sample *, new_samp); - batch->needs_flush = true; + fd_batch_needs_flush(batch); } fd_hw_sample_reference(ctx, &samp, batch->sample_cache[idx]);