From 5a8382064acc0f996c5784c78c4849d4ea78e22e Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 8 May 2022 18:10:25 +0200 Subject: [PATCH] Remove 0.95 factor for packet framerate It could make things stutter, especially if cl_maxfps was deliberately set to a fraction of the display refreshrate (as it'd target a few frames less). The 0.95 factor was supposed to ensure that we don't have more packet frames than renderframes (or two packet frames in a row without rendering in between), as that apparently breaks the movement prediction code. We now ensure the same thing my not running a packet frame if no render frame is run at the same time. --- src/common/frame.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/frame.c b/src/common/frame.c index 28f11106..7f586865 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -562,11 +562,8 @@ Qcommon_Frame(int usec) rfps = (int)vid_maxfps->value; } - /* The target render frame rate may be too high. The current - scene may be more complex then the previous one and SDL - may give us a 1 or 2 frames too low display refresh rate. - Add a security magin of 5%, e.g. 60fps * 0.95 = 57fps. */ - pfps = (cl_maxfps->value > (rfps * 0.95)) ? floor(rfps * 0.95) : cl_maxfps->value; + // we can't have more packet frames than render frames, so limit pfps to rfps + pfps = (cl_maxfps->value > rfps) ? rfps : cl_maxfps->value; // Calculate timings. @@ -581,7 +578,7 @@ Qcommon_Frame(int usec) { if (R_IsVSyncActive()) { - // Netwwork frames. + // Network frames. if (packetdelta < (0.8 * (1000000.0f / pfps))) { packetframe = false; @@ -607,6 +604,12 @@ Qcommon_Frame(int usec) renderframe = false; } } + if (!renderframe) + { + // we must have at least one render frame between two packet frames + // => no packet frame without render frame + packetframe = false; + } } else {