From fed476bc947ed5ed167e202ff7e8f0c048b99b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 5 Mar 2025 13:34:45 +0100 Subject: [PATCH] Fix rare deadlock in Vulkan shader compilation. Hopefully won't introduce new problems.. --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 3f45776672..ab98611c59 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -869,21 +869,26 @@ void VulkanRenderManager::EndCurRenderStep() { VkSampleCountFlagBits sampleCount = curRenderStep_->render.framebuffer ? curRenderStep_->render.framebuffer->sampleCount : VK_SAMPLE_COUNT_1_BIT; - compileQueueMutex_.lock(); bool needsCompile = false; for (VKRGraphicsPipeline *pipeline : pipelinesToCheck_) { if (!pipeline) { // Not good, but let's try not to crash. continue; } - std::lock_guard lock(pipeline->mutex_); + std::unique_lock lock(pipeline->mutex_); if (!pipeline->pipeline[(size_t)rpType]) { pipeline->pipeline[(size_t)rpType] = Promise::CreateEmpty(); + lock.unlock(); + _assert_(renderPass); + compileQueueMutex_.lock(); compileQueue_.emplace_back(pipeline, renderPass->Get(vulkan_, rpType, sampleCount), rpType, sampleCount); + compileQueueMutex_.unlock(); needsCompile = true; } } + + compileQueueMutex_.lock(); if (needsCompile) compileCond_.notify_one(); compileQueueMutex_.unlock();