rsx: Attempt to fix frame limiter

This commit is contained in:
Elad Ashkenazi 2022-10-08 20:09:01 +03:00 committed by kd-11
parent 3c88477270
commit e0df2c584f
2 changed files with 14 additions and 16 deletions

View File

@ -3401,21 +3401,11 @@ namespace rsx
if (limit)
{
const u64 time = rsx::uclock() - Emu.GetPauseTime();
const u64 needed_us = static_cast<u64>(1000000 / limit);
const u64 time = std::max<u64>(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)

View File

@ -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!");