diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index fba4fdaf82..eaba04faef 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -3401,21 +3401,11 @@ namespace rsx if (limit) { - const u64 time = rsx::uclock() - Emu.GetPauseTime(); const u64 needed_us = static_cast(1000000 / limit); + const u64 time = std::max(get_system_time(), target_rsx_flip_time > needed_us ? target_rsx_flip_time - needed_us : 0); - if (int_flip_index == 0) + if (int_flip_index) { - target_rsx_flip_time = time; - } - else - { - do - { - target_rsx_flip_time += needed_us; - } - while (time >= target_rsx_flip_time + needed_us); - if (target_rsx_flip_time > time + 1000) { const auto delay_us = target_rsx_flip_time - time; @@ -3424,6 +3414,7 @@ namespace rsx } } + target_rsx_flip_time = std::max(time, target_rsx_flip_time) + needed_us; flip_notification_count = 1; } else if (frame_limit == frame_limit_type::_ps3) diff --git a/rpcs3/Emu/RSX/VK/vkutils/sync.cpp b/rpcs3/Emu/RSX/VK/vkutils/sync.cpp index f2ae6b4298..420178bcb2 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/sync.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/sync.cpp @@ -199,7 +199,13 @@ namespace vk VkResult wait_for_event(event* pEvent, u64 timeout) { // Convert timeout to TSC cycles. Timeout accuracy isn't super-important, only fast response when event is signaled (within 10us if possible) - timeout *= (utils::get_tsc_freq() / 1'000'000); + const u64 freq = utils::get_tsc_freq(); + + if (freq) + { + timeout *= (freq / 1'000'000); + } + u64 start = 0; while (true) @@ -217,14 +223,15 @@ namespace vk if (timeout) { + const auto now = freq ? utils::get_tsc() : get_system_time(); + if (!start) { - start = utils::get_tsc(); + start = now; continue; } - if (const auto now = utils::get_tsc(); - (now > start) && + if ((now > start) && (now - start) > timeout) { rsx_log.error("[vulkan] vk::wait_for_event has timed out!");