From c8f2f182d2a27031ded2fd20f827df35bc17d829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 30 Nov 2017 19:36:28 +0100 Subject: [PATCH] Add mitigation for games like GTA that never call sceDisplaySetFramebuf --- Core/HLE/sceDisplay.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 16694766f0..1b1e329f5f 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -106,6 +106,7 @@ static int mode; static int width; static int height; static bool wasPaused; +static bool flippedThisFrame; // 1.001f to compensate for the classic 59.94 NTSC framerate that the PSP seems to have. static const double timePerVblank = 1.001f / 60.0f; @@ -193,6 +194,7 @@ void __DisplayInit() { numSkippedFrames = 0; numVBlanks = 0; numVBlanksSinceFlip = 0; + flippedThisFrame = false; framebufIsLatched = false; framebuf.topaddr = 0x04000000; framebuf.fmt = GE_FORMAT_8888; @@ -656,10 +658,14 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { framebufIsLatched = false; gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.stride, framebuf.fmt); __DisplayFlip(cyclesLate); + } else if (!flippedThisFrame) { + // Gotta flip even if sceDisplaySetFramebuf was not called. + __DisplayFlip(cyclesLate); } } void __DisplayFlip(int cyclesLate) { + flippedThisFrame = true; // We flip only if the framebuffer was dirty. This eliminates flicker when using // non-buffered rendering. The interaction with frame skipping seems to need // some work. @@ -749,6 +755,7 @@ void hleAfterFlip(u64 userdata, int cyclesLate) { void hleLeaveVblank(u64 userdata, int cyclesLate) { isVblank = 0; + flippedThisFrame = false; VERBOSE_LOG(SCEDISPLAY,"Leave VBlank %i", (int)userdata - 1); CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs) - cyclesLate, enterVblankEvent, userdata);