mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
core, fix race condition when waiting for vsync
This commit is contained in:
parent
e704c9b913
commit
3368c27707
1 changed files with 3 additions and 2 deletions
|
@ -1358,6 +1358,7 @@ static void emu_loop_prep(void)
|
|||
/* our tick here is 1 us right now */
|
||||
#define ms_to_ticks(x) (unsigned int)(x * 1000)
|
||||
#define get_ticks() plat_get_ticks_us()
|
||||
#define vsync_delay_x3 3*ms_to_ticks(1)
|
||||
|
||||
void emu_loop(void)
|
||||
{
|
||||
|
@ -1512,13 +1513,13 @@ void emu_loop(void)
|
|||
diff = timestamp_aim_x3 - timestamp * 3;
|
||||
|
||||
// sleep or vsync if we are still too fast
|
||||
if (diff > target_frametime_x3 && (currentConfig.EmuOpt & EOPT_VSYNC)) {
|
||||
if (diff > target_frametime_x3 + vsync_delay_x3 && (currentConfig.EmuOpt & EOPT_VSYNC)) {
|
||||
// we are too fast
|
||||
plat_video_wait_vsync();
|
||||
timestamp = get_ticks();
|
||||
diff = timestamp * 3 - timestamp_aim_x3;
|
||||
}
|
||||
if (diff > target_frametime_x3) {
|
||||
if (diff > target_frametime_x3 + vsync_delay_x3) {
|
||||
// still too fast
|
||||
plat_wait_till_us(timestamp + (diff - target_frametime_x3) / 3);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue