Enabled 3DNow! intrinsic support
authorSam Lantinga <slouken@libsdl.org>
Fri, 17 Aug 2007 03:22:03 +0000
changeset 2261c20476d7d7b3
parent 2260 202ddfd1cfb1
child 2262 bee005ace1bf
Enabled 3DNow! intrinsic support
VisualC/SDL/SDL.vcproj
configure.in
src/video/SDL_blit.h
src/video/SDL_blit_A.c
     1.1 --- a/VisualC/SDL/SDL.vcproj	Fri Aug 17 02:55:21 2007 +0000
     1.2 +++ b/VisualC/SDL/SDL.vcproj	Fri Aug 17 03:22:03 2007 +0000
     1.3 @@ -47,7 +47,7 @@
     1.4  				Name="VCCLCompilerTool"
     1.5  				Optimization="0"
     1.6  				AdditionalIncludeDirectories="..\..\include"
     1.7 -				PreprocessorDefinitions="_DEBUG;_WINDOWS;_WIN32_WINNT=0x0400;__SSE__;__MMX__"
     1.8 +				PreprocessorDefinitions="_DEBUG;_WINDOWS;_WIN32_WINNT=0x0400;__MMX__;__3dNOW__;__SSE__"
     1.9  				RuntimeLibrary="2"
    1.10  				BufferSecurityCheck="false"
    1.11  				UsePrecompiledHeader="0"
    1.12 @@ -145,7 +145,7 @@
    1.13  				InlineFunctionExpansion="1"
    1.14  				EnableIntrinsicFunctions="false"
    1.15  				AdditionalIncludeDirectories="..\..\include"
    1.16 -				PreprocessorDefinitions="NDEBUG;_WINDOWS;_WIN32_WINNT=0x0400;__SSE__;__MMX__"
    1.17 +				PreprocessorDefinitions="NDEBUG;_WINDOWS;_WIN32_WINNT=0x0400;__MMX__;__3dNOW__;__SSE__"
    1.18  				StringPooling="true"
    1.19  				RuntimeLibrary="2"
    1.20  				BufferSecurityCheck="false"
     2.1 --- a/configure.in	Fri Aug 17 02:55:21 2007 +0000
     2.2 +++ b/configure.in	Fri Aug 17 03:22:03 2007 +0000
     2.3 @@ -290,6 +290,9 @@
     2.4  
     2.5          AC_TRY_COMPILE([
     2.6          #include <mmintrin.h>
     2.7 +        #ifndef __MMX__
     2.8 +        #error Assembler CPP flag not enabled
     2.9 +        #endif
    2.10          ],[
    2.11          ],[
    2.12          have_gcc_mmx=yes
    2.13 @@ -301,6 +304,32 @@
    2.14          fi
    2.15      fi
    2.16  
    2.17 +    AC_ARG_ENABLE(3dnow,
    2.18 +AC_HELP_STRING([--enable-3dnow], [use MMX assembly routines [[default=yes]]]),
    2.19 +                  , enable_3dnow=yes)
    2.20 +    if test x$enable_3dnow = xyes; then
    2.21 +        save_CFLAGS="$CFLAGS"
    2.22 +        have_gcc_3dnow=no
    2.23 +        AC_MSG_CHECKING(for GCC -m3dnow option)
    2.24 +        amd3dnow_CFLAGS="-m3dnow"
    2.25 +        CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
    2.26 +
    2.27 +        AC_TRY_COMPILE([
    2.28 +        #include <mm3dnow.h>
    2.29 +        #ifndef __3dNOW__
    2.30 +        #error Assembler CPP flag not enabled
    2.31 +        #endif
    2.32 +        ],[
    2.33 +        ],[
    2.34 +        have_gcc_3dnow=yes
    2.35 +        ])
    2.36 +        AC_MSG_RESULT($have_gcc_3dnow)
    2.37 +
    2.38 +        if test x$have_gcc_3dnow = xyes; then
    2.39 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
    2.40 +        fi
    2.41 +    fi
    2.42 +
    2.43      AC_ARG_ENABLE(sse,
    2.44  AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
    2.45                    , enable_sse=yes)
    2.46 @@ -313,6 +342,9 @@
    2.47  
    2.48          AC_TRY_COMPILE([
    2.49          #include <xmmintrin.h>
    2.50 +        #ifndef __SSE__
    2.51 +        #error Assembler CPP flag not enabled
    2.52 +        #endif
    2.53          ],[
    2.54          ],[
    2.55          have_gcc_sse=yes
     3.1 --- a/src/video/SDL_blit.h	Fri Aug 17 02:55:21 2007 +0000
     3.2 +++ b/src/video/SDL_blit.h	Fri Aug 17 03:22:03 2007 +0000
     3.3 @@ -27,6 +27,9 @@
     3.4  #ifdef __MMX__
     3.5  #include <mmintrin.h>
     3.6  #endif
     3.7 +#ifdef __3dNOW__
     3.8 +#include <mm3dnow.h>
     3.9 +#endif
    3.10  #ifdef __SSE__
    3.11  #include <xmmintrin.h>
    3.12  #endif
     4.1 --- a/src/video/SDL_blit_A.c	Fri Aug 17 02:55:21 2007 +0000
     4.2 +++ b/src/video/SDL_blit_A.c	Fri Aug 17 03:22:03 2007 +0000
     4.3 @@ -1369,7 +1369,7 @@
     4.4      }
     4.5  }
     4.6  
     4.7 -#ifdef __MMX__
     4.8 +#ifdef __3dNOW__
     4.9  /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
    4.10  static void
    4.11  BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
    4.12 @@ -2250,17 +2250,21 @@
    4.13              if (sf->Rmask == df->Rmask
    4.14                  && sf->Gmask == df->Gmask
    4.15                  && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
    4.16 -#ifdef __MMX__
    4.17 +#if defined(__MMX__) || defined(__3dNOW__)
    4.18                  if (sf->Rshift % 8 == 0
    4.19                      && sf->Gshift % 8 == 0
    4.20                      && sf->Bshift % 8 == 0
    4.21                      && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
    4.22 +#ifdef __3dNOW__
    4.23                      if (SDL_Has3DNow())
    4.24                          return BlitRGBtoRGBPixelAlphaMMX3DNOW;
    4.25 +#endif
    4.26 +#ifdef __MMX__
    4.27                      if (SDL_HasMMX())
    4.28                          return BlitRGBtoRGBPixelAlphaMMX;
    4.29 +#endif
    4.30                  }
    4.31 -#endif
    4.32 +#endif /* __MMX__ || __3dNOW__ */
    4.33                  if (sf->Amask == 0xff000000) {
    4.34  #if SDL_ALTIVEC_BLITTERS
    4.35                      if (SDL_HasAltiVec())