From 417a1986fb17ae3d65bd57a8fb3efea7bda90752 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 21 Feb 2024 16:37:18 -0500 Subject: [PATCH] zink: set and manage a flag indicating that swapchain readback needs updating not currently used, but this is more coherent than relying on other flags Part-of: --- src/gallium/drivers/zink/zink_kopper.c | 9 +++++++++ src/gallium/drivers/zink/zink_kopper.h | 3 +++ src/gallium/drivers/zink/zink_synchronization.cpp | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 23fb14f9010..04a6b1eba54 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -842,6 +842,14 @@ zink_kopper_update_last_written(struct zink_resource *res) res->obj->last_dt_idx = res->obj->dt_idx; } +void +zink_kopper_set_readback_needs_update(struct zink_resource *res) +{ + struct kopper_displaytarget *cdt = res->obj->dt; + struct kopper_swapchain *cswap = cdt->swapchain; + cswap->images[res->obj->dt_idx].readback_needs_update = true; +} + static bool kopper_ensure_readback(struct zink_screen *screen, struct zink_resource *res) { @@ -976,6 +984,7 @@ zink_kopper_readback_update(struct zink_context *ctx, struct zink_resource *res) if (readback) ctx->base.resource_copy_region(&ctx->base, readback, 0, 0, 0, 0, &res->base.b, 0, &box); + cswap->images[res->obj->dt_idx].readback_needs_update = false; } bool diff --git a/src/gallium/drivers/zink/zink_kopper.h b/src/gallium/drivers/zink/zink_kopper.h index d63dcdb0629..698eafab44f 100644 --- a/src/gallium/drivers/zink/zink_kopper.h +++ b/src/gallium/drivers/zink/zink_kopper.h @@ -41,6 +41,7 @@ struct zink_batch_usage; struct kopper_swapchain_image { bool init; + bool readback_needs_update; bool dt_has_data; int age; VkImage image; @@ -163,6 +164,8 @@ int zink_kopper_query_buffer_age(struct pipe_context *pctx, struct pipe_resource *pres); void zink_kopper_prune_batch_usage(struct kopper_displaytarget *cdt, const struct zink_batch_usage *u); +void +zink_kopper_set_readback_needs_update(struct zink_resource *res); #ifdef __cplusplus } diff --git a/src/gallium/drivers/zink/zink_synchronization.cpp b/src/gallium/drivers/zink/zink_synchronization.cpp index 6d83b2eaaaa..d350a9ef280 100644 --- a/src/gallium/drivers/zink/zink_synchronization.cpp +++ b/src/gallium/drivers/zink/zink_synchronization.cpp @@ -515,10 +515,12 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res, if (!flags) flags = access_dst_flags(new_layout); + bool is_write = zink_resource_access_is_write(flags); + if (is_write && zink_is_swapchain(res)) + zink_kopper_set_readback_needs_update(res); if (!res->obj->needs_zs_evaluate && !zink_resource_image_needs_barrier(res, new_layout, flags, pipeline) && (res->queue == zink_screen(ctx->base.screen)->gfx_queue || res->queue == VK_QUEUE_FAMILY_IGNORED)) return; - bool is_write = zink_resource_access_is_write(flags); enum zink_resource_access rw = is_write ? ZINK_RESOURCE_ACCESS_RW : ZINK_RESOURCE_ACCESS_WRITE; bool completed = zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, rw); bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.state);