From 396ece1ad8f582eb39c9cbf4032f7298a9f67022 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 7 Mar 2025 15:31:04 -0600 Subject: [PATCH] zink: Set needs_barrier after transitioning to QUEUE_FAMILY_FOREIGN Otherwise, we'll transition to QUEUE_FAMILY_FOREIGN and then forget that we left it on the foreign queue and never transition back the next time we use the resource. This was kind-of okay with Wayland compositors because they always re-import the BO so it's always fresh and they pick up on the queue transfer the first time. X11, on the other hand, does not re-import BOs so they get stuck in this weird QUEUE_FAMILY_FOREIGN limbo until something happens to randomly trigger a layout transition check and then we find it and do the transition. We should mark them as needing a barrier the moment we transition to QUEUE_FAMILY_FOREIGN. Fixes: d4f8ad27f2d7 ("zink: handle implicit sync for dmabufs") Reviewed-by: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_batch.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 457a686b297..c7e746829ed 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -891,6 +891,15 @@ zink_end_batch(struct zink_context *ctx) } res->queue = VK_QUEUE_FAMILY_FOREIGN_EXT; + /* We just transitioned to VK_QUEUE_FAMILY_FOREIGN_EXT. We'll need a + * barrier to transition back to our queue before we can use this + * resource again. Set need_barriers if bound. + */ + for (unsigned i = 0; i < ARRAY_SIZE(ctx->need_barriers); i++) { + if (res->bind_count[i]) + _mesa_set_add(ctx->need_barriers[i], res); + } + for (; res; res = zink_resource(res->base.b.next)) { VkSemaphore sem = zink_create_exportable_semaphore(screen); if (sem)