From 9b7625f03e96cccf4733b700f16c56e0b0fae42e Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 13 Mar 2025 19:08:35 -0300 Subject: [PATCH] Remove the need for waitIdle from Vulkan. --- UnleashedRecomp/gpu/video.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index e24ce4d..f9ba682 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -1973,23 +1973,21 @@ void Video::WaitForGPU() { g_waitForGPUCount++; - if (g_vulkan) + // Wait for all queue frames to finish. + for (size_t i = 0; i < NUM_FRAMES; i++) { - g_device->waitIdle(); - } - else - { - for (size_t i = 0; i < NUM_FRAMES; i++) + if (g_commandListStates[i]) { - if (g_commandListStates[i]) - { - g_queue->waitForCommandFence(g_commandFences[i].get()); - g_commandListStates[i] = false; - } + g_queue->waitForCommandFence(g_commandFences[i].get()); + g_commandListStates[i] = false; } - g_queue->executeCommandLists(nullptr, g_commandFences[0].get()); - g_queue->waitForCommandFence(g_commandFences[0].get()); } + + // Execute an empty command list and wait for it to end to guarantee that any remaining presentation has finished. + g_commandLists[0]->begin(); + g_commandLists[0]->end(); + g_queue->executeCommandLists(g_commandLists[0].get(), g_commandFences[0].get()); + g_queue->waitForCommandFence(g_commandFences[0].get()); } static uint32_t CreateDevice(uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5, be* a6)