mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 12:41:21 +00:00
Correct average render / packet time calculations.
We need to reset the avgrenderframetime and avgpacketframetime variables when we recalculate the average times spend rendering frame and / or processing package frames. Otherwise the result will be much too high, leading to lost frames down below. I wonder why nobody complained about this until now. While at it lower the security margin from 2% to just 1%. On the one hand we need a small security margin, because Quake II is not that precise and out average times spend may be too low. On the other hand the margin must not be too large, because the bigger the margin is the bigger is the risk of missing frames... Both 2% and 1% is very small, in fact often they don't even make a difference because of float -> int conversations. For example 16 * 0,02 = 0,32 -> cut to 0. But there are some extrem cases were it matters and my empirical testing showed that 1% is slighty better then 2%. At least on my system. An it's better to f*ck up the timing for a small number of frames than missing a frame. A broken timing is hard to recognize, a missed frame is much more annoying.
This commit is contained in:
parent
861cf25ddf
commit
60c12228c9
1 changed files with 6 additions and 4 deletions
|
@ -532,12 +532,13 @@ Qcommon_Frame(int msec)
|
|||
scenes complexity. Take the last 60 pure render
|
||||
frames (frames that are only render frames and
|
||||
nothing else) into account and add a security
|
||||
margin of 2%. */
|
||||
margin of 1%. */
|
||||
if (last_was_renderframe && !last_was_packetframe)
|
||||
{
|
||||
int measuredframes = 0;
|
||||
static int renderframenum;
|
||||
|
||||
avgrenderframetime = 0;
|
||||
renderframetimes[renderframenum] = msec;
|
||||
|
||||
for (int i = 0; i < 60; i++)
|
||||
|
@ -550,7 +551,7 @@ Qcommon_Frame(int msec)
|
|||
}
|
||||
|
||||
avgrenderframetime /= measuredframes;
|
||||
avgrenderframetime += (avgrenderframetime * 0.02f);
|
||||
avgrenderframetime += (avgrenderframetime * 0.01f);
|
||||
|
||||
renderframenum++;
|
||||
|
||||
|
@ -567,12 +568,13 @@ Qcommon_Frame(int msec)
|
|||
speed and the network delay. Take the last 60 pure
|
||||
packet frames (frames that are only packet frames ans
|
||||
nothing else) into account and add a security margin
|
||||
of 2%. */
|
||||
of 1%. */
|
||||
if (last_was_packetframe && last_was_renderframe)
|
||||
{
|
||||
int measuredframes = 0;
|
||||
static int packetframenum;
|
||||
|
||||
avgpacketframetime = 0;
|
||||
packetframetimes[packetframenum] = msec;
|
||||
|
||||
for (int i = 0; i < 60; i++)
|
||||
|
@ -585,7 +587,7 @@ Qcommon_Frame(int msec)
|
|||
}
|
||||
|
||||
avgpacketframetime /= measuredframes;
|
||||
avgpacketframetime += (avgpacketframetime * 0.02f);
|
||||
avgpacketframetime += (avgpacketframetime * 0.01f);
|
||||
|
||||
packetframenum++;
|
||||
|
||||
|
|
Loading…
Reference in a new issue