Date: Tue, 30 Mar 2004 21:26:47 -0600
authorSam Lantinga <slouken@libsdl.org>
Sun, 11 Apr 2004 19:47:28 +0000
changeset 8809ef41050100c
parent 879 2bacec7930b1
child 881 9eb85a211abd
Date: Tue, 30 Mar 2004 21:26:47 -0600
From: Tyler Montbriand
Subject: [SDL] Opteron MMX patches for SDL_blit.c and SDL_blit_A.c

The inline MMX assembly in SDL_blit.c and SDL_blit_A.c compiles and runs fine
unmodified under AMD Opteron. The inline assembly in SDL_yuv_mmx.c and
SDL_blit_N.c unfortunately isn't directly compatible.

I've included diffs from SDL_blit.c and SDL_blit_A.c that allow the MMX
assembly to be compiled when USE_ASMBLIT, __x86_64__, and __GNUC__ are all
defined. All I had to modify was typedefs, the inline assembly itself wasn't
touched.
src/video/SDL_RLEaccel.c
src/video/SDL_blit.c
src/video/SDL_blit_A.c
     1.1 --- a/src/video/SDL_RLEaccel.c	Thu Apr 08 21:13:14 2004 +0000
     1.2 +++ b/src/video/SDL_RLEaccel.c	Sun Apr 11 19:47:28 2004 +0000
     1.3 @@ -102,11 +102,11 @@
     1.4  #include "SDL_memops.h"
     1.5  #include "SDL_RLEaccel_c.h"
     1.6  
     1.7 -#if defined(i386) || defined(__x86_64__)
     1.8 -#define MMX_CAPABLE
     1.9 +#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
    1.10 +#define MMX_ASMBLIT
    1.11  #endif
    1.12  
    1.13 -#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT)
    1.14 +#ifdef MMX_ASMBLIT
    1.15  #include "mmx.h"
    1.16  #include "SDL_cpuinfo.h"
    1.17  #endif
    1.18 @@ -134,7 +134,7 @@
    1.19  #define OPAQUE_BLIT(to, from, length, bpp, alpha)	\
    1.20      PIXEL_COPY(to, from, length, bpp)
    1.21  
    1.22 -#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT)
    1.23 +#ifdef MMX_ASMBLIT
    1.24  
    1.25  #define ALPHA_BLIT32_888MMX(to, from, length, bpp, alpha)	\
    1.26      do {							\
    1.27 @@ -515,7 +515,7 @@
    1.28  	}								\
    1.29      } while(0)
    1.30  
    1.31 -#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT)
    1.32 +#ifdef MMX_ASMBLIT
    1.33  
    1.34  #define ALPHA_BLIT32_888_50MMX(to, from, length, bpp, alpha)		\
    1.35      do {								\
    1.36 @@ -628,7 +628,7 @@
    1.37  #define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha)	\
    1.38      ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde)
    1.39  
    1.40 -#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT)
    1.41 +#ifdef MMX_ASMBLIT
    1.42  
    1.43  #define CHOOSE_BLIT(blitter, alpha, fmt)				\
    1.44      do {								\
     2.1 --- a/src/video/SDL_blit.c	Thu Apr 08 21:13:14 2004 +0000
     2.2 +++ b/src/video/SDL_blit.c	Sun Apr 11 19:47:28 2004 +0000
     2.3 @@ -37,7 +37,11 @@
     2.4  #include "SDL_pixels_c.h"
     2.5  #include "SDL_memops.h"
     2.6  
     2.7 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
     2.8 +#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
     2.9 +#define MMX_ASMBLIT
    2.10 +#endif
    2.11 +
    2.12 +#if defined(MMX_ASMBLIT)
    2.13  #include "SDL_cpuinfo.h"
    2.14  #include "mmx.h"
    2.15  #endif
    2.16 @@ -111,7 +115,7 @@
    2.17  	return(okay ? 0 : -1);
    2.18  }
    2.19  
    2.20 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    2.21 +#ifdef MMX_ASMBLIT
    2.22  void SDL_memcpyMMX(char* to,char* from,int len)
    2.23  {
    2.24  	int i;
    2.25 @@ -165,7 +169,7 @@
    2.26  	dst = info->d_pixels;
    2.27  	srcskip = w+info->s_skip;
    2.28  	dstskip = w+info->d_skip;
    2.29 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    2.30 +#ifdef MMX_ASMBLIT
    2.31  	if(SDL_HasSSE())
    2.32  	{
    2.33  		while ( h-- ) {
     3.1 --- a/src/video/SDL_blit_A.c	Thu Apr 08 21:13:14 2004 +0000
     3.2 +++ b/src/video/SDL_blit_A.c	Sun Apr 11 19:47:28 2004 +0000
     3.3 @@ -31,7 +31,11 @@
     3.4  #include "SDL_video.h"
     3.5  #include "SDL_blit.h"
     3.6  
     3.7 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
     3.8 +#if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
     3.9 +#define MMX_ASMBLIT
    3.10 +#endif
    3.11 +
    3.12 +#ifdef MMX_ASMBLIT
    3.13  /* Function to check the CPU flags */
    3.14  #include "SDL_cpuinfo.h"
    3.15  #include "mmx.h"
    3.16 @@ -201,7 +205,7 @@
    3.17  	}
    3.18  }
    3.19  
    3.20 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.21 +#ifdef MMX_ASMBLIT
    3.22  /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
    3.23  static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
    3.24  {
    3.25 @@ -557,7 +561,7 @@
    3.26  	}
    3.27  }
    3.28  
    3.29 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.30 +#ifdef MMX_ASMBLIT
    3.31  /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
    3.32  inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info)
    3.33  {
    3.34 @@ -759,7 +763,7 @@
    3.35  	}
    3.36  }
    3.37  
    3.38 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.39 +#ifdef MMX_ASMBLIT
    3.40  /* fast RGB565->RGB565 blending with surface alpha */
    3.41  static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
    3.42  {
    3.43 @@ -1379,7 +1383,7 @@
    3.44  		if(surface->map->identity) {
    3.45  		    if(df->Gmask == 0x7e0)
    3.46  		    {
    3.47 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.48 +#ifdef MMX_ASMBLIT
    3.49  		if(SDL_HasMMX())
    3.50  			return Blit565to565SurfaceAlphaMMX;
    3.51  		else
    3.52 @@ -1388,7 +1392,7 @@
    3.53  		    }
    3.54  		    else if(df->Gmask == 0x3e0)
    3.55  		    {
    3.56 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.57 +#ifdef MMX_ASMBLIT
    3.58  		if(SDL_HasMMX())
    3.59  			return Blit555to555SurfaceAlphaMMX;
    3.60  		else
    3.61 @@ -1405,7 +1409,7 @@
    3.62  		   && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff
    3.63  		   && sf->BytesPerPixel == 4)
    3.64  		{
    3.65 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.66 +#ifdef MMX_ASMBLIT
    3.67  		if(SDL_HasMMX())
    3.68  		    return BlitRGBtoRGBSurfaceAlphaMMX;
    3.69  		else
    3.70 @@ -1445,7 +1449,7 @@
    3.71  	       && sf->Bmask == df->Bmask
    3.72  	       && sf->BytesPerPixel == 4)
    3.73  	    {
    3.74 -#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.75 +#ifdef MMX_ASMBLIT
    3.76  		if(SDL_Has3DNow())
    3.77  		    return BlitRGBtoRGBPixelAlphaMMX3DNOW;
    3.78  		else