From 17dfaa3aaef28f38b27c5d797be0a938c4ca38e2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 13 Aug 2012 10:37:49 -0700 Subject: Add a config option to disable use of CPU extensions --- Alc/ALc.c | 32 +++++++++++++++++++++++++++++++- Alc/helpers.c | 19 +++++++++++-------- 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index b017c480..e664d25a 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -769,6 +769,7 @@ static void alc_init(void) static void alc_initconfig(void) { const char *devs, *str; + ALuint capfilter; float valf; int i, n; @@ -790,7 +791,36 @@ static void alc_initconfig(void) ReadALConfig(); - FillCPUCaps(); + capfilter = CPU_CAP_ALL; + if(ConfigValueStr(NULL, "disable-cpu-exts", &str)) + { + if(strcasecmp(str, "all") == 0) + capfilter = 0; + else + { + size_t len; + const char *next = str; + + i = 0; + do { + str = next; + next = strchr(str, ','); + + while(isspace(str[0])) + str++; + if(!str[0] || str[0] == ',') + continue; + + len = (next ? ((size_t)(next-str)) : strlen(str)); + if(strncasecmp(str, "neon", len) == 0) + capfilter &= ~CPU_CAP_NEON; + else + WARN("Invalid CPU extension \"%s\"\n", str); + } while(next++); + } + } + FillCPUCaps(capfilter); + InitHrtf(); #ifdef _WIN32 diff --git a/Alc/helpers.c b/Alc/helpers.c index 6051573e..d963f3a8 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -63,8 +63,10 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, ALuint CPUCapFlags = 0; -void FillCPUCaps(void) +void FillCPUCaps(ALuint capfilter) { + ALuint caps = 0; + #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) /* FIXME: We really should get this for all available CPUs in case different * CPUs have different caps (is that possible on one machine?). */ @@ -90,11 +92,11 @@ void FillCPUCaps(void) { #ifdef bit_MMX if((cpuinf[0].regs[3]&bit_MMX)) - CPUCapFlags |= CPU_CAP_MMX; + caps |= CPU_CAP_MMX; #endif #ifdef bit_SSE if((cpuinf[0].regs[3]&bit_SSE)) - CPUCapFlags |= CPU_CAP_SSE; + caps |= CPU_CAP_SSE; #endif } } @@ -102,13 +104,14 @@ void FillCPUCaps(void) #endif #ifdef HAVE_ARM_NEON_H /* Assume Neon support if compiled with it */ - CPUCapFlags |= CPU_CAP_NEON; + caps |= CPU_CAP_NEON; #endif - TRACE("Got caps:%s%s%s%s\n", ((CPUCapFlags&CPU_CAP_MMX)?" MMX":""), - ((CPUCapFlags&CPU_CAP_SSE)?" SSE":""), - ((CPUCapFlags&CPU_CAP_NEON)?" Neon":""), - ((!CPUCapFlags)?" (none)":"")); + TRACE("Got caps:%s%s%s%s\n", ((caps&CPU_CAP_MMX)?((capfilter&CPU_CAP_MMX)?" MMX":" (MMX)"):""), + ((caps&CPU_CAP_SSE)?((capfilter&CPU_CAP_SSE)?" SSE":" (SSE)"):""), + ((caps&CPU_CAP_NEON)?((capfilter&CPU_CAP_NEON)?" Neon":" (Neon)"):""), + ((!caps)?" (none)":"")); + CPUCapFlags = caps & capfilter; } -- cgit v1.2.3