From 41f5158247a9bcf087b397501b5a0619d665026b Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 28 Feb 2021 22:00:46 +0300 Subject: [PATCH] vk: Sync main pipe with async jobs if any --- rpcs3/Emu/RSX/VK/VKDraw.cpp | 8 ++++++++ rpcs3/Emu/RSX/VK/vkutils/sync.cpp | 6 ++++++ rpcs3/Emu/RSX/VK/vkutils/sync.h | 1 + 3 files changed, 15 insertions(+) diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index bc6ff03ae3..a2371c36d1 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "../Common/BufferUtils.h" #include "../rsx_methods.h" + +#include "VKAsyncScheduler.h" #include "VKGSRender.h" #include "vkutils/buffer_object.h" @@ -960,6 +962,12 @@ void VKGSRender::end() load_program_env(); m_frame_stats.setup_time += m_profiler.duration(); + // Sync any async scheduler tasks + if (auto ev = g_fxo->get()->get_primary_sync_label()) + { + ev->gpu_wait(*m_current_command_buffer); + } + if (!m_shader_interpreter.is_interpreter(m_program)) [[likely]] { bind_texture_env(); diff --git a/rpcs3/Emu/RSX/VK/vkutils/sync.cpp b/rpcs3/Emu/RSX/VK/vkutils/sync.cpp index 757080541b..ae30540961 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/sync.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/sync.cpp @@ -122,6 +122,12 @@ namespace vk vkSetEvent(m_device, m_vk_event); } + void event::gpu_wait(const command_buffer& cmd) const + { + ensure(m_vk_event); + vkCmdWaitEvents(cmd, 1, &m_vk_event, 0, 0, 0, nullptr, 0, nullptr, 0, nullptr); + } + void event::reset() const { if (m_vk_event) [[likely]] diff --git a/rpcs3/Emu/RSX/VK/vkutils/sync.h b/rpcs3/Emu/RSX/VK/vkutils/sync.h index 822781bbad..807546aea5 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/sync.h +++ b/rpcs3/Emu/RSX/VK/vkutils/sync.h @@ -46,6 +46,7 @@ namespace vk void signal(const command_buffer& cmd, VkPipelineStageFlags stages, VkAccessFlags access); void host_signal() const; + void gpu_wait(const command_buffer& cmd) const; VkResult status() const; void reset() const; };