From 14df131f8f1ff866f9bcd8946c945de18003762d Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 13 Apr 2023 17:06:35 -0400 Subject: [PATCH] zink: always defer query pool deletion this feels dumb, but I can't think of a simpler way to do it that would more accurately handle deletion while also guaranteeing pool longevity Fixes: 7da78ffb697 ("zink: create/use query pools dynamically") Part-of: (cherry picked from commit 7119a344f3db5820041dfcdf23ebcbf15121f467) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_batch.c | 5 +++++ src/gallium/drivers/zink/zink_query.c | 2 +- src/gallium/drivers/zink/zink_types.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index db856f673ae..6bfa5ebdb14 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -715,7 +715,7 @@ "description": "zink: always defer query pool deletion", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "7da78ffb697bfea5c20b31dca635971d00d27b3c" }, diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index cdcce9197c9..7425159884e 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -111,6 +111,9 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs) struct zink_query *query = (void*)entry->key; zink_prune_query(screen, bs, query); } + util_dynarray_foreach(&bs->dead_querypools, VkQueryPool, pool) + VKSCR(DestroyQueryPool)(screen->dev, *pool, NULL); + util_dynarray_clear(&bs->dead_querypools); /* framebuffers are appended to the batch state in which they are destroyed * to ensure deferred deletion without destroying in-use objects @@ -267,6 +270,7 @@ zink_batch_state_destroy(struct zink_screen *screen, struct zink_batch_state *bs free(bs->real_objs.objs); free(bs->slab_objs.objs); free(bs->sparse_objs.objs); + util_dynarray_fini(&bs->dead_querypools); util_dynarray_fini(&bs->swapchain_obj); util_dynarray_fini(&bs->zombie_samplers); util_dynarray_fini(&bs->dead_framebuffers); @@ -327,6 +331,7 @@ create_batch_state(struct zink_context *ctx) SET_CREATE_OR_FAIL(&bs->programs); SET_CREATE_OR_FAIL(&bs->active_queries); util_dynarray_init(&bs->wait_semaphores, NULL); + util_dynarray_init(&bs->dead_querypools, NULL); util_dynarray_init(&bs->wait_semaphore_stages, NULL); util_dynarray_init(&bs->zombie_samplers, NULL); util_dynarray_init(&bs->dead_framebuffers, NULL); diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index ee8e931f28a..3777a9dea93 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -387,7 +387,7 @@ unref_vk_pool(struct zink_context *ctx, struct zink_query_pool *pool) { if (!pool || --pool->refcount) return; - VKCTX(DestroyQueryPool)(zink_screen(ctx->base.screen)->dev, pool->query_pool, NULL); + util_dynarray_append(&ctx->batch.state->dead_querypools, VkQueryPool, pool->query_pool); if (list_is_linked(&pool->list)) list_del(&pool->list); FREE(pool); diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 67bbe0d06fb..d045b252248 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -596,6 +596,7 @@ struct zink_batch_state { struct util_dynarray dead_framebuffers; struct set active_queries; /* zink_query objects which were active at some point in this batch */ + struct util_dynarray dead_querypools; struct zink_batch_descriptor_data dd;