Never sleep between frames with timedemo

This commit is contained in:
Denis Pauk 2021-10-16 14:38:11 +03:00
parent 012862b58d
commit fa1f5c2c84

View file

@ -142,33 +142,36 @@ Qcommon_Mainloop(void)
while (1) while (1)
{ {
#ifndef DEDICATED_ONLY #ifndef DEDICATED_ONLY
// Throttle the game a little bit. if (!cl_timedemo->value)
if (busywait->value)
{ {
long long spintime = Sys_Microseconds(); // Throttle the game a little bit.
if (busywait->value)
while (1)
{ {
/* Give the CPU a hint that this is a very tight long long spintime = Sys_Microseconds();
spinloop. One PAUSE instruction each loop is
enough to reduce power consumption and head while (1)
dispersion a lot, it's 95°C against 67°C on {
a Kaby Lake laptop. */ /* Give the CPU a hint that this is a very tight
spinloop. One PAUSE instruction each loop is
enough to reduce power consumption and head
dispersion a lot, it's 95°C against 67°C on
a Kaby Lake laptop. */
#if defined (__GNUC__) && (__i386 || __x86_64__) #if defined (__GNUC__) && (__i386 || __x86_64__)
asm("pause"); asm("pause");
#elif defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__ARM_ARCH_6K__) #elif defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__ARM_ARCH_6K__)
asm("yield"); asm("yield");
#endif #endif
if (Sys_Microseconds() - spintime >= 5) if (Sys_Microseconds() - spintime >= 5)
{ {
break; break;
}
} }
} }
} else
else {
{ Sys_Nanosleep(5000);
Sys_Nanosleep(5000); }
} }
#else #else
Sys_Nanosleep(850000); Sys_Nanosleep(850000);