Skip to content

Commit

Permalink
Defer waits.
Browse files Browse the repository at this point in the history
Add sanity check
  • Loading branch information
hrydgard committed Dec 18, 2023
1 parent 97e0f6d commit e1f1af6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Core/FrameTiming.cpp
Expand Up @@ -39,7 +39,9 @@ void WaitUntil(double now, double timestamp) {
}
#else
const double left = timestamp - now;
usleep((long)(left * 1000000));
if (left > 0.0) {
usleep((long)(left * 1000000));
}
#endif
}

Expand Down
12 changes: 8 additions & 4 deletions Core/HLE/sceDisplay.cpp
Expand Up @@ -438,11 +438,15 @@ 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.
WaitUntil(curFrameTime, nextFrameTime);
// If we're ending the frame here, we'll defer the sleep until after the command buffers
// have been handed off to the render thread, for some more overlap.
if (endOfFrame) {
g_frameTiming.DeferWaitUntil(nextFrameTime, &curFrameTime);
} else {
WaitUntil(curFrameTime, nextFrameTime);
curFrameTime = time_now_d(); // I guess we could also just set it to nextFrameTime...
}
}
curFrameTime = time_now_d();
}

lastFrameTime = nextFrameTime;
Expand Down

0 comments on commit e1f1af6

Please sign in to comment.