Add cmake options to disable or require support for CPU extensions
This commit is contained in:
@@ -791,7 +791,13 @@ static void alc_initconfig(void)
|
||||
|
||||
ReadALConfig();
|
||||
|
||||
capfilter = CPU_CAP_ALL;
|
||||
capfilter = 0;
|
||||
#ifdef HAVE_SSE
|
||||
capfilter |= CPU_CAP_SSE;
|
||||
#endif
|
||||
#ifdef HAVE_NEON
|
||||
capfilter |= CPU_CAP_NEON;
|
||||
#endif
|
||||
if(ConfigValueStr(NULL, "disable-cpu-exts", &str))
|
||||
{
|
||||
if(strcasecmp(str, "all") == 0)
|
||||
|
||||
+6
-6
@@ -41,7 +41,7 @@
|
||||
|
||||
DryMixerFunc SelectDirectMixer(enum Resampler Resampler)
|
||||
{
|
||||
#ifdef HAVE_XMMINTRIN_H
|
||||
#ifdef HAVE_SSE
|
||||
if((CPUCapFlags&CPU_CAP_SSE))
|
||||
{
|
||||
switch(Resampler)
|
||||
@@ -57,7 +57,7 @@ DryMixerFunc SelectDirectMixer(enum Resampler Resampler)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_ARM_NEON_H
|
||||
#ifdef HAVE_NEON
|
||||
if((CPUCapFlags&CPU_CAP_NEON))
|
||||
{
|
||||
switch(Resampler)
|
||||
@@ -90,7 +90,7 @@ DryMixerFunc SelectDirectMixer(enum Resampler Resampler)
|
||||
|
||||
DryMixerFunc SelectHrtfMixer(enum Resampler Resampler)
|
||||
{
|
||||
#ifdef HAVE_XMMINTRIN_H
|
||||
#ifdef HAVE_SSE
|
||||
if((CPUCapFlags&CPU_CAP_SSE))
|
||||
{
|
||||
switch(Resampler)
|
||||
@@ -106,7 +106,7 @@ DryMixerFunc SelectHrtfMixer(enum Resampler Resampler)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_ARM_NEON_H
|
||||
#ifdef HAVE_NEON
|
||||
if((CPUCapFlags&CPU_CAP_NEON))
|
||||
{
|
||||
switch(Resampler)
|
||||
@@ -139,7 +139,7 @@ DryMixerFunc SelectHrtfMixer(enum Resampler Resampler)
|
||||
|
||||
WetMixerFunc SelectSendMixer(enum Resampler Resampler)
|
||||
{
|
||||
#ifdef HAVE_XMMINTRIN_H
|
||||
#ifdef HAVE_SSE
|
||||
if((CPUCapFlags&CPU_CAP_SSE))
|
||||
{
|
||||
switch(Resampler)
|
||||
@@ -155,7 +155,7 @@ WetMixerFunc SelectSendMixer(enum Resampler Resampler)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_ARM_NEON_H
|
||||
#ifdef HAVE_NEON
|
||||
if((CPUCapFlags&CPU_CAP_NEON))
|
||||
{
|
||||
switch(Resampler)
|
||||
|
||||
+29
-8
@@ -26,6 +26,13 @@ PROJECT(OpenAL C)
|
||||
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
|
||||
|
||||
|
||||
OPTION(SSE "Check for SSE CPU extensions" ON)
|
||||
OPTION(NEON "Check for ARM Neon CPU extensions" ON)
|
||||
|
||||
OPTION(REQUIRE_SSE "Require SSE CPU extensions" OFF)
|
||||
OPTION(REQUIRE_NEON "Require ARM Neon CPU extensions" OFF)
|
||||
|
||||
|
||||
OPTION(ALSA "Check for ALSA backend" ON)
|
||||
OPTION(OSS "Check for OSS backend" ON)
|
||||
OPTION(SOLARIS "Check for Solaris backend" ON)
|
||||
@@ -429,19 +436,33 @@ SET(ALC_OBJS Alc/ALc.c
|
||||
|
||||
|
||||
SET(CPU_EXTS "Default")
|
||||
SET(HAVE_SSE 0)
|
||||
SET(HAVE_NEON 0)
|
||||
|
||||
# Check for SSE support
|
||||
CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H)
|
||||
IF(HAVE_XMMINTRIN_H)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
|
||||
SET(CPU_EXTS "${CPU_EXTS}, SSE")
|
||||
IF(SSE)
|
||||
CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H)
|
||||
IF(HAVE_XMMINTRIN_H)
|
||||
SET(HAVE_SSE 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_sse.c)
|
||||
SET(CPU_EXTS "${CPU_EXTS}, SSE")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF(REQUIRE_SSE AND NOT HAVE_SSE)
|
||||
MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
|
||||
ENDIF()
|
||||
|
||||
# Check for ARM Neon support
|
||||
CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
|
||||
IF(HAVE_ARM_NEON_H)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
|
||||
SET(CPU_EXTS "${CPU_EXTS}, Neon")
|
||||
IF(NEON)
|
||||
CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
|
||||
IF(HAVE_ARM_NEON_H)
|
||||
SET(HAVE_NEON 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/mixer_neon.c)
|
||||
SET(CPU_EXTS "${CPU_EXTS}, Neon")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF(REQUIRE_NEON AND NOT HAVE_NEON)
|
||||
MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
/* Define to the library version */
|
||||
#define ALSOFT_VERSION "${LIB_VERSION}"
|
||||
|
||||
/* Define if we have SSE CPU extensions */
|
||||
#cmakedefine HAVE_SSE
|
||||
|
||||
/* Define if we have ARM Neon CPU extensions */
|
||||
#cmakedefine HAVE_NEON
|
||||
|
||||
/* Define if we have the ALSA backend */
|
||||
#cmakedefine HAVE_ALSA
|
||||
|
||||
|
||||
Reference in New Issue
Block a user