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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27553>
(cherry picked from commit d2ed77072cfa354862843789f30b7702feeb9c70)
This commit is contained in:
Mike Blumenkrantz 2024-02-09 10:47:46 -05:00 committed by Eric Engestrom
parent cf0ed80d3a
commit 20cc365eb2
3 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -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,