Permalink
Browse files

Merge pull request #10213 from hrydgard/immediate-flip

Flip immediately if that's OK, instead of waiting for VBlank.
  • Loading branch information...
hrydgard committed Dec 6, 2017
2 parents cf5ede4 + 54ff4c8 commit 3b786876728e683725230e6bd58ed2adfeca1085
Showing with 18 additions and 1 deletion.
  1. +18 −1 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;
@@ -173,6 +174,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) {
@@ -192,6 +195,7 @@ void __DisplayInit() {
numSkippedFrames = 0;
numVBlanks = 0;
numVBlanksSinceFlip = 0;
flippedThisFrame = false;
framebufIsLatched = false;
framebuf.topaddr = 0x04000000;
framebuf.fmt = GE_FORMAT_8888;
@@ -655,7 +659,15 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
framebuf = latchedFramebuf;
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.
@@ -725,6 +737,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 {
@@ -744,6 +757,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);
@@ -835,9 +849,12 @@ 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.
if (!flippedThisFrame)
__DisplayFlip(0);
} else {
// Delay the write until vblank
latchedFramebuf = fbstate;

0 comments on commit 3b78687

Please sign in to comment.