zink: ctx->last_fence really wants to be a batch_state, so accomodate it

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28560>
This commit is contained in:
Gert Wollny
2024-04-02 21:11:23 +02:00
committed by Marge Bot
parent 98f3d072b4
commit d862cb0024
4 changed files with 16 additions and 16 deletions
+7 -7
View File
@@ -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;
+6 -6
View File
@@ -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;
}
+2 -2
View File
@@ -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);
}
}
+1 -1
View File
@@ -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