From f46f128278b1961976f958309d89738248c06d8c Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 29 Jul 2021 04:40:13 +0000 Subject: [PATCH] vkr: wait for device idle before device destruction This is also to prepare for destroying device level objects here. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Reviewed-by: Ryan Neph --- src/vkr_renderer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vkr_renderer.c b/src/vkr_renderer.c index 1f3d64b..e2849b5 100644 --- a/src/vkr_renderer.c +++ b/src/vkr_renderer.c @@ -2034,6 +2034,11 @@ vkr_dispatch_vkDestroyDevice(struct vn_dispatch_context *dispatch, return; } + VkDevice device = dev->base.handle.device; + VkResult ret = vkDeviceWaitIdle(device); + if (ret != VK_SUCCESS) + vrend_printf("vkDeviceWaitIdle(%p) failed(%d)", dev, (int32_t)ret); + /* TODO cleanup all objects here? */ struct vkr_queue *queue, *queue_tmp; LIST_FOR_EACH_ENTRY_SAFE (queue, queue_tmp, &dev->queues, head) @@ -2047,8 +2052,7 @@ vkr_dispatch_vkDestroyDevice(struct vn_dispatch_context *dispatch, mtx_destroy(&dev->free_sync_mutex); - vn_replace_vkDestroyDevice_args_handle(args); - vkDestroyDevice(args->device, NULL); + vkDestroyDevice(device, NULL); util_hash_table_remove_u64(ctx->object_table, dev->base.id); }