From 00a4dc57ce2fa1b757768a3e2863d63b6a0ce685 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 29 Aug 2022 11:40:50 -0400 Subject: [PATCH] zink: defer acquire semaphore destruction these have noticeable overhead, so handle them in the submit thread Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/zink/zink_batch.c | 8 ++++++-- src/gallium/drivers/zink/zink_types.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index e64549d2182..3fa4450b471 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -92,8 +92,8 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs) util_dynarray_clear(&bs->wait_semaphore_stages); bs->present = VK_NULL_HANDLE; - while (util_dynarray_contains(&bs->acquires, VkSemaphore)) - VKSCR(DestroySemaphore)(screen->dev, util_dynarray_pop(&bs->acquires, VkSemaphore), NULL); + memcpy(&bs->unref_semaphores, &bs->acquires, sizeof(struct util_dynarray)); + util_dynarray_init(&bs->acquires, NULL); bs->swapchain = NULL; while (util_dynarray_contains(&bs->dead_swapchains, VkImageView)) @@ -119,6 +119,8 @@ unref_resources(struct zink_screen *screen, struct zink_batch_state *bs) struct zink_resource_object *obj = util_dynarray_pop(&bs->unref_resources, struct zink_resource_object*); zink_resource_object_reference(screen, &obj, NULL); } + while (util_dynarray_contains(&bs->unref_semaphores, VkSemaphore)) + VKSCR(DestroySemaphore)(screen->dev, util_dynarray_pop(&bs->unref_semaphores, VkSemaphore), NULL); } void @@ -179,6 +181,7 @@ zink_batch_state_destroy(struct zink_screen *screen, struct zink_batch_state *bs util_dynarray_fini(&bs->bindless_releases[0]); util_dynarray_fini(&bs->bindless_releases[1]); util_dynarray_fini(&bs->acquires); + util_dynarray_fini(&bs->unref_semaphores); util_dynarray_fini(&bs->acquire_flags); util_dynarray_fini(&bs->dead_swapchains); zink_batch_descriptor_deinit(screen, bs); @@ -236,6 +239,7 @@ create_batch_state(struct zink_context *ctx) util_dynarray_init(&bs->persistent_resources, NULL); util_dynarray_init(&bs->unref_resources, NULL); util_dynarray_init(&bs->acquires, NULL); + util_dynarray_init(&bs->unref_semaphores, NULL); util_dynarray_init(&bs->acquire_flags, NULL); util_dynarray_init(&bs->dead_swapchains, NULL); util_dynarray_init(&bs->bindless_releases[0], NULL); diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index aa0bea6ada2..3d953f11577 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -433,6 +433,7 @@ struct zink_batch_state { struct util_dynarray acquires; struct util_dynarray acquire_flags; struct util_dynarray dead_swapchains; + struct util_dynarray unref_semaphores; struct util_queue_fence flush_completed;