mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-20 05:20:24 -07:00
Fixed render loop slowing down update loop if OpenGL performance was being limited by a power target
This commit is contained in:
parent
e6aaa283ff
commit
0f5da09916
4 changed files with 30 additions and 8 deletions
|
|
@ -534,7 +534,10 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
|
|||
|
||||
updateDelta = currentTime - lastUpdateTime;
|
||||
if (updateDelta >= FIXED_UPDATE_RATE * 1_000_000) {
|
||||
logicCycles = timer.count(minimumDelay, (int)FIXED_UPDATE_RATE);
|
||||
for (int cycle = 0; cycle < logicCycles; ++cycle) {
|
||||
this.mainLoopWrapper();
|
||||
}
|
||||
lastUpdateTime = currentTime;
|
||||
flush(signLink, canvas);
|
||||
}
|
||||
|
|
@ -544,15 +547,9 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (@Pc(198) Exception ex) {
|
||||
TracingException.report(null, ex);
|
||||
this.error("crash");
|
||||
|
|
|
|||
|
|
@ -87,4 +87,8 @@ public final class MillisTimer extends Timer {
|
|||
this.anInt3553 &= 0xFF;
|
||||
return local139;
|
||||
}
|
||||
|
||||
public int count(int arg0, int arg1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,23 @@ public final class NanoTimer extends Timer {
|
|||
}
|
||||
return local31;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(int arg0, int arg1) {
|
||||
@Pc(9) long local9 = (long) arg0 * 1000000L;
|
||||
@Pc(14) long local14 = this.aLong142 - System.nanoTime();
|
||||
if (local9 > local14) {
|
||||
local14 = local9;
|
||||
}
|
||||
@Pc(31) int local31 = 0;
|
||||
@Pc(33) long local33 = System.nanoTime();
|
||||
while (local31 < 10 && (local31 < 1 || this.aLong142 < local33)) {
|
||||
local31++;
|
||||
this.aLong142 += (long) arg1 * 1000000L;
|
||||
}
|
||||
if (local33 > this.aLong142) {
|
||||
this.aLong142 = local33;
|
||||
}
|
||||
return local31;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ public abstract class Timer {
|
|||
|
||||
@OriginalMember(owner = "client!s", name = "b", descriptor = "(I)V")
|
||||
public abstract void reset();
|
||||
|
||||
public abstract int count(int arg0, int arg1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue