Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the flip delay in the other direction to try to work around #10763. #10944

Merged
merged 2 commits into from
Apr 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/CoreTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This gets logged even for normal flips right?

-[Unknown]

gpu->CopyDisplayToOutput();
if (fbReallyDirty) {
actualFlips++;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down