mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
rsx: Improve VBLANK accuracy
This commit is contained in:
parent
571bdfc828
commit
dcb2e8cd9e
@ -629,12 +629,13 @@ namespace rsx
|
|||||||
// TODO: exit condition
|
// TODO: exit condition
|
||||||
while (!is_stopped())
|
while (!is_stopped())
|
||||||
{
|
{
|
||||||
|
const u64 current = get_system_time();
|
||||||
const u64 period_time = 1000000 / g_cfg.video.vblank_rate;
|
const u64 period_time = 1000000 / g_cfg.video.vblank_rate;
|
||||||
const u64 wait_sleep = period_time - u64{period_time >= host_min_quantum} * host_min_quantum;
|
const u64 wait_for = period_time - std::min<u64>(current - start_time, period_time);
|
||||||
|
const u64 wait_sleep = wait_for - u64{wait_for >= host_min_quantum} * host_min_quantum;
|
||||||
|
|
||||||
if (get_system_time() - start_time >= period_time)
|
if (!wait_for)
|
||||||
{
|
{
|
||||||
do
|
|
||||||
{
|
{
|
||||||
start_time += period_time;
|
start_time += period_time;
|
||||||
vblank_count++;
|
vblank_count++;
|
||||||
@ -658,10 +659,14 @@ namespace rsx
|
|||||||
sys_rsx_context_attribute(0x55555555, 0xFED, 1, 0, 0, 0);
|
sys_rsx_context_attribute(0x55555555, 0xFED, 1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (get_system_time() - start_time >= period_time);
|
}
|
||||||
|
else if (wait_sleep)
|
||||||
|
{
|
||||||
thread_ctrl::wait_for(wait_sleep);
|
thread_ctrl::wait_for(wait_sleep);
|
||||||
continue;
|
}
|
||||||
|
else if (wait_for >= host_min_quantum / 3 * 2)
|
||||||
|
{
|
||||||
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emu.IsPaused())
|
if (Emu.IsPaused())
|
||||||
@ -677,8 +682,6 @@ namespace rsx
|
|||||||
// Restore difference
|
// Restore difference
|
||||||
start_time = get_system_time() - start_time;
|
start_time = get_system_time() - start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_ctrl::wait_for(100);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user