From 874535752b497bd8ab49cf97add6de2ed9b16f81 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 19 Apr 2021 15:49:54 -0400 Subject: [PATCH] zink: force scanout sync when mapping scanout resource this is just for unit tests where the scanout object is redundant and the only time a flush occurs is from stalling on readback Fixes: 104603fa763 ("zink: create separate linear tiling image for scanout") Acked-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/zink/zink_resource.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index efd7a6e5df8..f9aae49ee55 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1003,8 +1003,17 @@ zink_transfer_map(struct pipe_context *pctx, if (usage & PIPE_MAP_READ) { zink_transfer_copy_bufimage(ctx, staging_res, res, trans); + /* TODO: remove for wsi */ + struct zink_resource *scanout = NULL; + if (res->scanout_obj) { + scanout = ctx->flush_res; + ctx->flush_res = res; + } /* need to wait for rendering to finish */ zink_fence_wait(pctx); + /* TODO: remove for wsi */ + if (res->scanout_obj) + ctx->flush_res = scanout; } ptr = base = map_resource(screen, staging_res); @@ -1019,10 +1028,19 @@ zink_transfer_map(struct pipe_context *pctx, if (zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_READ)) resource_sync_reads(ctx, res); if (zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_RW)) { + /* TODO: remove for wsi */ + struct zink_resource *scanout = NULL; + if (res->scanout_obj) { + scanout = ctx->flush_res; + ctx->flush_res = res; + } if (usage & PIPE_MAP_READ) resource_sync_writes_from_batch_usage(ctx, res); else zink_fence_wait(pctx); + /* TODO: remove for wsi */ + if (res->scanout_obj) + ctx->flush_res = scanout; } VkImageSubresource isr = { res->aspect,