There are a couple of issues with the selection of Altivec alpha-blitting
routines in CalculateAlphaBlit() in src/video/SDL_Blit_A.c.

1) There's no check for the presence of Altivec when checking if the
Blit32to565PixelAlphaAltivec() routine can be selected.

2) Altivec cannot be used in video memory, and there's no check if the
destination surface is a hardware surface. (Alpha-blitting to a hardware
surface with GPU support is a bad idea, but somebody's bound to do it anyway.)

Patch to fix these attached.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401243
This commit is contained in:
Ryan C. Gordon 2006-01-08 21:18:15 +00:00
parent 63a2120830
commit 958cb54ab3

View file

@ -2145,7 +2145,8 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
return BlitNto1SurfaceAlphaKey; return BlitNto1SurfaceAlphaKey;
else else
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && SDL_HasAltiVec()) if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32SurfaceAlphaKeyAltivec; return Blit32to32SurfaceAlphaKeyAltivec;
else else
#endif #endif
@ -2192,7 +2193,7 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
else else
#endif #endif
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if(SDL_HasAltiVec()) if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return BlitRGBtoRGBSurfaceAlphaAltivec; return BlitRGBtoRGBSurfaceAlphaAltivec;
else else
#endif #endif
@ -2200,7 +2201,8 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
} }
else else
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if((sf->BytesPerPixel == 4) && SDL_HasAltiVec()) if((sf->BytesPerPixel == 4) &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32SurfaceAlphaAltivec; return Blit32to32SurfaceAlphaAltivec;
else else
#endif #endif
@ -2219,9 +2221,9 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
case 2: case 2:
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if(sf->BytesPerPixel == 4 && if(sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) &&
df->Gmask == 0x7e0 && df->Gmask == 0x7e0 &&
df->Bmask == 0x1f) df->Bmask == 0x1f && SDL_HasAltiVec())
return Blit32to565PixelAlphaAltivec; return Blit32to565PixelAlphaAltivec;
else else
#endif #endif
@ -2252,14 +2254,15 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
else else
#endif #endif
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if(SDL_HasAltiVec()) if(!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return BlitRGBtoRGBPixelAlphaAltivec; return BlitRGBtoRGBPixelAlphaAltivec;
else else
#endif #endif
return BlitRGBtoRGBPixelAlpha; return BlitRGBtoRGBPixelAlpha;
} }
#ifdef USE_ALTIVEC_BLITTERS #ifdef USE_ALTIVEC_BLITTERS
if (sf->Amask && sf->BytesPerPixel == 4 && SDL_HasAltiVec()) if (sf->Amask && sf->BytesPerPixel == 4 &&
!(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
return Blit32to32PixelAlphaAltivec; return Blit32to32PixelAlphaAltivec;
else else
#endif #endif