zink: prune old swapchains on present

pruning old swapchains is challenging because there's no way to definitively
know when to destroy them without VK_EXT_swapchain_maintenance1 which isn't
supported yet

initially, I handled it by only pruning on shutdown and whenever a new swapchain
was created since those are both safe points, but this leads to scenarios where
a dead swapchain can exist for the entire lifetime of an application
if the swapinterval is changed

to avoid such ballooning, check whether the current swapchain has ever presented
on each present queue and then prune based on this

fixes #7529

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20588>
This commit is contained in:
Mike Blumenkrantz
2023-01-09 13:51:16 -05:00
committed by Marge Bot
parent 6b0db6bf8b
commit dc8c9d2056

View File

@@ -745,6 +745,11 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
struct kopper_displaytarget *cdt = res->obj->dt;
assert(zink_kopper_acquired(res->obj->dt, res->obj->dt_idx));
assert(res->obj->present);
/* always try to prune if the current swapchain has seen presents */
if (cdt->swapchain->last_present != UINT32_MAX)
prune_old_swapchains(screen, cdt, false);
struct kopper_present_info *cpi = malloc(sizeof(struct kopper_present_info));
cpi->sem = res->obj->present;
cpi->res = res;