From 69b6e5ad48254c675a05b5ac1a148edcdaa03c6b Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 30 Sep 2018 19:20:35 +0200 Subject: [PATCH] Redo 95bbb99 in a more correct manner. 1) Do not increment the frame rate returned by SDL by 1. Incrementing is unnessecary, more or less up to date versions on Nvidias, AMDs and Intels GPU driver on relevant platform return an value that's either correct or rounded up to next integer. And SDL itself also rounds up to the next integer. At least in current versions. In fact, incrementing the value by one is harmfull, it messes our internal timing up and leads to subtile miss predictions. Working around that in frame.c would add another bunch of fragile magic... So just do it correctly. If someone still has broken GPU drivers or SDL versions that are rounding down the could set vid_displayrefreshrate. 2) The calculation of the 5% security margin to pfps in frame.c was wrong. It didn't take into account that rfps can be slightly wrong in the first place, e.g. 60 on an 59.95hz display. Correct it by comparing against rfps including the margin and not the plain value. --- src/client/vid/glimp_sdl.c | 7 ------- src/common/frame.c | 3 +-- src/game/g_monster.c | 4 +++- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/client/vid/glimp_sdl.c b/src/client/vid/glimp_sdl.c index 774a26f8..f3b40a6d 100644 --- a/src/client/vid/glimp_sdl.c +++ b/src/client/vid/glimp_sdl.c @@ -401,12 +401,5 @@ GLimp_GetRefreshRate(void) } } - /* The value reported by SDL may be one frame too low, for example - on my old Radeon R7 360 the driver returns 59hz for my 59.95hz - display. And Quake II isn't that accurate, we loose a little bit - here and there. Since it doesn't really hurt if we're running a - litte bit too fast just return one frame more than we really have. */ - glimp_refreshRate++; - return glimp_refreshRate; } diff --git a/src/common/frame.c b/src/common/frame.c index 67b14ef2..0466702f 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -525,8 +525,7 @@ Qcommon_Frame(int msec) scene may be more complex than 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) ? floor(rfps * 0.95) : cl_maxfps->value; - + pfps = (cl_maxfps->value > (rfps * 0.95)) ? floor(rfps * 0.95) : cl_maxfps->value; /* Calculate average time spend to process a render frame. This is highly depended on the GPU and the diff --git a/src/game/g_monster.c b/src/game/g_monster.c index 2bd42bc3..3ed75a4e 100644 --- a/src/game/g_monster.c +++ b/src/game/g_monster.c @@ -262,7 +262,9 @@ M_CheckGround(edict_t *ent) VectorCopy(trace.endpos, ent->s.origin); ent->groundentity = trace.ent; ent->groundentity_linkcount = trace.ent->linkcount; - ent->velocity[2] = trace.ent->velocity[2]; + + // FIXME + ent->velocity[2] = 0; } }