From d476a8c07b5ababa94b6f02cb4b0a71f0d6c5caf Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 6 Aug 2025 14:01:41 -0400 Subject: [PATCH] zink: stop always syncing threaded flushes async flushes are meant to be async here, and the other ones are manually synced later in the function Part-of: --- src/gallium/drivers/zink/zink_context.c | 2 +- src/gallium/drivers/zink/zink_fence.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 8a47f99e71e..ce07e65ee69 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -4078,7 +4078,7 @@ zink_flush(struct pipe_context *pctx, if (deferred && !(flags & PIPE_FLUSH_FENCE_FD) && pfence) deferred_fence = true; else - flush_batch(ctx, true); + flush_batch(ctx, false); } if (pfence) { diff --git a/src/gallium/drivers/zink/zink_fence.c b/src/gallium/drivers/zink/zink_fence.c index f28d335aecf..1c107a2182e 100644 --- a/src/gallium/drivers/zink/zink_fence.c +++ b/src/gallium/drivers/zink/zink_fence.c @@ -129,11 +129,18 @@ tc_fence_finish(struct zink_context *ctx, struct zink_tc_fence *mfence, uint64_t static bool fence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeout_ns) { + struct zink_batch_state *bs = zink_batch_state(fence); if (screen->device_lost) return true; if (p_atomic_read(&fence->completed)) return true; + if (screen->threaded_submit) { + int64_t abs_timeout = os_time_get_absolute_timeout(timeout_ns); + if (!util_queue_fence_wait_timeout(&bs->flush_completed, abs_timeout)) + return false; + } + assert(fence->batch_id); assert(fence->submitted); @@ -141,7 +148,7 @@ fence_wait(struct zink_screen *screen, struct zink_fence *fence, uint64_t timeou if (success) { p_atomic_set(&fence->completed, true); - zink_batch_state(fence)->usage.usage = 0; + bs->usage.usage = 0; zink_screen_update_last_finished(screen, fence->batch_id); } return success;