Skip to content

Commit

Permalink
Small refactor to enable upcoming commits
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 18, 2023
1 parent ef149bd commit 91dbde9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void DoFrameDropLogging(float scaledTimestep) {

// All the throttling and frameskipping logic is here.
// This is called just before we drop out of the main loop, in order to allow the submit and present to happen.
static void DoFrameTiming(bool throttle, bool *skipFrame, float scaledTimestep) {
static void DoFrameTiming(bool throttle, bool *skipFrame, float scaledTimestep, bool endOfFrame) {
PROFILE_THIS_SCOPE("timing");
*skipFrame = false;

Expand Down Expand Up @@ -438,6 +438,9 @@ static void DoFrameTiming(bool throttle, bool *skipFrame, float scaledTimestep)
nextFrameTime = curFrameTime;
} else {
// Wait until we've caught up.
// TODO: This is the wait we actually move to after the frame.
// But watch out, curFrameTime below must be updated correctly - I think.

while (time_now_d() < nextFrameTime) {
#ifdef _WIN32
sleep_ms(1); // Sleep for 1ms on this thread
Expand Down Expand Up @@ -637,9 +640,13 @@ void __DisplayFlip(int cyclesLate) {

// Setting CORE_NEXTFRAME (which Core_NextFrame does) causes a swap.
const bool fbReallyDirty = gpu->FramebufferReallyDirty();

bool nextFrame = false;

if (fbReallyDirty || noRecentFlip || postEffectRequiresFlip) {
// Check first though, might've just quit / been paused.
if (!forceNoFlip && Core_NextFrame()) {
nextFrame = Core_NextFrame();
if (!forceNoFlip && nextFrame) {
gpu->CopyDisplayToOutput(fbReallyDirty);
if (fbReallyDirty) {
DisplayFireActualFlip();
Expand All @@ -659,7 +666,7 @@ void __DisplayFlip(int cyclesLate) {
scaledTimestep *= (float)framerate / fpsLimit;
}
bool skipFrame;
DoFrameTiming(throttle, &skipFrame, scaledTimestep);
DoFrameTiming(throttle, &skipFrame, scaledTimestep, nextFrame);

int maxFrameskip = 8;
int frameSkipNum = DisplayCalculateFrameSkip();
Expand Down

0 comments on commit 91dbde9

Please sign in to comment.