mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
freedreno: Consolidate needs_flush and clearing last_fence
Add a helper to both set batch->needs_flush and clear ctx->last_fence so
that the two related bits of state do not get out of sync.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10599>
(cherry picked from commit a9c9a9938d)
This commit is contained in:
parent
ce7f58e333
commit
c49609352c
7 changed files with 29 additions and 22 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue