detect if AVX is supported

This commit is contained in:
FunkyFr3sh 2022-09-19 13:13:34 +02:00
parent 537b8605b0
commit f4ee6128c4
5 changed files with 25 additions and 2 deletions

View file

@ -1,4 +1,5 @@
#include <windows.h>
#include <intrin.h>
#include "ddraw.h"
#include "debug.h"
#include "dd.h"
@ -10,6 +11,22 @@
#include "config.h"
BOOL util_is_avx_supported()
{
unsigned int xcr0 = 0;
#if defined(_MSC_VER)
xcr0 = (unsigned int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
#else
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
#endif
int info[4] = { 0 };
__cpuid(info, 1);
return (info[2] & (1 << 27)) && (info[2] & (1 << 28)) && (xcr0 & 6);
}
void util_limit_game_ticks()
{
if (g_ddraw->ticks_limiter.htimer)