Commit b078fb19 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40881
parent 4007c1de
...@@ -102,11 +102,11 @@ static char rcsid = ...@@ -102,11 +102,11 @@ static char rcsid =
#include "SDL_memops.h" #include "SDL_memops.h"
#include "SDL_RLEaccel_c.h" #include "SDL_RLEaccel_c.h"
#if defined(i386) || defined(__x86_64__) #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define MMX_CAPABLE #define MMX_ASMBLIT
#endif #endif
#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
#include "mmx.h" #include "mmx.h"
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#endif #endif
...@@ -134,7 +134,7 @@ do { \ ...@@ -134,7 +134,7 @@ do { \
#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ #define OPAQUE_BLIT(to, from, length, bpp, alpha) \
PIXEL_COPY(to, from, length, bpp) PIXEL_COPY(to, from, length, bpp)
#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
#define ALPHA_BLIT32_888MMX(to, from, length, bpp, alpha) \ #define ALPHA_BLIT32_888MMX(to, from, length, bpp, alpha) \
do { \ do { \
...@@ -515,7 +515,7 @@ do { \ ...@@ -515,7 +515,7 @@ do { \
} \ } \
} while(0) } while(0)
#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
#define ALPHA_BLIT32_888_50MMX(to, from, length, bpp, alpha) \ #define ALPHA_BLIT32_888_50MMX(to, from, length, bpp, alpha) \
do { \ do { \
...@@ -628,7 +628,7 @@ do { \ ...@@ -628,7 +628,7 @@ do { \
#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ #define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \
ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde) ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde)
#if defined(MMX_CAPABLE) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
#define CHOOSE_BLIT(blitter, alpha, fmt) \ #define CHOOSE_BLIT(blitter, alpha, fmt) \
do { \ do { \
......
...@@ -37,7 +37,11 @@ static char rcsid = ...@@ -37,7 +37,11 @@ static char rcsid =
#include "SDL_pixels_c.h" #include "SDL_pixels_c.h"
#include "SDL_memops.h" #include "SDL_memops.h"
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define MMX_ASMBLIT
#endif
#if defined(MMX_ASMBLIT)
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#include "mmx.h" #include "mmx.h"
#endif #endif
...@@ -111,7 +115,7 @@ static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -111,7 +115,7 @@ static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
return(okay ? 0 : -1); return(okay ? 0 : -1);
} }
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
void SDL_memcpyMMX(char* to,char* from,int len) void SDL_memcpyMMX(char* to,char* from,int len)
{ {
int i; int i;
...@@ -165,7 +169,7 @@ static void SDL_BlitCopy(SDL_BlitInfo *info) ...@@ -165,7 +169,7 @@ static void SDL_BlitCopy(SDL_BlitInfo *info)
dst = info->d_pixels; dst = info->d_pixels;
srcskip = w+info->s_skip; srcskip = w+info->s_skip;
dstskip = w+info->d_skip; dstskip = w+info->d_skip;
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
if(SDL_HasSSE()) if(SDL_HasSSE())
{ {
while ( h-- ) { while ( h-- ) {
......
...@@ -31,7 +31,11 @@ static char rcsid = ...@@ -31,7 +31,11 @@ static char rcsid =
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define MMX_ASMBLIT
#endif
#ifdef MMX_ASMBLIT
/* Function to check the CPU flags */ /* Function to check the CPU flags */
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#include "mmx.h" #include "mmx.h"
...@@ -201,7 +205,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) ...@@ -201,7 +205,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
} }
} }
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
/* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info) static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
{ {
...@@ -557,7 +561,7 @@ static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info) ...@@ -557,7 +561,7 @@ static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
} }
} }
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
/* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info) inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info)
{ {
...@@ -759,7 +763,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) ...@@ -759,7 +763,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
} }
} }
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
/* fast RGB565->RGB565 blending with surface alpha */ /* fast RGB565->RGB565 blending with surface alpha */
static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
{ {
...@@ -1379,7 +1383,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) ...@@ -1379,7 +1383,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
if(surface->map->identity) { if(surface->map->identity) {
if(df->Gmask == 0x7e0) if(df->Gmask == 0x7e0)
{ {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
if(SDL_HasMMX()) if(SDL_HasMMX())
return Blit565to565SurfaceAlphaMMX; return Blit565to565SurfaceAlphaMMX;
else else
...@@ -1388,7 +1392,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) ...@@ -1388,7 +1392,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
} }
else if(df->Gmask == 0x3e0) else if(df->Gmask == 0x3e0)
{ {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
if(SDL_HasMMX()) if(SDL_HasMMX())
return Blit555to555SurfaceAlphaMMX; return Blit555to555SurfaceAlphaMMX;
else else
...@@ -1405,7 +1409,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) ...@@ -1405,7 +1409,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
&& (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff
&& sf->BytesPerPixel == 4) && sf->BytesPerPixel == 4)
{ {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
if(SDL_HasMMX()) if(SDL_HasMMX())
return BlitRGBtoRGBSurfaceAlphaMMX; return BlitRGBtoRGBSurfaceAlphaMMX;
else else
...@@ -1445,7 +1449,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) ...@@ -1445,7 +1449,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
&& sf->Bmask == df->Bmask && sf->Bmask == df->Bmask
&& sf->BytesPerPixel == 4) && sf->BytesPerPixel == 4)
{ {
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) #ifdef MMX_ASMBLIT
if(SDL_Has3DNow()) if(SDL_Has3DNow())
return BlitRGBtoRGBPixelAlphaMMX3DNOW; return BlitRGBtoRGBPixelAlphaMMX3DNOW;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment