Merge pull request #6555 from xsacha/timing2

Improve frame timing on non-Windows.
This commit is contained in:
Henrik Rydgård 2014-07-15 19:58:29 +02:00
commit 459e244917
3 changed files with 15 additions and 5 deletions

View File

@ -161,9 +161,9 @@ void Core_RunLoop() {
// Simple throttling to not burn the GPU in the menu.
time_update();
double diffTime = time_now_d() - startTime;
int sleepTime = (int)(1000000.0 / 60.0) - (int)(diffTime * 1000000.0);
int sleepTime = (int)(1000.0 / 60.0) - (int)(diffTime * 1000.0);
if (sleepTime > 0)
Sleep(sleepTime / 1000);
Sleep(sleepTime);
if (!windowHidden) {
GL_SwapBuffers();
}

View File

@ -546,7 +546,12 @@ void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
} else {
// Wait until we've caught up.
while (time_now_d() < nextFrameTime) {
#ifdef _WIN32
sleep_ms(1); // Sleep for 1ms on this thread
#else
const double left = nextFrameTime - curFrameTime;
usleep((long)(left * 1000000));
#endif
time_update();
}
}
@ -557,7 +562,7 @@ void DoFrameTiming(bool &throttle, bool &skipFrame, float timestep) {
}
void DoFrameIdleTiming() {
if (!FrameTimingThrottled() || wasPaused) {
if (!FrameTimingThrottled() || !g_Config.bEnableSound || wasPaused) {
return;
}
@ -582,7 +587,12 @@ void DoFrameIdleTiming() {
// Give a little extra wiggle room in case the next vblank does more work.
const double goal = lastFrameTime + numVBlanksSinceFlip * scaledVblank - 0.001;
while (time_now_d() < goal) {
#ifdef _WIN32
sleep_ms(1);
#else
const double left = goal - time_now_d();
usleep((long)(left * 1000000));
#endif
time_update();
}
}
@ -727,8 +737,8 @@ void hleLagSync(u64 userdata, int cyclesLate) {
time_update();
// Don't lag too long ever, if they leave it paused.
while (time_now_d() < goal && goal < time_now_d() + 0.01) {
const double left = goal - time_now_d();
#ifndef _WIN32
const double left = goal - time_now_d();
usleep((long)(left * 1000000));
#endif
time_update();

2
native

@ -1 +1 @@
Subproject commit 22f41720b322c44d558546996f205bf6c06104d3
Subproject commit 84df417a01c425c64cd7d5dfe44a598a72c94611