From 20cc365eb2ea772a649b628fb5bc2180ab226981 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 9 Feb 2024 10:47:46 -0500 Subject: [PATCH] zink: flag acquired swapchain image as readback target on acquire, not present readback should trigger on the current backbuffer, not the most recently presented buffer. if e.g., a clear is only triggered through glFlush, this clear should be read back rather than the contents of the last-presented buffer cc: mesa-stable Part-of: (cherry picked from commit d2ed77072cfa354862843789f30b7702feeb9c70) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_kopper.c | 10 +++++++++- src/gallium/drivers/zink/zink_kopper.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 940214c187b..423addecea4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -184,7 +184,7 @@ "description": "zink: flag acquired swapchain image as readback target on acquire, not present", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 5fd6fd44369..b4f3e71a4bd 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -561,6 +561,8 @@ kopper_acquire(struct zink_screen *screen, struct zink_resource *res, uint64_t t if (cdt->swapchain->images[res->obj->dt_idx].readback) zink_resource(cdt->swapchain->images[res->obj->dt_idx].readback)->valid = false; res->obj->image = cdt->swapchain->images[res->obj->dt_idx].image; + if (!cdt->age_locked) + zink_kopper_update_last_written(res); cdt->swapchain->images[res->obj->dt_idx].acquired = false; if (!cdt->swapchain->images[res->obj->dt_idx].init) { /* swapchain images are initially in the UNDEFINED layout */ @@ -792,7 +794,7 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res) cpi->res = res; cpi->swapchain = cdt->swapchain; cpi->indefinite_acquire = res->obj->indefinite_acquire; - res->obj->last_dt_idx = cpi->image = res->obj->dt_idx; + cpi->image = res->obj->dt_idx; cpi->info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; cpi->info.pNext = NULL; cpi->info.waitSemaphoreCount = 1; @@ -834,6 +836,12 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res) res->obj->dt_idx = UINT32_MAX; } +void +zink_kopper_update_last_written(struct zink_resource *res) +{ + res->obj->last_dt_idx = res->obj->dt_idx; +} + static void kopper_ensure_readback(struct zink_screen *screen, struct zink_resource *res) { diff --git a/src/gallium/drivers/zink/zink_kopper.h b/src/gallium/drivers/zink/zink_kopper.h index 24614bbe376..2ebf9f3b212 100644 --- a/src/gallium/drivers/zink/zink_kopper.h +++ b/src/gallium/drivers/zink/zink_kopper.h @@ -121,6 +121,9 @@ zink_kopper_acquired(const struct kopper_displaytarget *cdt, uint32_t idx) return idx != UINT32_MAX && cdt->swapchain->images[idx].acquired; } +void +zink_kopper_update_last_written(struct zink_resource *res); + struct kopper_displaytarget * zink_kopper_displaytarget_create(struct zink_screen *screen, unsigned tex_usage, enum pipe_format format, unsigned width,