1
0
Fork 0
forked from fte/fteqw

win: Make sure sys_clockprecision gets applied at startup, which should help improve emulated system timer precision.

This commit is contained in:
Shpoike 2023-08-19 02:22:56 +01:00
parent aa43bc40f7
commit 3357338ab7

View file

@ -1756,6 +1756,21 @@ void VARGS Sys_Printf (char *fmt, ...)
}
}
static unsigned int sys_interrupt_freq;
static void Sys_ClockPrecision_Changed(cvar_t *var, char *oldval)
{
if (sys_interrupt_freq)
timeEndPeriod(sys_interrupt_freq);
sys_interrupt_freq = 0;
if (var && var->ival > 0)
{
sys_interrupt_freq = var->ival;
if (TIMERR_NOERROR != timeBeginPeriod(sys_interrupt_freq) && oldval)
Con_Printf(CON_ERROR"%s: timeBeginPeriod(%u) failed.\n", var->name, sys_interrupt_freq);
}
}
static quint64_t timer_qpc_frequency;
static unsigned int timer_tgt_period;
static quint64_t timer_basetime; //used by all clocks to bias them to starting at 0
@ -1864,6 +1879,8 @@ static void Sys_InitClock(void)
//calibrate it, and apply.
timer_basetime = Sys_GetClock(&freq);
Sys_ClockType_Changed(&sys_clocktype, NULL);
Sys_ClockPrecision_Changed(&sys_clocktype, NULL);
}
double Sys_DoubleTime (void)
{
@ -1877,21 +1894,6 @@ unsigned int Sys_Milliseconds (void)
return num / denum;
}
static unsigned int sys_interrupt_freq;
static void Sys_ClockPrecision_Changed(cvar_t *var, char *oldval)
{
if (sys_interrupt_freq)
timeEndPeriod(sys_interrupt_freq);
sys_interrupt_freq = 0;
if (var && var->ival > 0)
{
sys_interrupt_freq = var->ival;
if (TIMERR_NOERROR != timeBeginPeriod(sys_interrupt_freq))
Con_Printf(CON_ERROR"%s: timeBeginPeriod(%u) failed.\n", var->name, sys_interrupt_freq);
}
}
void Sys_Quit (void)
{
Sys_ClockType_Changed(NULL, NULL);