From d5d5f54fe9d9065c2476e520d8007c76f38b1839 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 21 Feb 2024 16:31:10 -0500 Subject: [PATCH] zink: add a swapchain readback case for reading differently-acquired image if a swapchain is shared between multiple resources, a deadlock and/or invalid data will result from readback attempts if one resource holds a swapchain image that the other resource must read from to avoid this, allow accessing the acquiring resource directly since this is the only sane way to perform readback Part-of: --- src/gallium/drivers/zink/zink_kopper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index a61720b18e0..b094aa4922b 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -873,6 +873,11 @@ zink_kopper_acquire_readback(struct zink_context *ctx, struct zink_resource *res *readback = res; return false; } + if (cswap->images[last_dt_idx].acquired) { + struct zink_resource *rb = cswap->images[last_dt_idx].acquired; + *readback = rb; + return false; + } if (cswap->images[last_dt_idx].readback) { struct zink_resource *rb = zink_resource(cswap->images[res->obj->last_dt_idx].readback); if (rb->valid) {