Skip to content
Permalink
Browse files

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

 GCCs versions.
  • Loading branch information
icculus committed Oct 20, 2005
1 parent fd3d767 commit 8cc81e370b26e27c2bb92d7aadbc584245ff85eb
Showing with 282 additions and 232 deletions.
  1. +25 −4 configure.in
  2. +92 −92 src/video/SDL_blit.h
  3. +59 −45 src/video/SDL_blit_A.c
  4. +106 −91 src/video/SDL_blit_N.c
@@ -1910,22 +1910,43 @@ CheckUSBHID()
dnl Check for altivec instruction support using gas syntax
CheckAltivec()
{
AC_MSG_CHECKING(for GCC Altivec instruction support)
have_gcc_altivec=no
dnl FIXME: Theoretically, you might not have altivec.h, we should check
dnl FIXME: that seperately, but I think all major platforms have it
dnl FIXME: at the moment... --ryan.

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([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
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
CFLAGS="${save_CFLAGS}"
fi
AC_MSG_RESULT($have_gcc_altivec)
}

dnl Check for a valid linux/version.h
@@ -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 */
/* 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); \
g = (((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
b = (((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \
r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \
g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
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); \
g = (((pixel&0x07E0)>>5)<<2); \
b = ((pixel&0x001F)<<3); \
r = (((Pixel&0xF800)>>11)<<3); \
g = (((Pixel&0x07E0)>>5)<<2); \
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); \
g = (((pixel&0x03E0)>>5)<<3); \
b = ((pixel&0x001F)<<3); \
r = (((Pixel&0x7C00)>>10)<<3); \
g = (((Pixel&0x03E0)>>5)<<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); \
g = ((pixel&0xFF00)>>8); \
b = (pixel&0xFF); \
r = ((Pixel&0xFF0000)>>16); \
g = ((Pixel&0xFF00)>>8); \
b = (Pixel&0xFF); \
}
#define RETRIEVE_RGB_PIXEL(buf, bpp, pixel) \
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
do { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)(buf); \
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 { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* appease gcc */ \
Pixel = 0; /* appease gcc */ \
break; \
} \
} while(0)

#define DISEMBLE_RGB(buf, bpp, fmt, pixel, r, g, b) \
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
do { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)buf; \
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 { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* prevent gcc from complaining */ \
Pixel = 0; /* prevent gcc from complaining */ \
break; \
} \
RGB_FROM_PIXEL(pixel, fmt, r, g, b); \
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
} while(0)

/* 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)| \
((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) \
{ \
switch (bpp) { \
case 2: { \
Uint16 pixel; \
Uint16 Pixel; \
\
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
@@ -213,10 +213,10 @@ do { \
break; \
\
case 4: { \
Uint32 pixel; \
Uint32 Pixel; \
\
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \
@@ -226,11 +226,11 @@ do { \
switch (bpp) { \
case 2: { \
Uint16 *bufp; \
Uint16 pixel; \
Uint16 Pixel; \
\
bufp = (Uint16 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
\
@@ -249,85 +249,85 @@ do { \
\
case 4: { \
Uint32 *bufp; \
Uint32 pixel; \
Uint32 Pixel; \
\
bufp = (Uint32 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
} \
}

/* 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; \
g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
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; \
g = (pixel&fmt->Gmask)>>fmt->Gshift; \
b = (pixel&fmt->Bmask)>>fmt->Bshift; \
a = (pixel&fmt->Amask)>>fmt->Ashift; \
r = (Pixel&fmt->Rmask)>>fmt->Rshift; \
g = (Pixel&fmt->Gmask)>>fmt->Gshift; \
b = (Pixel&fmt->Bmask)>>fmt->Bshift; \
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); \
g = ((pixel>>16)&0xFF); \
b = ((pixel>>8)&0xFF); \
a = (pixel&0xFF); \
r = (Pixel>>24); \
g = ((Pixel>>16)&0xFF); \
b = ((Pixel>>8)&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); \
g = ((pixel>>8)&0xFF); \
b = (pixel&0xFF); \
a = (pixel>>24); \
r = ((Pixel>>16)&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = (Pixel&0xFF); \
a = (Pixel>>24); \
}
#define RGBA_FROM_ABGR8888(pixel, r, g, b, a) \
#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \
{ \
r = (pixel&0xFF); \
g = ((pixel>>8)&0xFF); \
b = ((pixel>>16)&0xFF); \
a = (pixel>>24); \
r = (Pixel&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = ((Pixel>>16)&0xFF); \
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 { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: {/* FIXME: broken code (no alpha) */ \
Uint8 *b = (Uint8 *)buf; \
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 { \
pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* stop gcc complaints */ \
Pixel = 0; /* stop gcc complaints */ \
break; \
} \
RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
pixel &= ~fmt->Amask; \
RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
Pixel &= ~fmt->Amask; \
} while(0)

/* 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)| \
((b>>fmt->Bloss)<<fmt->Bshift)| \
((a>>fmt->Aloss)<<fmt->Ashift); \
@@ -336,10 +336,10 @@ do { \
{ \
switch (bpp) { \
case 2: { \
Uint16 pixel; \
Uint16 Pixel; \
\
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = pixel; \
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
@@ -357,24 +357,24 @@ do { \
break; \
\
case 4: { \
Uint32 pixel; \
Uint32 Pixel; \
\
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = pixel; \
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = Pixel; \
} \
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) \
do { \
dR = (((sR-dR)*(A))>>8)+dR; \
dG = (((sG-dG)*(A))>>8)+dG; \
dB = (((sB-dB)*(A))>>8)+dB; \
} 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) \
do { \
unsigned tR, tG, tB, tA; \

0 comments on commit 8cc81e3

Please sign in to comment.