From 39b1d97beb37dc86daab2393a9b7248a2e1ce459 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 1 Jun 2014 16:20:58 -0700 Subject: [PATCH] Make the lag sync adapt to minor variance. --- Core/HLE/sceDisplay.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 094cdce1dc..cfb418eb56 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -167,11 +167,11 @@ void __DisplayVblankEndCallback(SceUID threadID, SceUID prevCallbackId); int __DisplayGetFlipCount() { return actualFlips; } int __DisplayGetVCount() { return vCount; } -static void ScheduleLagSync() { +static void ScheduleLagSync(int over = 0) { lagSyncScheduled = g_Config.bForceLagSync; if (lagSyncScheduled) { CoreTiming::ScheduleEvent(msToCycles(1), lagSyncEvent, 0); - lastLagSync = real_time_now(); + lastLagSync = real_time_now() - (over / 1000000.0f); } } @@ -702,7 +702,6 @@ void hleLagSync(u64 userdata, int cyclesLate) { scale = g_Config.iFpsLimit / 60.0f; } - // TODO: Smarter, adaptive? Account for cyclesLate? Let's just try this for now. const double goal = lastLagSync + (scale / 1000.0f); time_update(); while (time_now_d() < goal) { @@ -711,7 +710,9 @@ void hleLagSync(u64 userdata, int cyclesLate) { time_update(); } - ScheduleLagSync(); + const int emuOver = (int)cyclesToUs(cyclesLate); + const int over = (int)((time_now_d() - goal) * 1000000); + ScheduleLagSync(over - emuOver); } u32 sceDisplayIsVblank() {