From fe7b573a380ca31ac028fa7bf05b37f6cb2137ba Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 9 Dec 2021 23:52:10 -0800 Subject: [PATCH] Vulkan: Fix use-after-free on shutdown. --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 2 +- GPU/Vulkan/PipelineManagerVulkan.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index e952bcaca4ff..90e7a759e1a4 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -449,7 +449,7 @@ void VulkanRenderManager::CompileThreadFunc() { if (!run_) { break; } - for (auto entry : toCompile) { + for (auto &entry : toCompile) { switch (entry.type) { case CompileQueueEntry::Type::GRAPHICS: entry.graphics->Create(vulkan_); diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 27e34dd3c7a6..3d79c9173ca9 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -37,7 +37,10 @@ void PipelineManagerVulkan::Clear() { if (value->pipeline) { VkPipeline pipeline = value->pipeline->pipeline; vulkan_->Delete().QueueDeletePipeline(pipeline); - delete value->pipeline; + vulkan_->Delete().QueueCallback([](void *p) { + VKRGraphicsPipeline *pipeline = (VKRGraphicsPipeline *)p; + delete pipeline; + }, value->pipeline); } else { // Something went wrong. ERROR_LOG(G3D, "Null pipeline found in PipelineManagerVulkan::Clear - didn't wait for asyncs?");