comparison src/video/SDL_blit_A.c @ 880:9ef41050100c

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.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 11 Apr 2004 19:47:28 +0000
parents b8d311d90021
children ffaaf7ecf685
comparison
equal deleted inserted replaced
879:2bacec7930b1 880:9ef41050100c
29 29
30 #include "SDL_types.h" 30 #include "SDL_types.h"
31 #include "SDL_video.h" 31 #include "SDL_video.h"
32 #include "SDL_blit.h" 32 #include "SDL_blit.h"
33 33
34 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 34 #if (defined(i386) || defined(__x86_64__)) && defined(__GNUC__) && defined(USE_ASMBLIT)
35 #define MMX_ASMBLIT
36 #endif
37
38 #ifdef MMX_ASMBLIT
35 /* Function to check the CPU flags */ 39 /* Function to check the CPU flags */
36 #include "SDL_cpuinfo.h" 40 #include "SDL_cpuinfo.h"
37 #include "mmx.h" 41 #include "mmx.h"
38 #endif 42 #endif
39 43
199 src += srcskip; 203 src += srcskip;
200 dst += dstskip; 204 dst += dstskip;
201 } 205 }
202 } 206 }
203 207
204 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 208 #ifdef MMX_ASMBLIT
205 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ 209 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
206 static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info) 210 static void BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
207 { 211 {
208 int width = info->d_width; 212 int width = info->d_width;
209 int height = info->d_height; 213 int height = info->d_height;
555 srcp += srcskip; 559 srcp += srcskip;
556 dstp += dstskip; 560 dstp += dstskip;
557 } 561 }
558 } 562 }
559 563
560 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 564 #ifdef MMX_ASMBLIT
561 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ 565 /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */
562 inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info) 566 inline static void BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo *info)
563 { 567 {
564 int width = info->d_width; 568 int width = info->d_width;
565 int height = info->d_height; 569 int height = info->d_height;
757 dstp += dstskip; 761 dstp += dstskip;
758 } 762 }
759 } 763 }
760 } 764 }
761 765
762 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 766 #ifdef MMX_ASMBLIT
763 /* fast RGB565->RGB565 blending with surface alpha */ 767 /* fast RGB565->RGB565 blending with surface alpha */
764 static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) 768 static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
765 { 769 {
766 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ 770 unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
767 if(alpha == 128) { 771 if(alpha == 128) {
1377 1381
1378 case 2: 1382 case 2:
1379 if(surface->map->identity) { 1383 if(surface->map->identity) {
1380 if(df->Gmask == 0x7e0) 1384 if(df->Gmask == 0x7e0)
1381 { 1385 {
1382 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1386 #ifdef MMX_ASMBLIT
1383 if(SDL_HasMMX()) 1387 if(SDL_HasMMX())
1384 return Blit565to565SurfaceAlphaMMX; 1388 return Blit565to565SurfaceAlphaMMX;
1385 else 1389 else
1386 #endif 1390 #endif
1387 return Blit565to565SurfaceAlpha; 1391 return Blit565to565SurfaceAlpha;
1388 } 1392 }
1389 else if(df->Gmask == 0x3e0) 1393 else if(df->Gmask == 0x3e0)
1390 { 1394 {
1391 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1395 #ifdef MMX_ASMBLIT
1392 if(SDL_HasMMX()) 1396 if(SDL_HasMMX())
1393 return Blit555to555SurfaceAlphaMMX; 1397 return Blit555to555SurfaceAlphaMMX;
1394 else 1398 else
1395 #endif 1399 #endif
1396 return Blit555to555SurfaceAlpha; 1400 return Blit555to555SurfaceAlpha;
1403 && sf->Gmask == df->Gmask 1407 && sf->Gmask == df->Gmask
1404 && sf->Bmask == df->Bmask 1408 && sf->Bmask == df->Bmask
1405 && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff 1409 && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff
1406 && sf->BytesPerPixel == 4) 1410 && sf->BytesPerPixel == 4)
1407 { 1411 {
1408 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1412 #ifdef MMX_ASMBLIT
1409 if(SDL_HasMMX()) 1413 if(SDL_HasMMX())
1410 return BlitRGBtoRGBSurfaceAlphaMMX; 1414 return BlitRGBtoRGBSurfaceAlphaMMX;
1411 else 1415 else
1412 #endif 1416 #endif
1413 return BlitRGBtoRGBSurfaceAlpha; 1417 return BlitRGBtoRGBSurfaceAlpha;
1443 && sf->Rmask == df->Rmask 1447 && sf->Rmask == df->Rmask
1444 && sf->Gmask == df->Gmask 1448 && sf->Gmask == df->Gmask
1445 && sf->Bmask == df->Bmask 1449 && sf->Bmask == df->Bmask
1446 && sf->BytesPerPixel == 4) 1450 && sf->BytesPerPixel == 4)
1447 { 1451 {
1448 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1452 #ifdef MMX_ASMBLIT
1449 if(SDL_Has3DNow()) 1453 if(SDL_Has3DNow())
1450 return BlitRGBtoRGBPixelAlphaMMX3DNOW; 1454 return BlitRGBtoRGBPixelAlphaMMX3DNOW;
1451 else 1455 else
1452 if(SDL_HasMMX()) 1456 if(SDL_HasMMX())
1453 return BlitRGBtoRGBPixelAlphaMMX; 1457 return BlitRGBtoRGBPixelAlphaMMX;