diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index bcde55490b..96ac910e0e 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -581,6 +581,7 @@ void VulkanRenderManager::CompileThreadFunc() { } toCompile = std::move(compileQueue_); compileQueue_.clear(); + compileScheduling_ = true; if (!runCompileThread_) { exitAfterCompile = true; } @@ -626,6 +627,11 @@ void VulkanRenderManager::CompileThreadFunc() { g_threadManager.EnqueueTask(task); } + { + std::unique_lock lock(compileQueueMutex_); + compileScheduling_ = false; + } + if (exitAfterCompile) { break; } @@ -904,6 +910,16 @@ void VulkanRenderManager::ReportBadStateForDraw() { } int VulkanRenderManager::WaitForPipelines() { + // Pipelines still in the queue, or taken off it but not yet made into tasks, aren't in flight yet. + while (true) { + { + std::unique_lock lock(compileQueueMutex_); + if (compileQueue_.empty() && !compileScheduling_) { + break; + } + } + sleep_ms(2, "pipeline-queue-wait"); + } return CreateMultiPipelinesTask::WaitForAll(); } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 42bb5f2dd7..0b19a4c2cb 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -628,6 +628,8 @@ private: std::condition_variable compileCond_; std::mutex compileQueueMutex_; std::vector compileQueue_; + // Set while the compile thread turns a batch it took off compileQueue_ into tasks. + bool compileScheduling_ = false; // Thread for measuring presentation delay. std::thread presentWaitThread_;