From 97feb483ab1c78cc6d88b891c80e5fa481afb9a2 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 28 Aug 2020 15:27:16 +1000 Subject: [PATCH] - Set frame-time as close to the buffer swap as possible, and calculate smoothratio for Duke/SW as late as possible. * Micro-optimisation, but was getting a very occasional jitter in Duke 3D that seems to have gone with this. --- source/build/src/engine.cpp | 1 + source/core/gamecontrol.cpp | 1 - source/games/duke/src/gameloop.cpp | 3 +-- source/sw/src/game.cpp | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 42ce85175..01086eb35 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -2724,6 +2724,7 @@ void videoNextPage(void) { g_beforeSwapTime = I_msTimeF(); videoShowFrame(0); + I_SetFrameTime(); omdtims = mdtims; mdtims = I_msTime(); diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 2f53733b4..14b69bf59 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -941,7 +941,6 @@ void app_loop() TickSubsystems(); twod->SetSize(screen->GetWidth(), screen->GetHeight()); twodpsp.SetSize(screen->GetWidth(), screen->GetHeight()); - I_SetFrameTime(); handleevents(); updatePauseStatus(); diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index c0ec5f9bc..5c3dd9455 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -353,8 +353,6 @@ bool GameTicker() } } - double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio; - gameupdatetime.Unclock(); if (ps[myconnectindex].gm & (MODE_EOL | MODE_RESTART)) @@ -370,6 +368,7 @@ bool GameTicker() drawtime.Reset(); drawtime.Clock(); S_Update(); + double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio; displayrooms(screenpeek, smoothRatio); displayrest(smoothRatio); drawtime.Unclock(); diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index edf851112..dd9a5ba29 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -788,11 +788,11 @@ void GameTicker(void) MoveTicker(); } - smoothratio = I_GetTimeFrac() * MaxSmoothRatio; - // Get input again to update q16ang/q16horiz. if (!PedanticMode) getinput(&loc, TRUE); + + smoothratio = I_GetTimeFrac() * MaxSmoothRatio; } drawscreen(Player + screenpeek, smoothratio);