From 522de63eed79e9e5362fcc35ee5f44c5091c9171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 30 Nov 2017 00:54:30 +0100 Subject: [PATCH] Flip immediately if that's OK. This can save up to a frame of graphics latency, in games that display "immediately" instead of latched. --- Core/HLE/sceDisplay.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index c94aedc84b..d6014aefe4 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -173,6 +173,8 @@ int __DisplayGetFlipCount() { return actualFlips; } int __DisplayGetVCount() { return vCount; } int __DisplayGetNumVblanks() { return numVBlanks; } +void __DisplayFlip(int cyclesLate); + static void ScheduleLagSync(int over = 0) { lagSyncScheduled = g_Config.bForceLagSync; if (lagSyncScheduled) { @@ -655,7 +657,11 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { framebuf = latchedFramebuf; framebufIsLatched = false; gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.stride, framebuf.fmt); + __DisplayFlip(cyclesLate); } +} + +void __DisplayFlip(int cyclesLate) { // 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. @@ -725,6 +731,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { // Returning here with coreState == CORE_NEXTFRAME causes a buffer flip to happen (next frame). // Right after, we regain control for a little bit in hleAfterFlip. I think that's a great // place to do housekeeping. + CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0); numVBlanksSinceFlip = 0; } else { @@ -835,9 +842,11 @@ void __DisplaySetFramebuf(u32 topaddr, int linesize, int pixelFormat, int sync) fbstate.stride = linesize; if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) { - // Write immediately to the current framebuffer parameters + // Write immediately to the current framebuffer parameters. framebuf = fbstate; gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.stride, framebuf.fmt); + // IMMEDIATE means that the buffer is fine. We can just flip immediately. + __DisplayFlip(0); } else { // Delay the write until vblank latchedFramebuf = fbstate;