comparison src/video/SDL_blit_N.c @ 1361:19418e4422cb

New configure-based build system. Still work in progress, but much improved
author Sam Lantinga <slouken@libsdl.org>
date Thu, 16 Feb 2006 10:11:48 +0000
parents c71e05b4dc2e
children d910939febfa
comparison
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
25 #include "SDL_cpuinfo.h" 25 #include "SDL_cpuinfo.h"
26 #include "SDL_blit.h" 26 #include "SDL_blit.h"
27 27
28 /* Functions to blit from N-bit surfaces to other surfaces */ 28 /* Functions to blit from N-bit surfaces to other surfaces */
29 29
30 #ifdef USE_ALTIVEC_BLITTERS 30 #if SDL_ALTIVEC_BLITTERS
31 #ifdef HAVE_ALTIVEC_H 31 #ifdef HAVE_ALTIVEC_H
32 #include <altivec.h> 32 #include <altivec.h>
33 #endif 33 #endif
34 #define assert(X) 34 #define assert(X)
35 #ifdef MACOSX 35 #ifdef MACOSX
840 #else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ 840 #else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
841 #define HI 0 841 #define HI 0
842 #define LO 1 842 #define LO 1
843 #endif 843 #endif
844 844
845 #ifdef USE_ASMBLIT 845 #if SDL_HERMES_BLITTERS
846 846
847 /* Heheheh, we coerce Hermes into using SDL blit information */ 847 /* Heheheh, we coerce Hermes into using SDL blit information */
848 #define X86_ASSEMBLER 848 #define X86_ASSEMBLER
849 #define HermesConverterInterface SDL_BlitInfo 849 #define HermesConverterInterface SDL_BlitInfo
850 #define HermesClearInterface void 850 #define HermesClearInterface void
851 #define STACKCALL 851 #define STACKCALL
852 852
853 #include "HeadMMX.h" 853 #include "../hermes/HeadMMX.h"
854 #include "HeadX86.h" 854 #include "../hermes/HeadX86.h"
855 855
856 #else 856 #else
857 857
858 /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */ 858 /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
859 #define RGB888_RGB332(dst, src) { \ 859 #define RGB888_RGB332(dst, src) { \
1198 } 1198 }
1199 } 1199 }
1200 #endif /* USE_DUFFS_LOOP */ 1200 #endif /* USE_DUFFS_LOOP */
1201 } 1201 }
1202 1202
1203 #endif /* USE_ASMBLIT */ 1203 #endif /* SDL_HERMES_BLITTERS */
1204 1204
1205 1205
1206 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */ 1206 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */
1207 #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1]) 1207 #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1])
1208 static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) 1208 static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
2270 static const struct blit_table normal_blit_1[] = { 2270 static const struct blit_table normal_blit_1[] = {
2271 /* Default for 8-bit RGB source, an invalid combination */ 2271 /* Default for 8-bit RGB source, an invalid combination */
2272 { 0,0,0, 0, 0,0,0, 0, NULL, NULL }, 2272 { 0,0,0, 0, 0,0,0, 0, NULL, NULL },
2273 }; 2273 };
2274 static const struct blit_table normal_blit_2[] = { 2274 static const struct blit_table normal_blit_2[] = {
2275 #ifdef USE_ASMBLIT 2275 #if SDL_HERMES_BLITTERS
2276 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000007E0,0x0000F800, 2276 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000007E0,0x0000F800,
2277 0, ConvertX86p16_16BGR565, ConvertX86, NO_ALPHA }, 2277 0, ConvertX86p16_16BGR565, ConvertX86, NO_ALPHA },
2278 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x00007C00,0x000003E0,0x0000001F, 2278 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x00007C00,0x000003E0,0x0000001F,
2279 0, ConvertX86p16_16RGB555, ConvertX86, NO_ALPHA }, 2279 0, ConvertX86p16_16RGB555, ConvertX86, NO_ALPHA },
2280 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000003E0,0x00007C00, 2280 { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000003E0,0x00007C00,
2281 0, ConvertX86p16_16BGR555, ConvertX86, NO_ALPHA }, 2281 0, ConvertX86p16_16BGR555, ConvertX86, NO_ALPHA },
2282 #endif 2282 #elif SDL_ALTIVEC_BLITTERS
2283 #ifdef USE_ALTIVEC_BLITTERS
2284 /* has-altivec */ 2283 /* has-altivec */
2285 { 0x0000F800,0x000007E0,0x0000001F, 4, 0x00000000,0x00000000,0x00000000, 2284 { 0x0000F800,0x000007E0,0x0000001F, 4, 0x00000000,0x00000000,0x00000000,
2286 2, NULL, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, 2285 2, NULL, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
2287 { 0x00007C00,0x000003E0,0x0000001F, 4, 0x00000000,0x00000000,0x00000000, 2286 { 0x00007C00,0x000003E0,0x0000001F, 4, 0x00000000,0x00000000,0x00000000,
2288 2, NULL, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, 2287 2, NULL, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
2302 static const struct blit_table normal_blit_3[] = { 2301 static const struct blit_table normal_blit_3[] = {
2303 /* Default for 24-bit RGB source, never optimized */ 2302 /* Default for 24-bit RGB source, never optimized */
2304 { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 } 2303 { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
2305 }; 2304 };
2306 static const struct blit_table normal_blit_4[] = { 2305 static const struct blit_table normal_blit_4[] = {
2307 #ifdef USE_ASMBLIT 2306 #if SDL_HERMES_BLITTERS
2308 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F, 2307 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
2309 1, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA }, 2308 1, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
2310 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F, 2309 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
2311 0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA }, 2310 0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA },
2312 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800, 2311 { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
2330 { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0xFF000000,0x00FF0000,0x0000FF00, 2329 { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0xFF000000,0x00FF0000,0x0000FF00,
2331 0, ConvertX86p32_32RGBA888, ConvertX86, NO_ALPHA }, 2330 0, ConvertX86p32_32RGBA888, ConvertX86, NO_ALPHA },
2332 { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0x0000FF00,0x00FF0000,0xFF000000, 2331 { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0x0000FF00,0x00FF0000,0xFF000000,
2333 0, ConvertX86p32_32BGRA888, ConvertX86, NO_ALPHA }, 2332 0, ConvertX86p32_32BGRA888, ConvertX86, NO_ALPHA },
2334 #else 2333 #else
2335 #ifdef USE_ALTIVEC_BLITTERS 2334 #if SDL_ALTIVEC_BLITTERS
2336 /* has-altivec | dont-use-prefetch */ 2335 /* has-altivec | dont-use-prefetch */
2337 { 0x00000000,0x00000000,0x00000000, 4, 0x00000000,0x00000000,0x00000000, 2336 { 0x00000000,0x00000000,0x00000000, 4, 0x00000000,0x00000000,0x00000000,
2338 6, NULL, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, 2337 6, NULL, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
2339 /* has-altivec */ 2338 /* has-altivec */
2340 { 0x00000000,0x00000000,0x00000000, 4, 0x00000000,0x00000000,0x00000000, 2339 { 0x00000000,0x00000000,0x00000000, 4, 0x00000000,0x00000000,0x00000000,
2391 && surface->map->identity) 2390 && surface->map->identity)
2392 return Blit2to2Key; 2391 return Blit2to2Key;
2393 else if(dstfmt->BytesPerPixel == 1) 2392 else if(dstfmt->BytesPerPixel == 1)
2394 return BlitNto1Key; 2393 return BlitNto1Key;
2395 else { 2394 else {
2396 #ifdef USE_ALTIVEC_BLITTERS 2395 #if SDL_ALTIVEC_BLITTERS
2397 if((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) { 2396 if((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) {
2398 return Blit32to32KeyAltivec; 2397 return Blit32to32KeyAltivec;
2399 } else 2398 } else
2400 #endif 2399 #endif
2401 2400
2414 (srcfmt->Gmask == 0x0000FF00) && 2413 (srcfmt->Gmask == 0x0000FF00) &&
2415 (srcfmt->Bmask == 0x000000FF) ) { 2414 (srcfmt->Bmask == 0x000000FF) ) {
2416 if ( surface->map->table ) { 2415 if ( surface->map->table ) {
2417 blitfun = Blit_RGB888_index8_map; 2416 blitfun = Blit_RGB888_index8_map;
2418 } else { 2417 } else {
2419 #ifdef USE_ASMBLIT 2418 #if SDL_HERMES_BLITTERS
2420 sdata->aux_data = ConvertX86p32_8RGB332; 2419 sdata->aux_data = ConvertX86p32_8RGB332;
2421 blitfun = ConvertX86; 2420 blitfun = ConvertX86;
2422 #else 2421 #else
2423 blitfun = Blit_RGB888_index8; 2422 blitfun = Blit_RGB888_index8;
2424 #endif 2423 #endif
2459 } 2458 }
2460 } 2459 }
2461 } 2460 }
2462 2461
2463 #ifdef DEBUG_ASM 2462 #ifdef DEBUG_ASM
2464 #ifdef USE_ASMBLIT 2463 #if SDL_HERMES_BLITTERS
2465 if ( blitfun == ConvertMMX ) 2464 if ( blitfun == ConvertMMX )
2466 fprintf(stderr, "Using mmx blit\n"); 2465 fprintf(stderr, "Using mmx blit\n");
2467 else 2466 else
2468 if ( blitfun == ConvertX86 ) 2467 if ( blitfun == ConvertX86 )
2469 fprintf(stderr, "Using asm blit\n"); 2468 fprintf(stderr, "Using asm blit\n");