Commit 48c21b29 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Altivec-optimized blitters!

Vast majority of this work is compliments of Bob Ippolito.

http://www.devolution.com/pipermail/sdl/2005-February/067466.html and many
 other posts.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401048
parent 20dbe0d9
...@@ -1839,17 +1839,18 @@ CheckAltivec() ...@@ -1839,17 +1839,18 @@ CheckAltivec()
{ {
AC_MSG_CHECKING(for GCC Altivec instruction support) AC_MSG_CHECKING(for GCC Altivec instruction support)
have_gcc_altivec=no have_gcc_altivec=no
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
AC_TRY_COMPILE([ AC_TRY_COMPILE([
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[ ],[
asm volatile ("mtspr 256, %0\n\t"
"vand %%v0, %%v0, %%v0"
:
: "r" (-1));
],[ ],[
have_gcc_altivec=yes have_gcc_altivec=yes
]) ])
if test x$have_gcc_altivec = xyes; then if test x$have_gcc_altivec = xno; then
CFLAGS="$CFLAGS -DGCC_ALTIVEC" CFLAGS="${save_CFLAGS}"
fi fi
AC_MSG_RESULT($have_gcc_altivec) AC_MSG_RESULT($have_gcc_altivec)
} }
...@@ -2564,6 +2565,7 @@ case "$target" in ...@@ -2564,6 +2565,7 @@ case "$target" in
CheckMacGL CheckMacGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION CheckSIGACTION
CheckAltivec
# If either the audio or CD driver is used, add the AudioUnit framework # If either the audio or CD driver is used, add the AudioUnit framework
if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
SYSTEM_LIBS="$SYSTEM_LIBS -framework AudioToolbox -framework AudioUnit" SYSTEM_LIBS="$SYSTEM_LIBS -framework AudioToolbox -framework AudioUnit"
......
...@@ -374,6 +374,20 @@ do { \ ...@@ -374,6 +374,20 @@ 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 */
#define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB) \
do { \
unsigned tR, tG, tB, tA; \
tA = 255 - sA; \
tR = 1 + (sR * sA) + (dR * tA); \
dR = (tR + (tR >> 8)) >> 8; \
tG = 1 + (sG * sA) + (dG * tA); \
dG = (tG + (tG >> 8)) >> 8; \
tB = 1 + (sB * sA) + (dB * tA); \
dB = (tB + (tB >> 8)) >> 8; \
} while(0)
/* This is a very useful loop for optimizing blitters */ /* This is a very useful loop for optimizing blitters */
#if defined(_MSC_VER) && (_MSC_VER == 1300) #if defined(_MSC_VER) && (_MSC_VER == 1300)
/* There's a bug in the Visual C++ 7 optimizer when compiling this code */ /* There's a bug in the Visual C++ 7 optimizer when compiling this code */
......
This diff is collapsed.
This diff is collapsed.
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