From 687b5f92b162f7206bfba3222b69c0782628980d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 20 Apr 2018 11:01:33 +0200 Subject: [PATCH 1/2] Limit the flip delay in the other direction to try to work around #10763. --- Core/CoreTiming.cpp | 1 + Core/HLE/sceDisplay.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 78ca1d2fb8c8..5cebf2f3a56e 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -585,6 +585,7 @@ void Advance() int cyclesExecuted = slicelength - currentMIPS->downcount; globalTimer += cyclesExecuted; currentMIPS->downcount = slicelength; + VERBOSE_LOG(SCEDISPLAY, "CoreTiming: Event type '%s'", event_types[first->type].name); if (Common::AtomicLoadAcquire(hasTsEvents)) MoveEvents(); diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 8c7fd1359789..01521d4b34af 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -588,6 +588,7 @@ static void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) { static void DoFrameIdleTiming() { PROFILE_THIS_SCOPE("timing"); + if (!FrameTimingThrottled() || !g_Config.bEnableSound || wasPaused) { return; } @@ -713,6 +714,7 @@ void __DisplayFlip(int cyclesLate) { // Check first though, might've just quit / been paused. if (coreState == CORE_RUNNING) { coreState = CORE_NEXTFRAME; + DEBUG_LOG(SCEDISPLAY, "No recent flip - displaying anyway."); gpu->CopyDisplayToOutput(); if (fbReallyDirty) { actualFlips++; @@ -910,6 +912,8 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) // sceDisplaySetFramebuf() isn't supposed to delay threads at all. This is a hack. // So let's only delay when it's more than 1ms. const s64 FLIP_DELAY_CYCLES_MIN = usToCycles(1000); + // Though if we are super early, we also don't want to delay because the game is being silly like in #10763 + const s64 FLIP_DELAY_CYCLES_MAX = usToCycles(16000); // This is slightly less than a full frame at 60hz, 16666 // Some games (like Final Fantasy 4) only call this too much in spurts. // The goal is to fix games where this would result in a consistent overhead. const int FLIP_DELAY_MIN_FLIPS = 30; @@ -919,7 +923,7 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) u64 now = CoreTiming::GetTicks(); s64 cyclesAhead = nextFlipCycles - now; - if (cyclesAhead > FLIP_DELAY_CYCLES_MIN) { + if (cyclesAhead > FLIP_DELAY_CYCLES_MIN && (cyclesAhead < FLIP_DELAY_CYCLES_MAX || PSP_CoreParameter().unthrottle)) { if (lastFlipsTooFrequent >= FLIP_DELAY_MIN_FLIPS && gpuStats.numClears > 0) { delayCycles = cyclesAhead; } else { From 5f9767d19e8280d9b11f2277638bb739fd5c6923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 29 Apr 2018 09:45:34 +0200 Subject: [PATCH 2/2] Remove misleading log --- Core/HLE/sceDisplay.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 01521d4b34af..2d9cef0500a5 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -714,7 +714,6 @@ void __DisplayFlip(int cyclesLate) { // Check first though, might've just quit / been paused. if (coreState == CORE_RUNNING) { coreState = CORE_NEXTFRAME; - DEBUG_LOG(SCEDISPLAY, "No recent flip - displaying anyway."); gpu->CopyDisplayToOutput(); if (fbReallyDirty) { actualFlips++;