diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index b781784e77..1ab65831f7 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -294,7 +294,11 @@ void VulkanRenderManager::StopThread() { INFO_LOG(G3D, "Vulkan submission thread joined. Frame=%d", vulkan_->GetCurFrame()); - compileCond_.notify_all(); + if (compileThread_.joinable()) { + // Lock to avoid race conditions. + std::lock_guard guard(compileMutex_); + compileCond_.notify_all(); + } compileThread_.join(); INFO_LOG(G3D, "Vulkan compiler thread joined."); @@ -352,7 +356,7 @@ void VulkanRenderManager::CompileThreadFunc() { std::vector toCompile; { std::unique_lock lock(compileMutex_); - if (compileQueue_.empty()) { + if (compileQueue_.empty() && run_) { compileCond_.wait(lock); } toCompile = std::move(compileQueue_);