From 51466755ad52d80164f969fffcf1f7ba4699a4d2 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 14 Sep 2022 15:14:44 +0200 Subject: [PATCH] wined3d: Destroy the Vulkan command pool after cleaning up resources. This fixes an issue exposed (but not caused) by commit e553be7e776282fea77b8b60304298d9de90bd8b. Calling vkFreeCommandBuffers() after the corresponding command pool was destroyed causes invalid memory accesses. Thanks to Jacek for pointing this out. --- dlls/wined3d/context_vk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index db1840d29e2..d47f7cf5d1a 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -1684,10 +1684,13 @@ void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) heap_free(context_vk->vk_descriptor_pools); if (context_vk->vk_framebuffer) VK_CALL(vkDestroyFramebuffer(device_vk->vk_device, context_vk->vk_framebuffer, NULL)); - VK_CALL(vkDestroyCommandPool(device_vk->vk_device, context_vk->vk_command_pool, NULL)); if (context_vk->vk_so_counter_bo.vk_buffer) wined3d_context_vk_destroy_bo(context_vk, &context_vk->vk_so_counter_bo); wined3d_context_vk_cleanup_resources(context_vk, VK_NULL_HANDLE); + /* Destroy the command pool after cleaning up resources. In particular, + * this needs to happen after all command buffers are freed, because + * vkFreeCommandBuffers() requires a valid pool handle. */ + VK_CALL(vkDestroyCommandPool(device_vk->vk_device, context_vk->vk_command_pool, NULL)); wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_occlusion_query_pools); wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_timestamp_query_pools); wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_pipeline_statistics_query_pools);