Fixed render loop slowing down update loop if OpenGL performance was being limited by a power target

This commit is contained in:
Pazaz 2022-04-27 14:46:14 -04:00
parent e6aaa283ff
commit 0f5da09916
4 changed files with 30 additions and 8 deletions

View file

@ -534,7 +534,10 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
updateDelta = currentTime - lastUpdateTime;
if (updateDelta >= FIXED_UPDATE_RATE * 1_000_000) {
this.mainLoopWrapper();
logicCycles = timer.count(minimumDelay, (int)FIXED_UPDATE_RATE);
for (int cycle = 0; cycle < logicCycles; ++cycle) {
this.mainLoopWrapper();
}
lastUpdateTime = currentTime;
flush(signLink, canvas);
}
@ -544,13 +547,7 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
this.mainInputLoop();
this.mainRedrawWrapper();
lastDrawTime = currentTime;
if (VARIABLE_RENDER_RATE > minimumDelay) {
timer.sleep(minimumDelay, (int) VARIABLE_RENDER_RATE);
} else {
// encourage thread switching
Thread.yield();
}
Thread.yield();
}
}
} catch (@Pc(198) Exception ex) {