audio: Wired up new SSE code to build system.

This commit is contained in:
Ryan C. Gordon 2017-01-23 01:05:44 -05:00
parent 202ab30c16
commit 3594bf8eeb
6 changed files with 132 additions and 14 deletions

View File

@ -262,6 +262,7 @@ set_option(MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
set_option(3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
set_option(SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
set_option(SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
set_option(SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
set_option(ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
set_option(DISKAUDIO "Support the disk writer audio driver" ON)
set_option(DUMMYAUDIO "Support the dummy audio driver" ON)
@ -516,8 +517,31 @@ if(ASSEMBLY)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
endif()
if(SSE3)
set(CMAKE_REQUIRED_FLAGS "-msse3")
check_c_source_compiles("
#ifdef __MINGW32__
#include <_mingw.h>
#ifdef __MINGW64_VERSION_MAJOR
#include <intrin.h>
#else
#include <pmmintrin.h>
#endif
#else
#include <pmmintrin.h>
#endif
#ifndef __SSE3__
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { }" HAVE_SSE3)
if(HAVE_SSE3)
list(APPEND EXTRA_CFLAGS "-msse3")
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
endif()
if(SSEMATH)
if(SSE OR SSE2)
if(SSE OR SSE2 OR SSE3)
if(USE_GCC)
list(APPEND EXTRA_CFLAGS "-mfpmath=387")
endif()
@ -557,12 +581,13 @@ if(ASSEMBLY)
endif()
set(HAVE_SSE TRUE)
set(HAVE_SSE2 TRUE)
set(HAVE_SSE3 TRUE)
set(SDL_ASSEMBLY_ROUTINES 1)
endif()
# TODO:
#else()
# if(USE_GCC OR USE_CLANG)
# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-sse3" "-mno-mmx")
# endif()
endif()

61
configure vendored
View File

@ -798,6 +798,7 @@ enable_mmx
enable_3dnow
enable_sse
enable_sse2
enable_sse3
enable_altivec
enable_oss
enable_alsa
@ -1527,7 +1528,8 @@ Optional Features:
--enable-mmx use MMX assembly routines [[default=yes]]
--enable-3dnow use 3DNow! assembly routines [[default=yes]]
--enable-sse use SSE assembly routines [[default=yes]]
--enable-sse2 use SSE2 assembly routines [[default=no]]
--enable-sse2 use SSE2 assembly routines [[default=maybe]]
--enable-sse3 use SSE3 assembly routines [[default=maybe]]
--enable-altivec use Altivec assembly routines [[default=yes]]
--enable-oss support the OSS audio API [[default=maybe]]
--enable-alsa support the ALSA audio API [[default=yes]]
@ -17308,6 +17310,63 @@ $as_echo "$have_gcc_sse2" >&6; }
fi
fi
# Check whether --enable-sse3 was given.
if test "${enable_sse3+set}" = set; then :
enableval=$enable_sse3;
else
enable_sse3=$default_ssemath
fi
if test x$enable_sse3 = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_sse3=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -msse3 option" >&5
$as_echo_n "checking for GCC -msse3 option... " >&6; }
sse3_CFLAGS="-msse3"
CFLAGS="$save_CFLAGS $sse3_CFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __MINGW32__
#include <_mingw.h>
#ifdef __MINGW64_VERSION_MAJOR
#include <intrin.h>
#else
#include <pmmintrin.h>
#endif
#else
#include <pmmintrin.h>
#endif
#ifndef __SSE2__
#error Assembler CPP flag not enabled
#endif
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
have_gcc_sse3=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse3" >&5
$as_echo "$have_gcc_sse3" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_sse3 = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
SUMMARY_math="${SUMMARY_math} sse3"
fi
fi
# Check whether --enable-altivec was given.
if test "${enable_altivec+set}" = set; then :
enableval=$enable_altivec;

View File

@ -593,7 +593,7 @@ AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
fi
AC_ARG_ENABLE(sse2,
AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]),
, enable_sse2=$default_ssemath)
if test x$enable_sse2 = xyes; then
save_CFLAGS="$CFLAGS"
@ -629,6 +629,43 @@ AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
fi
fi
AC_ARG_ENABLE(sse3,
AC_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
, enable_sse3=$default_ssemath)
if test x$enable_sse3 = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_sse3=no
AC_MSG_CHECKING(for GCC -msse3 option)
sse3_CFLAGS="-msse3"
CFLAGS="$save_CFLAGS $sse3_CFLAGS"
AC_TRY_COMPILE([
#ifdef __MINGW32__
#include <_mingw.h>
#ifdef __MINGW64_VERSION_MAJOR
#include <intrin.h>
#else
#include <pmmintrin.h>
#endif
#else
#include <pmmintrin.h>
#endif
#ifndef __SSE2__
#error Assembler CPP flag not enabled
#endif
],[
],[
have_gcc_sse3=yes
])
AC_MSG_RESULT($have_gcc_sse3)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_sse3 = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
SUMMARY_math="${SUMMARY_math} sse3"
fi
fi
AC_ARG_ENABLE(altivec,
AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
, enable_altivec=yes)

View File

@ -61,6 +61,9 @@
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#ifdef __SSE3__
#include <pmmintrin.h>
#endif
#endif
#include "begin_code.h"

View File

@ -28,13 +28,10 @@
#include "SDL_loadso.h"
#include "SDL_assert.h"
#include "../SDL_dataqueue.h"
/* !!! FIXME: wire this up to the configure script, etc. */
#include "SDL_cpuinfo.h"
#define HAVE_SSE3_INTRINSICS 0
#if HAVE_SSE3_INTRINSICS
#include <pmmintrin.h>
#ifdef __SSE3__
#define HAVE_SSE3_INTRINSICS 1
#endif
#if HAVE_SSE3_INTRINSICS

View File

@ -28,11 +28,8 @@
/* !!! FIXME: write NEON code. */
#define HAVE_NEON_INTRINSICS 0
/* !!! FIXME: wire this up to the configure script, etc. */
#define HAVE_SSE2_INTRINSICS 0
#if HAVE_SSE2_INTRINSICS
#include <emmintrin.h>
#ifdef __SSE2__
#define HAVE_SSE2_INTRINSICS 1
#endif
#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS