- get the frame time right at the start of the frame, not when performing interpolations.

This is to factor think time out of the time span between frames and to avoid changes if the smoothratio gets calculated multiple times.
This commit is contained in:
Christoph Oelckers 2020-08-02 21:16:01 +02:00
parent 3861064f62
commit 18c3d9b240
5 changed files with 16 additions and 16 deletions

View file

@ -2965,19 +2965,10 @@ void DrawFullscreenBlends();
//
void videoNextPage(void)
{
static bool recursion;
if (!recursion)
{
// This protection is needed because the menu can call scripts from inside its drawers and the scripts can call the busy-looping Screen_Play script event
// which calls videoNextPage for page flipping again. In this loop the UI drawers may not get called again.
// Ideally this stuff should be moved out of videoNextPage so that all those busy loops won't call UI overlays at all.
recursion = true;
FStat::PrintStat(twod);
C_DrawConsole();
M_Drawer();
recursion = false;
}
// Draw overlay elements to the 2D drawer
FStat::PrintStat(twod);
C_DrawConsole();
M_Drawer();
// Handle the final 2D overlays.
DrawFullscreenBlends();
@ -2999,8 +2990,10 @@ void videoNextPage(void)
beforedrawrooms = 1;
numframes++;
// This should be in the main loop but with some of the games still having multiple render loops it cannot be moved out of here
twod->SetSize(screen->GetWidth(), screen->GetHeight());
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
I_SetFrameTime();
}
//

View file

@ -150,6 +150,11 @@ uint64_t I_msTimeFS() // from "start"
return (FirstFrameStartTime == 0) ? 0 : NSToMS(I_nsTime() - FirstFrameStartTime);
}
uint64_t I_GetTimeNS()
{
return CurrentFrameStartTime - FirstFrameStartTime;
}
int I_GetTime()
{
return NSToTic(CurrentFrameStartTime - FirstFrameStartTime);

View file

@ -9,6 +9,8 @@ void I_SetFrameTime();
// Called by D_DoomLoop, returns current time in tics.
int I_GetTime();
// same, but using nanoseconds
uint64_t I_GetTimeNS();
double I_GetTimeFrac();

View file

@ -1038,7 +1038,7 @@ void S_SetSoundPaused(int state)
}
}
int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int realgameticspersec)
int CalcSmoothRatio(ClockTicks totalclk, ClockTicks ototalclk, int realgameticspersec)
{
double ratio;
int result;
@ -1051,7 +1051,7 @@ int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int
if (!cl_legacyintrpl)
{
double const gametics = 1'000'000'000. / realgameticspersec;
uint64_t currentTime = I_nsTime();
uint64_t currentTime = I_GetTimeNS();
if ((lastototalclk == ototalclk) && (lastTime != 0))
{

View file

@ -192,7 +192,7 @@ void S_ResumeSound(bool notsfx);
void S_SetSoundPaused(int state);
void G_FatalEngineError(void);
int CalcSmoothRatio(const ClockTicks& totalclk, const ClockTicks& ototalclk, int realgameticspersec);
int CalcSmoothRatio(ClockTicks totalclk, ClockTicks ototalclk, int realgameticspersec);
enum
{
MaxSmoothRatio = FRACUNIT