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: d4f8ad27f2 ("zink: handle implicit sync for dmabufs")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33952>
This commit is contained in:
Faith Ekstrand 2025-03-07 15:31:04 -06:00 committed by Marge Bot
parent e538a38017
commit 396ece1ad8

View file

@ -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)