From d862cb00247113195b621f6f7d1350fbf072bab4 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 2 Apr 2024 21:11:23 +0200 Subject: [PATCH] zink: ctx->last_fence really wants to be a batch_state, so accomodate it Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/zink/zink_batch.c | 14 +++++++------- src/gallium/drivers/zink/zink_context.c | 12 ++++++------ src/gallium/drivers/zink/zink_screen.c | 4 ++-- src/gallium/drivers/zink/zink_types.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index b3f72018720..6da1d571c74 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -251,8 +251,8 @@ pop_batch_state(struct zink_context *ctx) const struct zink_batch_state *bs = ctx->batch_states; ctx->batch_states = bs->next; ctx->batch_states_count--; - if (ctx->last_fence == &bs->fence) - ctx->last_fence = NULL; + if (ctx->last_batch_state == bs) + ctx->last_batch_state = NULL; } /* reset all batch states and append to the free state list @@ -554,8 +554,8 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch) ); batch->state->fence.completed = false; - if (ctx->last_fence) { - struct zink_batch_state *last_state = zink_batch_state(ctx->last_fence); + if (ctx->last_batch_state) { + struct zink_batch_state *last_state = ctx->last_batch_state; batch->last_batch_usage = &last_state->usage; } @@ -812,13 +812,13 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch) } bs = batch->state; - if (ctx->last_fence) - zink_batch_state(ctx->last_fence)->next = bs; + if (ctx->last_batch_state) + ctx->last_batch_state->next = bs; else { assert(!ctx->batch_states); ctx->batch_states = bs; } - ctx->last_fence = &bs->fence; + ctx->last_batch_state = bs; ctx->batch_states_count++; batch->work_count = 0; diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 93dc632e82c..1e6671b4350 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -3386,8 +3386,8 @@ static void stall(struct zink_context *ctx) { struct zink_screen *screen = zink_screen(ctx->base.screen); - sync_flush(ctx, zink_batch_state(ctx->last_fence)); - zink_screen_timeline_wait(screen, ctx->last_fence->batch_id, OS_TIMEOUT_INFINITE); + sync_flush(ctx, ctx->last_batch_state); + zink_screen_timeline_wait(screen, ctx->last_batch_state->fence.batch_id, OS_TIMEOUT_INFINITE); zink_batch_reset_all(ctx); } @@ -3914,10 +3914,10 @@ zink_flush(struct pipe_context *pctx, if (!batch->has_work) { if (pfence) { /* reuse last fence */ - fence = ctx->last_fence; + fence = &ctx->last_batch_state->fence; } if (!deferred) { - struct zink_batch_state *last = zink_batch_state(ctx->last_fence); + struct zink_batch_state *last = ctx->last_batch_state; if (last) { sync_flush(ctx, last); if (last->is_device_lost) @@ -3984,7 +3984,7 @@ zink_fence_wait(struct pipe_context *pctx) if (ctx->batch.has_work) pctx->flush(pctx, NULL, PIPE_FLUSH_HINT_FINISH); - if (ctx->last_fence) + if (ctx->last_batch_state) stall(ctx); } @@ -3995,7 +3995,7 @@ zink_wait_on_batch(struct zink_context *ctx, uint64_t batch_id) if (!batch_id) { /* not submitted yet */ flush_batch(ctx, true); - bs = zink_batch_state(ctx->last_fence); + bs = ctx->last_batch_state; assert(bs); batch_id = bs->fence.batch_id; } diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index dfc900e5a86..328cea2fa03 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1844,8 +1844,8 @@ zink_flush_frontbuffer(struct pipe_screen *pscreen, if (ctx->batch.swapchain || ctx->needs_present) { ctx->batch.has_work = true; pctx->flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME); - if (ctx->last_fence && screen->threaded_submit) { - struct zink_batch_state *bs = zink_batch_state(ctx->last_fence); + if (ctx->last_batch_state && screen->threaded_submit) { + struct zink_batch_state *bs = ctx->last_batch_state; util_queue_fence_wait(&bs->flush_completed); } } diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 7fe4b839dbb..dd8f8c19625 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1807,7 +1807,7 @@ struct zink_context { struct util_queue_fence flush_fence; //unsigned during flush (blocks unsync ops) struct zink_fence *deferred_fence; - struct zink_fence *last_fence; //the last command buffer submitted + struct zink_batch_state *last_batch_state; //the last command buffer submitted struct zink_batch_state *batch_states; //list of submitted batch states: ordered by increasing timeline id unsigned batch_states_count; //number of states in `batch_states` struct zink_batch_state *free_batch_states; //unused batch states