From 3a0888c62fa3ebcce0494e3e07451fa9aa26b9df Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 18 Jan 2022 17:40:56 -0500 Subject: [PATCH] zink: fix waiting on current batch id - the current batch id is always 0 - there is always a current batch - a batch id can only be set at the time of submit thus when passing 0 to wait on the current batch, the submit must complete so that there is a batch id, and this must occur before the timeline wait path or else the timeline wait does nothing cc: mesa-stable Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 86fb7c8d045..56ca890c395 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -3109,11 +3109,15 @@ zink_fence_wait(struct pipe_context *pctx) void zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id) { - struct zink_batch_state *bs = ctx->batch.state; - assert(bs); - if (!batch_id || bs->fence.batch_id == batch_id) + struct zink_batch_state *bs; + if (!batch_id) { /* not submitted yet */ flush_batch(ctx, true); + bs = zink_batch_state(ctx->last_fence); + assert(bs); + batch_id = bs->fence.batch_id; + } + assert(batch_id); if (ctx->have_timelines) { if (!zink_screen_timeline_wait(zink_screen(ctx->base.screen), batch_id, UINT64_MAX)) check_device_lost(ctx); @@ -3122,8 +3126,8 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id) simple_mtx_lock(&ctx->batch_mtx); struct zink_fence *fence; - assert(batch_id || ctx->last_fence); - if (ctx->last_fence && (!batch_id || batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id)) + assert(ctx->last_fence); + if (batch_id == zink_batch_state(ctx->last_fence)->fence.batch_id) fence = ctx->last_fence; else { for (bs = ctx->batch_states; bs; bs = bs->next) {