From 114a5da7905520ec8626beee885572dc386a383c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 21 Feb 2024 16:35:05 -0500 Subject: [PATCH] zink: update swapchain readback cache on create ensure this can be used immediately Part-of: --- src/gallium/drivers/zink/zink_kopper.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 6bac2be9341..23fb14f9010 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -842,7 +842,7 @@ zink_kopper_update_last_written(struct zink_resource *res) res->obj->last_dt_idx = res->obj->dt_idx; } -static void +static bool kopper_ensure_readback(struct zink_screen *screen, struct zink_resource *res) { struct kopper_displaytarget *cdt = res->obj->dt; @@ -850,11 +850,12 @@ kopper_ensure_readback(struct zink_screen *screen, struct zink_resource *res) for (unsigned i = 0; i < cswap->num_images; i++) { if (cswap->images[i].readback) - return; + return false; struct pipe_resource templ = res->base.b; templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; cswap->images[i].readback = screen->base.resource_create(&screen->base, &templ); } + return true; } bool @@ -867,8 +868,10 @@ zink_kopper_acquire_readback(struct zink_context *ctx, struct zink_resource *res uint32_t last_dt_idx = res->obj->last_dt_idx; VkResult ret = VK_SUCCESS; - if (++cdt->readback_counter >= ZINK_READBACK_THRESHOLD) - kopper_ensure_readback(screen, res); + if (++cdt->readback_counter >= ZINK_READBACK_THRESHOLD) { + if (kopper_ensure_readback(screen, res)) + zink_kopper_readback_update(ctx, res); + } /* if this hasn't been presented or if it has data, use this as the readback target */ if (res->obj->last_dt_idx == UINT32_MAX || (res->obj->dt_idx != UINT32_MAX && cdt->swapchain->images[res->obj->dt_idx].age)) {