aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/helpers.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-07 05:36:25 -0700
committerChris Robinson <[email protected]>2012-10-07 05:36:25 -0700
commit6b870714a91c9607acc4501234a00c7c94fa2b85 (patch)
tree04d0ae8cf35cb357a21a63bba7d420e3dee794be /Alc/helpers.c
parent708f3ccc3d457499ac046a009a7c3317b31a2b4b (diff)
Use __cpuid from intrin.h in Windows when available
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r--Alc/helpers.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 262c2551..6eff516e 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -54,6 +54,9 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
+#ifdef HAVE_INTRIN_H
+#include <intrin.h>
+#endif
#ifdef HAVE_CPUID_H
#include <cpuid.h>
#endif
@@ -109,6 +112,36 @@ void FillCPUCaps(ALuint capfilter)
#endif
}
}
+#elif defined(HAVE___CPUID)
+ union {
+ int regs[4];
+ char str[sizeof(int[4])];
+ } cpuinf[3];
+ unsigned int maxfunc = 0;
+ unsigned int maxextfunc = 0;
+
+ (__cpuid)(cpuinf[0].regs, 0);
+ maxfunc = cpuinf[0].regs[0];
+
+ (__cpuid)(cpuinf[0].regs, 0x80000000);
+ maxextfunc = cpuinf[0].regs[0];
+ TRACE("Detected max CPUID function: 0x%x (ext. 0x%x)\n", maxfunc, maxextfunc);
+
+ TRACE("Vendor ID: \"%.4s%.4s%.4s\"\n", cpuinf[0].str+4, cpuinf[0].str+12, cpuinf[0].str+8);
+ if(maxextfunc >= 0x80000004)
+ {
+ (__cpuid)(cpuinf[0].regs, 0x80000002);
+ (__cpuid)(cpuinf[1].regs, 0x80000003);
+ (__cpuid)(cpuinf[2].regs, 0x80000004);
+ TRACE("Name: \"%.16s%.16s%.16s\"\n", cpuinf[0].str, cpuinf[1].str, cpuinf[2].str);
+ }
+
+ if(maxfunc >= 1)
+ {
+ (__cpuid)(cpuinf[0].regs, 1);
+ if((cpuinf[0].regs[3]&(1<<25)))
+ caps |= CPU_CAP_SSE;
+ }
#endif
#endif
#ifdef HAVE_NEON