Skip to content

Commit

Permalink
Add mitigation for games like GTA that never call sceDisplaySetFramebuf
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 6, 2017
1 parent 522de63 commit 4c72063
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Core/HLE/sceDisplay.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static int mode;
static int width; static int width;
static int height; static int height;
static bool wasPaused; static bool wasPaused;
static bool flippedThisFrame;


// 1.001f to compensate for the classic 59.94 NTSC framerate that the PSP seems to have. // 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; static const double timePerVblank = 1.001f / 60.0f;
Expand Down Expand Up @@ -194,6 +195,7 @@ void __DisplayInit() {
numSkippedFrames = 0; numSkippedFrames = 0;
numVBlanks = 0; numVBlanks = 0;
numVBlanksSinceFlip = 0; numVBlanksSinceFlip = 0;
flippedThisFrame = false;
framebufIsLatched = false; framebufIsLatched = false;
framebuf.topaddr = 0x04000000; framebuf.topaddr = 0x04000000;
framebuf.fmt = GE_FORMAT_8888; framebuf.fmt = GE_FORMAT_8888;
Expand Down Expand Up @@ -658,10 +660,14 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
framebufIsLatched = false; framebufIsLatched = false;
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.stride, framebuf.fmt); gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.stride, framebuf.fmt);
__DisplayFlip(cyclesLate); __DisplayFlip(cyclesLate);
} else if (!flippedThisFrame) {
// Gotta flip even if sceDisplaySetFramebuf was not called.
__DisplayFlip(cyclesLate);
} }
} }


void __DisplayFlip(int cyclesLate) { void __DisplayFlip(int cyclesLate) {
flippedThisFrame = true;
// We flip only if the framebuffer was dirty. This eliminates flicker when using // We flip only if the framebuffer was dirty. This eliminates flicker when using
// non-buffered rendering. The interaction with frame skipping seems to need // non-buffered rendering. The interaction with frame skipping seems to need
// some work. // some work.
Expand Down Expand Up @@ -751,6 +757,7 @@ void hleAfterFlip(u64 userdata, int cyclesLate) {


void hleLeaveVblank(u64 userdata, int cyclesLate) { void hleLeaveVblank(u64 userdata, int cyclesLate) {
isVblank = 0; isVblank = 0;
flippedThisFrame = false;
VERBOSE_LOG(SCEDISPLAY,"Leave VBlank %i", (int)userdata - 1); VERBOSE_LOG(SCEDISPLAY,"Leave VBlank %i", (int)userdata - 1);
CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs) - cyclesLate, enterVblankEvent, userdata); CoreTiming::ScheduleEvent(msToCycles(frameMs - vblankMs) - cyclesLate, enterVblankEvent, userdata);


Expand Down

0 comments on commit 4c72063

Please sign in to comment.