From b7a0265c27ad754ecb4cb4e3a97dbb63ae85b050 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 8 Apr 2021 10:08:00 -0400 Subject: [PATCH] zink: handle checking batch completion from other contexts without timelines if a batch state can't be found, it may exist on a different context, so the screen value needs to be checked if the screen value indicates that the batch hasn't completed and we're waiting, force a flush so there's a fence that can be waited upon Reviewed-by: Erik Faye-Lund Tested-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/zink/zink_context.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 68c997debeb..de0f1ea8b8d 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -2067,9 +2067,14 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id) fence = ctx->last_fence; else { struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&ctx->batch_states, batch_id, (void*)(uintptr_t)batch_id); - /* if we can't find it, it must have finished already */ if (!he) { simple_mtx_unlock(&ctx->batch_mtx); + /* if we can't find it, it either must have finished already or is on a different context */ + if (!zink_screen_check_last_finished(zink_screen(ctx->base.screen), batch_id)) { + /* if it hasn't finished, it's on another context, so force a flush so there's something to wait on */ + ctx->batch.has_work = true; + zink_fence_wait(&ctx->base); + } return; } fence = he->data; @@ -2103,10 +2108,11 @@ zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id) fence = ctx->last_fence; else { struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&ctx->batch_states, batch_id, (void*)(uintptr_t)batch_id); - /* if we can't find it, it must have finished already */ + /* if we can't find it, it either must have finished already or is on a different context */ if (!he) { simple_mtx_unlock(&ctx->batch_mtx); - return true; + /* return compare against last_finished, since this has info from all contexts */ + return zink_screen_check_last_finished(zink_screen(ctx->base.screen), batch_id); } fence = he->data; }