tune the preloads a bit
[sdl_omap.git] / src / video / SDL_blit_A.c
index 565879d..504451b 100644 (file)
@@ -72,13 +72,15 @@ static void name(SDL_BlitInfo *info) \
        int height = info->d_height; \
        Uint8 *src = info->s_pixels; \
        Uint8 *dst = info->d_pixels; \
-       int srcskip = info->s_skip; \
-       int dstskip = info->d_skip; \
+       int dstBpp = info->dst->BytesPerPixel; \
+       int srcstride = width * 4 + info->s_skip; \
+       int dststride = width * dstBpp + info->d_skip; \
 \
        while ( height-- ) { \
-            neon_name(dst, src, width); \
-           src += width * 4 + srcskip; \
-           dst += width * 4 + dstskip; \
+           __builtin_prefetch(dst + dststride); \
+           neon_name(dst, src, width); \
+           src += srcstride; \
+           dst += dststride; \
        } \
 }
 
@@ -103,6 +105,8 @@ static void name(SDL_BlitInfo *info) \
 
 make_neon_caller(BlitABGRtoXRGBalpha_neon, neon_ABGRtoXRGBalpha)
 make_neon_caller(BlitARGBtoXRGBalpha_neon, neon_ARGBtoXRGBalpha)
+make_neon_caller(BlitABGRtoRGB565alpha_neon, neon_ABGRtoRGB565alpha)
+make_neon_caller(BlitARGBtoRGB565alpha_neon, neon_ARGBtoRGB565alpha)
 make_neon_callerS(BlitABGRtoXRGBalphaS_neon, neon_ABGRtoXRGBalphaS)
 make_neon_callerS(BlitARGBtoXRGBalphaS_neon, neon_ARGBtoXRGBalphaS)
 
@@ -2857,7 +2861,9 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
                        if(sf->Rshift % 8 == 0
                           && sf->Gshift % 8 == 0
                           && sf->Bshift % 8 == 0)
+                       {
                                return BlitARGBtoXRGBalphaS_neon;
+                       }
 #endif
                        if((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff)
                        {
@@ -2869,6 +2875,13 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
                                return BlitRGBtoRGBSurfaceAlpha;
                        }
                }
+#ifdef __ARM_NEON__
+               if (sf->Gmask == df->Gmask && sf->Rmask == df->Bmask && sf->Bmask == df->Rmask
+                   && sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0)
+               {
+                       return BlitABGRtoXRGBalphaS_neon;
+               }
+#endif
 #if SDL_ALTIVEC_BLITTERS
                if((sf->BytesPerPixel == 4) &&
                   !(surface->map->dst->flags & SDL_HWSURFACE) && SDL_HasAltiVec())
@@ -2895,6 +2908,16 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
           df->Bmask == 0x1f && SDL_HasAltiVec())
             return Blit32to565PixelAlphaAltivec;
         else
+#endif
+#ifdef __ARM_NEON__
+           if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
+              && sf->Gmask == 0xff00 && df->Gmask == 0x7e0) {
+               if((sf->Bmask >> 3) == df->Bmask || (sf->Rmask >> 3) == df->Rmask)
+                   return BlitARGBtoRGB565alpha_neon;
+               else
+                   return BlitABGRtoRGB565alpha_neon;
+           }
+           else
 #endif
            if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
               && sf->Gmask == 0xff00
@@ -2925,6 +2948,15 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
                        if(SDL_HasMMX())
                                return BlitRGBtoRGBPixelAlphaMMX;
                }
+#endif
+#ifdef __ARM_NEON__
+               if(sf->Rshift % 8 == 0
+                  && sf->Gshift % 8 == 0
+                  && sf->Bshift % 8 == 0
+                  && sf->Ashift % 8 == 0)
+               {
+                       return BlitARGBtoXRGBalpha_neon;
+               }
 #endif
                if(sf->Amask == 0xff000000)
                {
@@ -2932,17 +2964,14 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
                        if(!(surface->map->dst->flags & SDL_HWSURFACE)
                                && SDL_HasAltiVec())
                                return BlitRGBtoRGBPixelAlphaAltivec;
-#endif
-#ifdef __ARM_NEON__
-                       return BlitARGBtoXRGBalpha_neon;
 #endif
                        return BlitRGBtoRGBPixelAlpha;
                }
            }
 #ifdef __ARM_NEON__
-           if (sf->Gmask == df->Gmask && sf->Amask == 0xff000000 &&
-               ((sf->Rmask == 0xff && df->Rmask == 0xff0000 && sf->Bmask == 0xff0000 && df->Bmask == 0xff) ||
-                (sf->Rmask == 0xff0000 && df->Rmask == 0xff && sf->Bmask == 0xff && df->Bmask == 0xff0000)))
+           if (sf->Gmask == df->Gmask && sf->Rmask == df->Bmask && sf->Bmask == df->Rmask
+               && sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0
+               && sf->Amask == 0xff000000)
            {
                return BlitABGRtoXRGBalpha_neon;
            }