Commit 47107f28 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Enable altivec blitters on PowerPC Linux, and some fixes for recent

 GCCs versions.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401165
parent dba88d23
...@@ -1910,11 +1910,16 @@ CheckUSBHID() ...@@ -1910,11 +1910,16 @@ CheckUSBHID()
dnl Check for altivec instruction support using gas syntax dnl Check for altivec instruction support using gas syntax
CheckAltivec() CheckAltivec()
{ {
AC_MSG_CHECKING(for GCC Altivec instruction support) dnl FIXME: Theoretically, you might not have altivec.h, we should check
have_gcc_altivec=no dnl FIXME: that seperately, but I think all major platforms have it
dnl FIXME: at the moment... --ryan.
save_CFLAGS="${CFLAGS}" save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec" have_gcc_altivec=no
AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
CFLAGS="${save_CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -maltivec"
AC_TRY_COMPILE([ AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() { vector unsigned int vzero() {
return vec_splat_u32(0); return vec_splat_u32(0);
} }
...@@ -1922,10 +1927,26 @@ CheckAltivec() ...@@ -1922,10 +1927,26 @@ CheckAltivec()
],[ ],[
have_gcc_altivec=yes have_gcc_altivec=yes
]) ])
AC_MSG_RESULT($have_gcc_altivec)
if test x$have_gcc_altivec = xno; then
AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
])
AC_MSG_RESULT($have_gcc_altivec)
fi
if test x$have_gcc_altivec = xno; then if test x$have_gcc_altivec = xno; then
CFLAGS="${save_CFLAGS}" CFLAGS="${save_CFLAGS}"
fi fi
AC_MSG_RESULT($have_gcc_altivec)
} }
dnl Check for a valid linux/version.h dnl Check for a valid linux/version.h
......
...@@ -90,112 +90,112 @@ extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex); ...@@ -90,112 +90,112 @@ extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
/* Load pixel of the specified format from a buffer and get its R-G-B values */ /* Load pixel of the specified format from a buffer and get its R-G-B values */
/* FIXME: rescale values to 0..255 here? */ /* FIXME: rescale values to 0..255 here? */
#define RGB_FROM_PIXEL(pixel, fmt, r, g, b) \ #define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \
{ \ { \
r = (((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \ r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \
g = (((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \ g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
b = (((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \ b = (((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \
} }
#define RGB_FROM_RGB565(pixel, r, g, b) \ #define RGB_FROM_RGB565(Pixel, r, g, b) \
{ \ { \
r = (((pixel&0xF800)>>11)<<3); \ r = (((Pixel&0xF800)>>11)<<3); \
g = (((pixel&0x07E0)>>5)<<2); \ g = (((Pixel&0x07E0)>>5)<<2); \
b = ((pixel&0x001F)<<3); \ b = ((Pixel&0x001F)<<3); \
} }
#define RGB_FROM_RGB555(pixel, r, g, b) \ #define RGB_FROM_RGB555(Pixel, r, g, b) \
{ \ { \
r = (((pixel&0x7C00)>>10)<<3); \ r = (((Pixel&0x7C00)>>10)<<3); \
g = (((pixel&0x03E0)>>5)<<3); \ g = (((Pixel&0x03E0)>>5)<<3); \
b = ((pixel&0x001F)<<3); \ b = ((Pixel&0x001F)<<3); \
} }
#define RGB_FROM_RGB888(pixel, r, g, b) \ #define RGB_FROM_RGB888(Pixel, r, g, b) \
{ \ { \
r = ((pixel&0xFF0000)>>16); \ r = ((Pixel&0xFF0000)>>16); \
g = ((pixel&0xFF00)>>8); \ g = ((Pixel&0xFF00)>>8); \
b = (pixel&0xFF); \ b = (Pixel&0xFF); \
} }
#define RETRIEVE_RGB_PIXEL(buf, bpp, pixel) \ #define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
do { \ do { \
switch (bpp) { \ switch (bpp) { \
case 2: \ case 2: \
pixel = *((Uint16 *)(buf)); \ Pixel = *((Uint16 *)(buf)); \
break; \ break; \
\ \
case 3: { \ case 3: { \
Uint8 *B = (Uint8 *)(buf); \ Uint8 *B = (Uint8 *)(buf); \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \ } else { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \ } \
} \ } \
break; \ break; \
\ \
case 4: \ case 4: \
pixel = *((Uint32 *)(buf)); \ Pixel = *((Uint32 *)(buf)); \
break; \ break; \
\ \
default: \ default: \
pixel = 0; /* appease gcc */ \ Pixel = 0; /* appease gcc */ \
break; \ break; \
} \ } \
} while(0) } while(0)
#define DISEMBLE_RGB(buf, bpp, fmt, pixel, r, g, b) \ #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
do { \ do { \
switch (bpp) { \ switch (bpp) { \
case 2: \ case 2: \
pixel = *((Uint16 *)(buf)); \ Pixel = *((Uint16 *)(buf)); \
break; \ break; \
\ \
case 3: { \ case 3: { \
Uint8 *B = (Uint8 *)buf; \ Uint8 *B = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \ } else { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \ } \
} \ } \
break; \ break; \
\ \
case 4: \ case 4: \
pixel = *((Uint32 *)(buf)); \ Pixel = *((Uint32 *)(buf)); \
break; \ break; \
\ \
default: \ default: \
pixel = 0; /* prevent gcc from complaining */ \ Pixel = 0; /* prevent gcc from complaining */ \
break; \ break; \
} \ } \
RGB_FROM_PIXEL(pixel, fmt, r, g, b); \ RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
} while(0) } while(0)
/* Assemble R-G-B values into a specified pixel format and store them */ /* Assemble R-G-B values into a specified pixel format and store them */
#define PIXEL_FROM_RGB(pixel, fmt, r, g, b) \ #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \
{ \ { \
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \ ((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift); \ ((b>>fmt->Bloss)<<fmt->Bshift); \
} }
#define RGB565_FROM_RGB(pixel, r, g, b) \ #define RGB565_FROM_RGB(Pixel, r, g, b) \
{ \ { \
pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \ Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \
} }
#define RGB555_FROM_RGB(pixel, r, g, b) \ #define RGB555_FROM_RGB(Pixel, r, g, b) \
{ \ { \
pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \ Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \
} }
#define RGB888_FROM_RGB(pixel, r, g, b) \ #define RGB888_FROM_RGB(Pixel, r, g, b) \
{ \ { \
pixel = (r<<16)|(g<<8)|b; \ Pixel = (r<<16)|(g<<8)|b; \
} }
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
{ \ { \
switch (bpp) { \ switch (bpp) { \
case 2: { \ case 2: { \
Uint16 pixel; \ Uint16 Pixel; \
\ \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \ PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = pixel; \ *((Uint16 *)(buf)) = Pixel; \
} \ } \
break; \ break; \
\ \
...@@ -213,10 +213,10 @@ do { \ ...@@ -213,10 +213,10 @@ do { \
break; \ break; \
\ \
case 4: { \ case 4: { \
Uint32 pixel; \ Uint32 Pixel; \
\ \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \ PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = pixel; \ *((Uint32 *)(buf)) = Pixel; \
} \ } \
break; \ break; \
} \ } \
...@@ -226,11 +226,11 @@ do { \ ...@@ -226,11 +226,11 @@ do { \
switch (bpp) { \ switch (bpp) { \
case 2: { \ case 2: { \
Uint16 *bufp; \ Uint16 *bufp; \
Uint16 pixel; \ Uint16 Pixel; \
\ \
bufp = (Uint16 *)buf; \ bufp = (Uint16 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \ PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \ *bufp = Pixel | (*bufp & Amask); \
} \ } \
break; \ break; \
\ \
...@@ -249,85 +249,85 @@ do { \ ...@@ -249,85 +249,85 @@ do { \
\ \
case 4: { \ case 4: { \
Uint32 *bufp; \ Uint32 *bufp; \
Uint32 pixel; \ Uint32 Pixel; \
\ \
bufp = (Uint32 *)buf; \ bufp = (Uint32 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \ PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \ *bufp = Pixel | (*bufp & Amask); \
} \ } \
break; \ break; \
} \ } \
} }
/* FIXME: Should we rescale alpha into 0..255 here? */ /* FIXME: Should we rescale alpha into 0..255 here? */
#define RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \ #define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \
{ \ { \
r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \ r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \ g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \ b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \ a = ((Pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
} }
#define RGBA_FROM_8888(pixel, fmt, r, g, b, a) \ #define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \
{ \ { \
r = (pixel&fmt->Rmask)>>fmt->Rshift; \ r = (Pixel&fmt->Rmask)>>fmt->Rshift; \
g = (pixel&fmt->Gmask)>>fmt->Gshift; \ g = (Pixel&fmt->Gmask)>>fmt->Gshift; \
b = (pixel&fmt->Bmask)>>fmt->Bshift; \ b = (Pixel&fmt->Bmask)>>fmt->Bshift; \
a = (pixel&fmt->Amask)>>fmt->Ashift; \ a = (Pixel&fmt->Amask)>>fmt->Ashift; \
} }
#define RGBA_FROM_RGBA8888(pixel, r, g, b, a) \ #define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \
{ \ { \
r = (pixel>>24); \ r = (Pixel>>24); \
g = ((pixel>>16)&0xFF); \ g = ((Pixel>>16)&0xFF); \
b = ((pixel>>8)&0xFF); \ b = ((Pixel>>8)&0xFF); \
a = (pixel&0xFF); \ a = (Pixel&0xFF); \
} }
#define RGBA_FROM_ARGB8888(pixel, r, g, b, a) \ #define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \
{ \ { \
r = ((pixel>>16)&0xFF); \ r = ((Pixel>>16)&0xFF); \
g = ((pixel>>8)&0xFF); \ g = ((Pixel>>8)&0xFF); \
b = (pixel&0xFF); \ b = (Pixel&0xFF); \
a = (pixel>>24); \ a = (Pixel>>24); \
} }
#define RGBA_FROM_ABGR8888(pixel, r, g, b, a) \ #define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \
{ \ { \
r = (pixel&0xFF); \ r = (Pixel&0xFF); \
g = ((pixel>>8)&0xFF); \ g = ((Pixel>>8)&0xFF); \
b = ((pixel>>16)&0xFF); \ b = ((Pixel>>16)&0xFF); \
a = (pixel>>24); \ a = (Pixel>>24); \
} }
#define DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \ #define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \
do { \ do { \
switch (bpp) { \ switch (bpp) { \
case 2: \ case 2: \
pixel = *((Uint16 *)(buf)); \ Pixel = *((Uint16 *)(buf)); \
break; \ break; \
\ \
case 3: {/* FIXME: broken code (no alpha) */ \ case 3: {/* FIXME: broken code (no alpha) */ \
Uint8 *b = (Uint8 *)buf; \ Uint8 *b = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = b[0] + (b[1] << 8) + (b[2] << 16); \ Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
} else { \ } else { \
pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \ Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
} \ } \
} \ } \
break; \ break; \
\ \
case 4: \ case 4: \
pixel = *((Uint32 *)(buf)); \ Pixel = *((Uint32 *)(buf)); \
break; \ break; \
\ \
default: \ default: \
pixel = 0; /* stop gcc complaints */ \ Pixel = 0; /* stop gcc complaints */ \
break; \ break; \
} \ } \
RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \ RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
pixel &= ~fmt->Amask; \ Pixel &= ~fmt->Amask; \
} while(0) } while(0)
/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
#define PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \ #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
{ \ { \
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \ ((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift)| \ ((b>>fmt->Bloss)<<fmt->Bshift)| \
((a>>fmt->Aloss)<<fmt->Ashift); \ ((a>>fmt->Aloss)<<fmt->Ashift); \
...@@ -336,10 +336,10 @@ do { \ ...@@ -336,10 +336,10 @@ do { \
{ \ { \
switch (bpp) { \ switch (bpp) { \
case 2: { \ case 2: { \
Uint16 pixel; \ Uint16 Pixel; \
\ \
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \ PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = pixel; \ *((Uint16 *)(buf)) = Pixel; \
} \ } \
break; \ break; \
\ \
...@@ -357,16 +357,16 @@ do { \ ...@@ -357,16 +357,16 @@ do { \
break; \ break; \
\ \
case 4: { \ case 4: { \
Uint32 pixel; \ Uint32 Pixel; \
\ \
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \ PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = pixel; \ *((Uint32 *)(buf)) = Pixel; \
} \ } \
break; \ break; \
} \ } \
} }
/* Blend the RGB values of two pixels based on a source alpha value */ /* Blend the RGB values of two Pixels based on a source alpha value */
#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ #define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
do { \ do { \
dR = (((sR-dR)*(A))>>8)+dR; \ dR = (((sR-dR)*(A))>>8)+dR; \
...@@ -374,7 +374,7 @@ do { \ ...@@ -374,7 +374,7 @@ do { \
dB = (((sB-dB)*(A))>>8)+dB; \ dB = (((sB-dB)*(A))>>8)+dB; \
} while(0) } while(0)
/* Blend the RGB values of two pixels based on a source alpha value */ /* Blend the RGB values of two Pixels based on a source alpha value */
#define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB) \ #define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB) \
do { \ do { \
unsigned tR, tG, tB, tA; \ unsigned tR, tG, tB, tA; \
......
...@@ -62,14 +62,14 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) ...@@ -62,14 +62,14 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP4( DUFFS_LOOP4(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
unsigned dR; unsigned dR;
unsigned dG; unsigned dG;
unsigned dB; unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB); DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
dR = dstfmt->palette->colors[*dst].r; dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g; dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b; dB = dstfmt->palette->colors[*dst].b;
...@@ -114,7 +114,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info) ...@@ -114,7 +114,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP4( DUFFS_LOOP4(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
...@@ -122,7 +122,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info) ...@@ -122,7 +122,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
unsigned dR; unsigned dR;
unsigned dG; unsigned dG;
unsigned dB; unsigned dB;
DISEMBLE_RGBA(src,srcbpp,srcfmt,pixel,sR,sG,sB,sA); DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
dR = dstfmt->palette->colors[*dst].r; dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g; dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b; dB = dstfmt->palette->colors[*dst].b;
...@@ -169,15 +169,15 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) ...@@ -169,15 +169,15 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
unsigned dR; unsigned dR;
unsigned dG; unsigned dG;
unsigned dB; unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB); DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
if ( pixel != ckey ) { if ( Pixel != ckey ) {
dR = dstfmt->palette->colors[*dst].r; dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g; dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b; dB = dstfmt->palette->colors[*dst].b;
...@@ -298,7 +298,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info) ...@@ -298,7 +298,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info)
pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */ pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */ packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */
por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */ por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
movd_r2m(mm2, *dstp);/* mm2 -> pixel */ movd_r2m(mm2, *dstp);/* mm2 -> Pixel */
++srcp; ++srcp;
++dstp; ++dstp;
},{ },{
...@@ -334,7 +334,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info) ...@@ -334,7 +334,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info)
psllq_i2r(32, mm6); /* mm6 << 32 -> mm6 */ psllq_i2r(32, mm6); /* mm6 << 32 -> mm6 */
por_r2r(mm6, mm2); /* mm6 | mm2 -> mm2 */ por_r2r(mm6, mm2); /* mm6 | mm2 -> mm2 */
por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */ por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
movq_r2m(mm2, *dstp);/* mm2 -> 2 x pixel */ movq_r2m(mm2, *dstp);/* mm2 -> 2 x Pixel */
srcp += 2; srcp += 2;
dstp += 2; dstp += 2;
}, width); }, width);
...@@ -422,7 +422,21 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info) ...@@ -422,7 +422,21 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
#endif #endif
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
#include <altivec.h>
#include <assert.h> #include <assert.h>
#if ((defined MACOSX) && (__GNUC__ < 4))
#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
(vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p )
#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
(vector unsigned short) ( a,b,c,d,e,f,g,h )
#else
#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
(vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p }
#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
(vector unsigned short) { a,b,c,d,e,f,g,h }
#endif
#define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F) #define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F)
#define VECPRINT(msg, v) do { \ #define VECPRINT(msg, v) do { \
vector unsigned int tmpvec = (vector unsigned int)(v); \ vector unsigned int tmpvec = (vector unsigned int)(v); \
...@@ -493,7 +507,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, ...@@ -493,7 +507,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
if (!dstfmt) { if (!dstfmt) {
dstfmt = &default_pixel_format; dstfmt = &default_pixel_format;
} }
vector unsigned char plus = (vector unsigned char) vector unsigned char plus = VECUINT8_LITERAL
( 0x00, 0x00, 0x00, 0x00, ( 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
...@@ -512,7 +526,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, ...@@ -512,7 +526,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF); amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF);
} }
#undef RESHIFT #undef RESHIFT
((unsigned int *)&srcvec)[0] = (rmask | gmask | bmask | amask); ((unsigned int *)(char*)&srcvec)[0] = (rmask | gmask | bmask | amask);
vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0)); vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0));
return(vswiz); return(vswiz);
} }
...@@ -533,10 +547,10 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -533,10 +547,10 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
vector unsigned short v3_16 = vec_splat_u16(3); vector unsigned short v3_16 = vec_splat_u16(3);
vector unsigned int v8_32 = vec_splat_u32(8); vector unsigned int v8_32 = vec_splat_u32(8);
vector unsigned int v16_32 = vec_add(v8_32, v8_32); vector unsigned int v16_32 = vec_add(v8_32, v8_32);
vector unsigned short v3f = (vector unsigned short)( vector unsigned short v3f = VECUINT16_LITERAL(
0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f,
0x003f, 0x003f, 0x003f, 0x003f); 0x003f, 0x003f, 0x003f, 0x003f);
vector unsigned short vfc = (vector unsigned short)( vector unsigned short vfc = VECUINT16_LITERAL(
0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
0x00fc, 0x00fc, 0x00fc, 0x00fc); 0x00fc, 0x00fc, 0x00fc, 0x00fc);
...@@ -545,7 +559,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -545,7 +559,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0e evens are the red 0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero 0x01 - 0x0f odds are zero
*/ */
vector unsigned char vredalpha1 = (vector unsigned char)( vector unsigned char vredalpha1 = VECUINT8_LITERAL(
0x10, 0x00, 0x01, 0x01, 0x10, 0x00, 0x01, 0x01,
0x10, 0x02, 0x01, 0x01, 0x10, 0x02, 0x01, 0x01,
0x10, 0x04, 0x01, 0x01, 0x10, 0x04, 0x01, 0x01,
...@@ -558,7 +572,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -558,7 +572,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x00 - 0x0f is ARxx ARxx ARxx ARxx
0x11 - 0x0f odds are blue 0x11 - 0x0f odds are blue
*/ */
vector unsigned char vblue1 = (vector unsigned char)( vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11, 0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13, 0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15, 0x08, 0x09, 0x0a, 0x15,
...@@ -571,7 +585,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -571,7 +585,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green 0x10 - 0x0e evens are green
*/ */
vector unsigned char vgreen1 = (vector unsigned char)( vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03, 0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07, 0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b, 0x08, 0x09, 0x14, 0x0b,
...@@ -580,7 +594,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -580,7 +594,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
vector unsigned char vgreen2 = (vector unsigned char)( vector unsigned char vgreen2 = (vector unsigned char)(
vec_add((vector unsigned int)vgreen1, vec_sl(v8_32, v8_32)) vec_add((vector unsigned int)vgreen1, vec_sl(v8_32, v8_32))
); );
vector unsigned char vgmerge = (vector unsigned char)( vector unsigned char vgmerge = VECUINT8_LITERAL(
0x00, 0x02, 0x00, 0x06, 0x00, 0x02, 0x00, 0x06,
0x00, 0x0a, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x0e,
0x00, 0x12, 0x00, 0x16, 0x00, 0x12, 0x00, 0x16,
...@@ -601,9 +615,9 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -601,9 +615,9 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \ while (condition) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB, sA; \ unsigned sR, sG, sB, dR, dG, dB, sA; \
DISEMBLE_RGBA(src, 4, srcfmt, pixel, sR, sG, sB, sA); \ DISEMBLE_RGBA(src, 4, srcfmt, Pixel, sR, sG, sB, sA); \
if(sA) { \ if(sA) { \
unsigned short dstpixel = *((unsigned short *)dst); \ unsigned short dstpixel = *((unsigned short *)dst); \
dR = (dstpixel >> 8) & 0xf8; \ dR = (dstpixel >> 8) & 0xf8; \
...@@ -727,26 +741,26 @@ static void Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo *info) ...@@ -727,26 +741,26 @@ static void Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo *info)
vbits = (vector unsigned char)vec_splat_s8(-1); vbits = (vector unsigned char)vec_splat_s8(-1);
ckey &= rgbmask; ckey &= rgbmask;
((unsigned int *)&vckey)[0] = ckey; ((unsigned int *)(char*)&vckey)[0] = ckey;
vckey = vec_splat(vckey, 0); vckey = vec_splat(vckey, 0);
((unsigned int *)&vrgbmask)[0] = rgbmask; ((unsigned int *)(char*)&vrgbmask)[0] = rgbmask;
vrgbmask = vec_splat(vrgbmask, 0); vrgbmask = vec_splat(vrgbmask, 0);
while(height--) { while(height--) {
int width = info->d_width; int width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \ while (condition) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB; \ unsigned sR, sG, sB, dR, dG, dB; \
RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, pixel); \ RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
if(sA && pixel != ckey) { \ if(sA && Pixel != ckey) { \
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); \ RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, pixel, dR, dG, dB); \ DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
} \ } \
((Uint8 *)dstp) += 4; \ dstp++; \
((Uint8 *)srcp) += 4; \ srcp++; \
widthvar--; \ widthvar--; \
} }
ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
...@@ -840,11 +854,11 @@ static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info) ...@@ -840,11 +854,11 @@ static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
width = info->d_width; width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB, sA, dA; \ unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, pixel, sR, sG, sB, sA); \ DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
if(sA) { \ if(sA) { \
DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, pixel, dR, dG, dB, dA); \ DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \ ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \
} \ } \
...@@ -1040,10 +1054,10 @@ static void Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo *info) ...@@ -1040,10 +1054,10 @@ static void Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo *info)
while(height--) { while(height--) {
int width = info->d_width; int width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB; \ unsigned sR, sG, sB, dR, dG, dB; \
DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, pixel, sR, sG, sB); \ DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, pixel, dR, dG, dB); \ DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
++srcp; \ ++srcp; \
...@@ -2002,15 +2016,15 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info) ...@@ -2002,15 +2016,15 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP4( DUFFS_LOOP4(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
unsigned dR; unsigned dR;
unsigned dG; unsigned dG;
unsigned dB; unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB); DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB); DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
src += srcbpp; src += srcbpp;
...@@ -2043,17 +2057,17 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) ...@@ -2043,17 +2057,17 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP4( DUFFS_LOOP4(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
unsigned dR; unsigned dR;
unsigned dG; unsigned dG;
unsigned dB; unsigned dB;
RETRIEVE_RGB_PIXEL(src, srcbpp, pixel); RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if(sA && pixel != ckey) { if(sA && Pixel != ckey) {
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB); DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
} }
...@@ -2093,7 +2107,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) ...@@ -2093,7 +2107,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP4( DUFFS_LOOP4(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
...@@ -2102,9 +2116,9 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) ...@@ -2102,9 +2116,9 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
unsigned dB; unsigned dB;
unsigned sA; unsigned sA;
unsigned dA; unsigned dA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA); DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
if(sA) { if(sA) {
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
} }
......
...@@ -36,10 +36,11 @@ static char rcsid = ...@@ -36,10 +36,11 @@ static char rcsid =
/* Functions to blit from N-bit surfaces to other surfaces */ /* Functions to blit from N-bit surfaces to other surfaces */
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
#include <altivec.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#ifdef MACOSX #ifdef MACOSX
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <stdlib.h>
static size_t GetL3CacheSize( void ) static size_t GetL3CacheSize( void )
{ {
const char key[] = "hw.l3cachesize"; const char key[] = "hw.l3cachesize";
...@@ -60,6 +61,18 @@ static size_t GetL3CacheSize( void ) ...@@ -60,6 +61,18 @@ static size_t GetL3CacheSize( void )
} }
#endif /* MACOSX */ #endif /* MACOSX */
#if ((defined MACOSX) && (__GNUC__ < 4))
#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
(vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p )
#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
(vector unsigned short) ( a,b,c,d,e,f,g,h )
#else
#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
(vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p }
#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
(vector unsigned short) { a,b,c,d,e,f,g,h }
#endif
#define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F) #define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F)
#define VSWIZZLE32(a,b,c,d) (vector unsigned char) \ #define VSWIZZLE32(a,b,c,d) (vector unsigned char) \
( 0x00+a, 0x00+b, 0x00+c, 0x00+d, \ ( 0x00+a, 0x00+b, 0x00+c, 0x00+d, \
...@@ -112,7 +125,8 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, ...@@ -112,7 +125,8 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
if (!dstfmt) { if (!dstfmt) {
dstfmt = &default_pixel_format; dstfmt = &default_pixel_format;
} }
vector unsigned char plus = (vector unsigned char)( 0x00, 0x00, 0x00, 0x00, vector unsigned char plus = VECUINT8_LITERAL(
0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x0C, 0x0C, 0x0C, 0x0C ); 0x0C, 0x0C, 0x0C, 0x0C );
...@@ -130,7 +144,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, ...@@ -130,7 +144,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF); amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF);
} }
#undef RESHIFT #undef RESHIFT
((unsigned int *)&srcvec)[0] = (rmask | gmask | bmask | amask); ((unsigned int *)(char*)&srcvec)[0] = (rmask | gmask | bmask | amask);
vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0)); vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0));
return(vswiz); return(vswiz);
} }
...@@ -145,17 +159,17 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) { ...@@ -145,17 +159,17 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) {
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
vector unsigned char valpha = vec_splat_u8(0); vector unsigned char valpha = vec_splat_u8(0);
vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
vector unsigned char vgmerge = (vector unsigned char)( vector unsigned char vgmerge = VECUINT8_LITERAL(
0x00, 0x02, 0x00, 0x06, 0x00, 0x02, 0x00, 0x06,
0x00, 0x0a, 0x00, 0x0e, 0x00, 0x0a, 0x00, 0x0e,
0x00, 0x12, 0x00, 0x16, 0x00, 0x12, 0x00, 0x16,
0x00, 0x1a, 0x00, 0x1e); 0x00, 0x1a, 0x00, 0x1e);
vector unsigned short v1 = vec_splat_u16(1); vector unsigned short v1 = vec_splat_u16(1);
vector unsigned short v3 = vec_splat_u16(3); vector unsigned short v3 = vec_splat_u16(3);
vector unsigned short v3f = (vector unsigned short)( vector unsigned short v3f = VECUINT16_LITERAL(
0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f, 0x003f,
0x003f, 0x003f, 0x003f, 0x003f); 0x003f, 0x003f, 0x003f, 0x003f);
vector unsigned short vfc = (vector unsigned short)( vector unsigned short vfc = VECUINT16_LITERAL(
0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc, 0x00fc,
0x00fc, 0x00fc, 0x00fc, 0x00fc); 0x00fc, 0x00fc, 0x00fc, 0x00fc);
vector unsigned short vf800 = (vector unsigned short)vec_splat_u8(-7); vector unsigned short vf800 = (vector unsigned short)vec_splat_u8(-7);
...@@ -172,9 +186,9 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) { ...@@ -172,9 +186,9 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) {
/* do scalar until we can align... */ /* do scalar until we can align... */
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \ while (condition) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, sA; \ unsigned sR, sG, sB, sA; \
DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, pixel, \ DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \
sR, sG, sB, sA); \ sR, sG, sB, sA); \
*(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \ *(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \
((sG << 3) & 0x000007E0) | \ ((sG << 3) & 0x000007E0) | \
...@@ -259,20 +273,20 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) { ...@@ -259,20 +273,20 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0e evens are the red 0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero 0x01 - 0x0f odds are zero
*/ */
vector unsigned char vredalpha1 = (vector unsigned char)( vector unsigned char vredalpha1 = VECUINT8_LITERAL(
0x10, 0x00, 0x01, 0x01, 0x10, 0x00, 0x01, 0x01,
0x10, 0x02, 0x01, 0x01, 0x10, 0x02, 0x01, 0x01,
0x10, 0x04, 0x01, 0x01, 0x10, 0x04, 0x01, 0x01,
0x10, 0x06, 0x01, 0x01 0x10, 0x06, 0x01, 0x01
); );
vector unsigned char vredalpha2 = (vector unsigned char)( vector unsigned char vredalpha2 = (vector unsigned char) (
vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16)) vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16))
); );
/* /*
0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x00 - 0x0f is ARxx ARxx ARxx ARxx
0x11 - 0x0f odds are blue 0x11 - 0x0f odds are blue
*/ */
vector unsigned char vblue1 = (vector unsigned char)( vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11, 0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13, 0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15, 0x08, 0x09, 0x0a, 0x15,
...@@ -285,7 +299,7 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) { ...@@ -285,7 +299,7 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green 0x10 - 0x0e evens are green
*/ */
vector unsigned char vgreen1 = (vector unsigned char)( vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03, 0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07, 0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b, 0x08, 0x09, 0x14, 0x0b,
...@@ -323,10 +337,10 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) { ...@@ -323,10 +337,10 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \ while (condition) { \
unsigned sR, sG, sB; \ unsigned sR, sG, sB; \
unsigned short pixel = *((unsigned short *)src); \ unsigned short Pixel = *((unsigned short *)src); \
sR = (pixel >> 8) & 0xf8; \ sR = (Pixel >> 8) & 0xf8; \
sG = (pixel >> 3) & 0xfc; \ sG = (Pixel >> 3) & 0xfc; \
sB = (pixel << 3) & 0xf8; \ sB = (Pixel << 3) & 0xf8; \
ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \
src += 2; \ src += 2; \
dst += 4; \ dst += 4; \
...@@ -404,7 +418,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) { ...@@ -404,7 +418,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0e evens are the red 0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero 0x01 - 0x0f odds are zero
*/ */
vector unsigned char vredalpha1 = (vector unsigned char)( vector unsigned char vredalpha1 = VECUINT8_LITERAL(
0x10, 0x00, 0x01, 0x01, 0x10, 0x00, 0x01, 0x01,
0x10, 0x02, 0x01, 0x01, 0x10, 0x02, 0x01, 0x01,
0x10, 0x04, 0x01, 0x01, 0x10, 0x04, 0x01, 0x01,
...@@ -417,7 +431,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) { ...@@ -417,7 +431,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x00 - 0x0f is ARxx ARxx ARxx ARxx
0x11 - 0x0f odds are blue 0x11 - 0x0f odds are blue
*/ */
vector unsigned char vblue1 = (vector unsigned char)( vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11, 0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13, 0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15, 0x08, 0x09, 0x0a, 0x15,
...@@ -430,7 +444,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) { ...@@ -430,7 +444,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green 0x10 - 0x0e evens are green
*/ */
vector unsigned char vgreen1 = (vector unsigned char)( vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03, 0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07, 0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b, 0x08, 0x09, 0x14, 0x0b,
...@@ -468,10 +482,10 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) { ...@@ -468,10 +482,10 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \ while (condition) { \
unsigned sR, sG, sB; \ unsigned sR, sG, sB; \
unsigned short pixel = *((unsigned short *)src); \ unsigned short Pixel = *((unsigned short *)src); \
sR = (pixel >> 7) & 0xf8; \ sR = (Pixel >> 7) & 0xf8; \
sG = (pixel >> 2) & 0xf8; \ sG = (Pixel >> 2) & 0xf8; \
sB = (pixel << 3) & 0xf8; \ sB = (Pixel << 3) & 0xf8; \
ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \
src += 2; \ src += 2; \
dst += 4; \ dst += 4; \
...@@ -565,39 +579,39 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info) ...@@ -565,39 +579,39 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info)
valpha = (vector unsigned int)vzero; valpha = (vector unsigned int)vzero;
} }
ckey &= rgbmask; ckey &= rgbmask;
((unsigned int *)&vckey)[0] = ckey; ((unsigned int *)(char*)&vckey)[0] = ckey;
vckey = vec_splat(vckey, 0); vckey = vec_splat(vckey, 0);
((unsigned int *)&vrgbmask)[0] = rgbmask; ((unsigned int *)(char*)&vrgbmask)[0] = rgbmask;
vrgbmask = vec_splat(vrgbmask, 0); vrgbmask = vec_splat(vrgbmask, 0);
while (height--) { while (height--) {
#define ONE_PIXEL_BLEND(condition, widthvar) \ #define ONE_PIXEL_BLEND(condition, widthvar) \
if (copy_alpha) { \ if (copy_alpha) { \
while (condition) { \ while (condition) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB, sA; \ unsigned sR, sG, sB, sA; \
DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, pixel, \ DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \
sR, sG, sB, sA); \ sR, sG, sB, sA); \
if ( (pixel & rgbmask) != ckey ) { \ if ( (Pixel & rgbmask) != ckey ) { \
ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \
sR, sG, sB, sA); \ sR, sG, sB, sA); \
} \ } \
((Uint8 *)dstp) += dstbpp; \ dstp = (Uint32 *) (((Uint8 *) dstp) + dstbpp); \
((Uint8 *)srcp) += srcbpp; \ srcp = (Uint32 *) (((Uint8 *) srcp) + srcbpp); \
widthvar--; \ widthvar--; \
} \ } \
} else { \ } else { \
while (condition) { \ while (condition) { \
Uint32 pixel; \ Uint32 Pixel; \
unsigned sR, sG, sB; \ unsigned sR, sG, sB; \
RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, pixel); \ RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, Pixel); \
if ( pixel != ckey ) { \ if ( Pixel != ckey ) { \
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); \ RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \
sR, sG, sB, alpha); \ sR, sG, sB, alpha); \
} \ } \
((Uint8 *)dstp) += dstbpp; \ dstp = (Uint32 *) (((Uint8 *)dstp) + dstbpp); \
((Uint8 *)srcp) += srcbpp; \ srcp = (Uint32 *) (((Uint8 *)srcp) + srcbpp); \
widthvar--; \ widthvar--; \
} \ } \
} }
...@@ -819,6 +833,7 @@ static Uint32 GetBlitFeatures( void ) ...@@ -819,6 +833,7 @@ static Uint32 GetBlitFeatures( void )
/* Feature 2 is has-AltiVec */ /* Feature 2 is has-AltiVec */
| ((SDL_HasAltiVec()) ? 2 : 0) | ((SDL_HasAltiVec()) ? 2 : 0)
/* Feature 4 is dont-use-prefetch */ /* Feature 4 is dont-use-prefetch */
/* !!!! FIXME: Check for G5 or later, not the cache size! Always prefetch on a G4. */
| ((GetL3CacheSize() == 0) ? 4 : 0) | ((GetL3CacheSize() == 0) ? 4 : 0)
); );
} }
...@@ -911,43 +926,43 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info) ...@@ -911,43 +926,43 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info)
dst += dstskip; dst += dstskip;
} }
} else { } else {
int pixel; int Pixel;
while ( height-- ) { while ( height-- ) {
#ifdef USE_DUFFS_LOOP #ifdef USE_DUFFS_LOOP
DUFFS_LOOP( DUFFS_LOOP(
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
, width); , width);
#else #else
for ( c=width/4; c; --c ) { for ( c=width/4; c; --c ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
} }
switch ( width & 3 ) { switch ( width & 3 ) {
case 3: case 3:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
case 2: case 2:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
case 1: case 1:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
} }
#endif /* USE_DUFFS_LOOP */ #endif /* USE_DUFFS_LOOP */
...@@ -1820,7 +1835,7 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info) ...@@ -1820,7 +1835,7 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
#ifndef USE_DUFFS_LOOP #ifndef USE_DUFFS_LOOP
int c; int c;
#endif #endif
int pixel; int Pixel;
int width, height; int width, height;
Uint32 *src; Uint32 *src;
const Uint8 *map; const Uint8 *map;
...@@ -1839,8 +1854,8 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info) ...@@ -1839,8 +1854,8 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
#ifdef USE_DUFFS_LOOP #ifdef USE_DUFFS_LOOP
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
, width); , width);
src += srcskip; src += srcskip;
...@@ -1850,31 +1865,31 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info) ...@@ -1850,31 +1865,31 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
for ( c=width/4; c; --c ) { for ( c=width/4; c; --c ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
} }
switch ( width & 3 ) { switch ( width & 3 ) {
case 3: case 3:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
case 2: case 2:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
case 1: case 1:
RGB888_RGB332(pixel, *src); RGB888_RGB332(Pixel, *src);
*dst++ = map[pixel]; *dst++ = map[Pixel];
++src; ++src;
} }
src += srcskip; src += srcskip;
...@@ -1893,7 +1908,7 @@ static void BlitNto1(SDL_BlitInfo *info) ...@@ -1893,7 +1908,7 @@ static void BlitNto1(SDL_BlitInfo *info)
Uint8 *dst; Uint8 *dst;
int srcskip, dstskip; int srcskip, dstskip;
int srcbpp; int srcbpp;
Uint32 pixel; Uint32 Pixel;
int sR, sG, sB; int sR, sG, sB;
SDL_PixelFormat *srcfmt; SDL_PixelFormat *srcfmt;
...@@ -1912,7 +1927,7 @@ static void BlitNto1(SDL_BlitInfo *info) ...@@ -1912,7 +1927,7 @@ static void BlitNto1(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
#ifdef USE_DUFFS_LOOP #ifdef USE_DUFFS_LOOP
DUFFS_LOOP( DUFFS_LOOP(
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( 1 ) { if ( 1 ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
...@@ -1925,7 +1940,7 @@ static void BlitNto1(SDL_BlitInfo *info) ...@@ -1925,7 +1940,7 @@ static void BlitNto1(SDL_BlitInfo *info)
, width); , width);
#else #else
for ( c=width; c; --c ) { for ( c=width; c; --c ) {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( 1 ) { if ( 1 ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
...@@ -1944,7 +1959,7 @@ static void BlitNto1(SDL_BlitInfo *info) ...@@ -1944,7 +1959,7 @@ static void BlitNto1(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
#ifdef USE_DUFFS_LOOP #ifdef USE_DUFFS_LOOP
DUFFS_LOOP( DUFFS_LOOP(
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( 1 ) { if ( 1 ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
...@@ -1957,7 +1972,7 @@ static void BlitNto1(SDL_BlitInfo *info) ...@@ -1957,7 +1972,7 @@ static void BlitNto1(SDL_BlitInfo *info)
, width); , width);
#else #else
for ( c=width; c; --c ) { for ( c=width; c; --c ) {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( 1 ) { if ( 1 ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
...@@ -1991,11 +2006,11 @@ static void BlitNtoN(SDL_BlitInfo *info) ...@@ -1991,11 +2006,11 @@ static void BlitNtoN(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB); DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
dst += dstbpp; dst += dstbpp;
src += srcbpp; src += srcbpp;
...@@ -2023,9 +2038,9 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info) ...@@ -2023,9 +2038,9 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
/* FIXME: should map alpha to [0..255] correctly! */ /* FIXME: should map alpha to [0..255] correctly! */
while ( height-- ) { while ( height-- ) {
for ( c=width; c; --c ) { for ( c=width; c; --c ) {
Uint32 pixel; Uint32 Pixel;
unsigned sR, sG, sB, sA; unsigned sR, sG, sB, sA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel,
sR, sG, sB, sA); sR, sG, sB, sA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, sA); sR, sG, sB, sA);
...@@ -2050,7 +2065,7 @@ static void BlitNto1Key(SDL_BlitInfo *info) ...@@ -2050,7 +2065,7 @@ static void BlitNto1Key(SDL_BlitInfo *info)
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = srcfmt->colorkey;
Uint32 rgbmask = ~srcfmt->Amask; Uint32 rgbmask = ~srcfmt->Amask;
int srcbpp; int srcbpp;
Uint32 pixel; Uint32 Pixel;
Uint8 sR, sG, sB; Uint8 sR, sG, sB;
/* Set up some basic variables */ /* Set up some basic variables */
...@@ -2061,9 +2076,9 @@ static void BlitNto1Key(SDL_BlitInfo *info) ...@@ -2061,9 +2076,9 @@ static void BlitNto1Key(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( (pixel & rgbmask) != ckey ) { if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
*dst = ((sR>>5)<<(3+2))| *dst = ((sR>>5)<<(3+2))|
((sG>>5)<<(2)) | ((sG>>5)<<(2)) |
...@@ -2080,9 +2095,9 @@ static void BlitNto1Key(SDL_BlitInfo *info) ...@@ -2080,9 +2095,9 @@ static void BlitNto1Key(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB); sR, sG, sB);
if ( (pixel & rgbmask) != ckey ) { if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */ /* Pack RGB into 8bit pixel */
*dst = palmap[((sR>>5)<<(3+2))| *dst = palmap[((sR>>5)<<(3+2))|
((sG>>5)<<(2)) | ((sG>>5)<<(2)) |
...@@ -2147,13 +2162,13 @@ static void BlitNtoNKey(SDL_BlitInfo *info) ...@@ -2147,13 +2162,13 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
Uint32 pixel; Uint32 Pixel;
unsigned sR; unsigned sR;
unsigned sG; unsigned sG;
unsigned sB; unsigned sB;
RETRIEVE_RGB_PIXEL(src, srcbpp, pixel); RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if ( pixel != ckey ) { if ( Pixel != ckey ) {
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, alpha); sR, sG, sB, alpha);
} }
...@@ -2181,7 +2196,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) ...@@ -2181,7 +2196,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Uint8 srcbpp; Uint8 srcbpp;
Uint8 dstbpp; Uint8 dstbpp;
Uint32 pixel; Uint32 Pixel;
Uint8 sR, sG, sB, sA; Uint8 sR, sG, sB, sA;
/* Set up some basic variables */ /* Set up some basic variables */
...@@ -2193,9 +2208,9 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) ...@@ -2193,9 +2208,9 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
while ( height-- ) { while ( height-- ) {
DUFFS_LOOP( DUFFS_LOOP(
{ {
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel,
sR, sG, sB, sA); sR, sG, sB, sA);
if ( (pixel & rgbmask) != ckey ) { if ( (Pixel & rgbmask) != ckey ) {
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, sA); sR, sG, sB, sA);
} }
......
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