From 6b8b23c401766b2704eaa0621aea2cbf9a8fad8b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Wed, 23 Feb 2022 01:50:21 +0300 Subject: [PATCH] vk: Drain the label queue before using the CPU fallback to avoid out-of-order signals - This avoids crashes in some game engines which expect RSX semaphores to signal in the order they are submitted. --- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 8deeede81c..9f6a99c269 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1496,24 +1496,25 @@ bool VKGSRender::release_GCM_label(u32 address, u32 args) return false; } + auto drain_label_queue = [this]() + { + while (m_host_data_ptr->last_label_release_event > m_host_data_ptr->commands_complete_event) + { + _mm_pause(); + + if (thread_ctrl::state() == thread_state::aborting) + { + break; + } + } + }; + ensure(m_host_data_ptr); if (m_host_data_ptr->texture_load_complete_event == m_host_data_ptr->texture_load_request_event) { // All texture loads already seen by the host GPU // Wait for all previously submitted labels to be flushed - if (m_host_data_ptr->last_label_release_event > m_host_data_ptr->commands_complete_event) - { - while (m_host_data_ptr->last_label_release_event > m_host_data_ptr->commands_complete_event) - { - _mm_pause(); - - if (thread_ctrl::state() == thread_state::aborting) - { - break; - } - } - } - + drain_label_queue(); return false; } @@ -1525,6 +1526,7 @@ bool VKGSRender::release_GCM_label(u32 address, u32 args) // NVIDIA GPUs can disappoint when DMA blocks straddle VirtualAlloc boundaries. // Take the L and try the fallback. rsx_log.warning("Host label update at 0x%x was not possible.", address); + drain_label_queue(); return false; }