comparison src/video/SDL_blit_N.c @ 2247:93994f65c74c

Removed hermes since it's LGPL and not compatible with a commercial license. Prepping for using MMX and SSE intrinsics instead of inline assembly. .. except for memcpy equivalents which only get faster if they can exploit the parallelism of loading into multiple SIMD registers. :)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 15 Aug 2007 08:21:10 +0000
parents 8055185ae4ed
children 340942cfda48
comparison
equal deleted inserted replaced
2246:75daa0792bd1 2247:93994f65c74c
877 #else /* SDL_BYTEORDER == SDL_BIG_ENDIAN */ 877 #else /* SDL_BYTEORDER == SDL_BIG_ENDIAN */
878 #define HI 0 878 #define HI 0
879 #define LO 1 879 #define LO 1
880 #endif 880 #endif
881 881
882 #if SDL_HERMES_BLITTERS
883
884 /* Heheheh, we coerce Hermes into using SDL blit information */
885 #define X86_ASSEMBLER
886 #define HermesConverterInterface SDL_BlitInfo
887 #define HermesClearInterface void
888 #define STACKCALL
889
890 #include "../hermes/HeadMMX.h"
891 #include "../hermes/HeadX86.h"
892
893 #else
894
895 /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */ 882 /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
896 #define RGB888_RGB332(dst, src) { \ 883 #define RGB888_RGB332(dst, src) { \
897 dst = (Uint8)((((src)&0x00E00000)>>16)| \ 884 dst = (Uint8)((((src)&0x00E00000)>>16)| \
898 (((src)&0x0000E000)>>11)| \ 885 (((src)&0x0000E000)>>11)| \
899 (((src)&0x000000C0)>>6)); \ 886 (((src)&0x000000C0)>>6)); \
1247 dst += dstskip; 1234 dst += dstskip;
1248 } 1235 }
1249 } 1236 }
1250 #endif /* USE_DUFFS_LOOP */ 1237 #endif /* USE_DUFFS_LOOP */
1251 } 1238 }
1252
1253 #endif /* SDL_HERMES_BLITTERS */
1254 1239
1255 1240
1256 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */ 1241 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */
1257 #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1]) 1242 #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1])
1258 static void 1243 static void
2355 static const struct blit_table normal_blit_1[] = { 2340 static const struct blit_table normal_blit_1[] = {
2356 /* Default for 8-bit RGB source, an invalid combination */ 2341 /* Default for 8-bit RGB source, an invalid combination */
2357 {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, 2342 {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL},
2358 }; 2343 };
2359 static const struct blit_table normal_blit_2[] = { 2344 static const struct blit_table normal_blit_2[] = {
2360 #if SDL_HERMES_BLITTERS 2345 #if SDL_ALTIVEC_BLITTERS
2361 {0x0000F800, 0x000007E0, 0x0000001F, 2, 0x0000001F, 0x000007E0,
2362 0x0000F800,
2363 0, ConvertX86p16_16BGR565, ConvertX86, NO_ALPHA},
2364 {0x0000F800, 0x000007E0, 0x0000001F, 2, 0x00007C00, 0x000003E0,
2365 0x0000001F,
2366 0, ConvertX86p16_16RGB555, ConvertX86, NO_ALPHA},
2367 {0x0000F800, 0x000007E0, 0x0000001F, 2, 0x0000001F, 0x000003E0,
2368 0x00007C00,
2369 0, ConvertX86p16_16BGR555, ConvertX86, NO_ALPHA},
2370 #elif SDL_ALTIVEC_BLITTERS
2371 /* has-altivec */ 2346 /* has-altivec */
2372 {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 2347 {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000,
2373 0x00000000, 2348 0x00000000,
2374 2, NULL, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, 2349 2, NULL, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
2375 {0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 2350 {0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000,
2395 static const struct blit_table normal_blit_3[] = { 2370 static const struct blit_table normal_blit_3[] = {
2396 /* Default for 24-bit RGB source, never optimized */ 2371 /* Default for 24-bit RGB source, never optimized */
2397 {0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0} 2372 {0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0}
2398 }; 2373 };
2399 static const struct blit_table normal_blit_4[] = { 2374 static const struct blit_table normal_blit_4[] = {
2400 #if SDL_HERMES_BLITTERS
2401 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0,
2402 0x0000001F,
2403 1, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA},
2404 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0,
2405 0x0000001F,
2406 0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA},
2407 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000001F, 0x000007E0,
2408 0x0000F800,
2409 1, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA},
2410 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000001F, 0x000007E0,
2411 0x0000F800,
2412 0, ConvertX86p32_16BGR565, ConvertX86, NO_ALPHA},
2413 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0,
2414 0x0000001F,
2415 1, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA},
2416 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0,
2417 0x0000001F,
2418 0, ConvertX86p32_16RGB555, ConvertX86, NO_ALPHA},
2419 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000001F, 0x000003E0,
2420 0x00007C00,
2421 1, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA},
2422 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000001F, 0x000003E0,
2423 0x00007C00,
2424 0, ConvertX86p32_16BGR555, ConvertX86, NO_ALPHA},
2425 {0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x00FF0000, 0x0000FF00,
2426 0x000000FF,
2427 0, ConvertX86p32_24RGB888, ConvertX86, NO_ALPHA},
2428 {0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00,
2429 0x00FF0000,
2430 0, ConvertX86p32_24BGR888, ConvertX86, NO_ALPHA},
2431 {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00,
2432 0x00FF0000,
2433 0, ConvertX86p32_32BGR888, ConvertX86, NO_ALPHA},
2434 {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0xFF000000, 0x00FF0000,
2435 0x0000FF00,
2436 0, ConvertX86p32_32RGBA888, ConvertX86, NO_ALPHA},
2437 {0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x0000FF00, 0x00FF0000,
2438 0xFF000000,
2439 0, ConvertX86p32_32BGRA888, ConvertX86, NO_ALPHA},
2440 #else
2441 #if SDL_ALTIVEC_BLITTERS 2375 #if SDL_ALTIVEC_BLITTERS
2442 /* has-altivec | dont-use-prefetch */ 2376 /* has-altivec | dont-use-prefetch */
2443 {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 2377 {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000,
2444 0x00000000, 2378 0x00000000,
2445 6, NULL, ConvertAltivec32to32_noprefetch, 2379 6, NULL, ConvertAltivec32to32_noprefetch,
2458 0x0000001F, 2392 0x0000001F,
2459 0, NULL, Blit_RGB888_RGB565, NO_ALPHA}, 2393 0, NULL, Blit_RGB888_RGB565, NO_ALPHA},
2460 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 2394 {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0,
2461 0x0000001F, 2395 0x0000001F,
2462 0, NULL, Blit_RGB888_RGB555, NO_ALPHA}, 2396 0, NULL, Blit_RGB888_RGB555, NO_ALPHA},
2463 #endif
2464 /* Default for 32-bit RGB source, used if no other blitter matches */ 2397 /* Default for 32-bit RGB source, used if no other blitter matches */
2465 {0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0} 2398 {0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0}
2466 }; 2399 };
2467 static const struct blit_table *normal_blit[] = { 2400 static const struct blit_table *normal_blit[] = {
2468 normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4 2401 normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4
2527 (srcfmt->Rmask == 0x00FF0000) && 2460 (srcfmt->Rmask == 0x00FF0000) &&
2528 (srcfmt->Gmask == 0x0000FF00) && (srcfmt->Bmask == 0x000000FF)) { 2461 (srcfmt->Gmask == 0x0000FF00) && (srcfmt->Bmask == 0x000000FF)) {
2529 if (surface->map->table) { 2462 if (surface->map->table) {
2530 blitfun = Blit_RGB888_index8_map; 2463 blitfun = Blit_RGB888_index8_map;
2531 } else { 2464 } else {
2532 #if SDL_HERMES_BLITTERS
2533 sdata->aux_data = ConvertX86p32_8RGB332;
2534 blitfun = ConvertX86;
2535 #else
2536 blitfun = Blit_RGB888_index8; 2465 blitfun = Blit_RGB888_index8;
2537 #endif
2538 } 2466 }
2539 } else { 2467 } else {
2540 blitfun = BlitNto1; 2468 blitfun = BlitNto1;
2541 } 2469 }
2542 } else { 2470 } else {
2573 } 2501 }
2574 } 2502 }
2575 } 2503 }
2576 2504
2577 #ifdef DEBUG_ASM 2505 #ifdef DEBUG_ASM
2578 #if SDL_HERMES_BLITTERS
2579 if (blitfun == ConvertMMX)
2580 fprintf(stderr, "Using mmx blit\n");
2581 else if (blitfun == ConvertX86)
2582 fprintf(stderr, "Using asm blit\n");
2583 else
2584 #endif
2585 if ((blitfun == BlitNtoN) || (blitfun == BlitNto1)) 2506 if ((blitfun == BlitNtoN) || (blitfun == BlitNto1))
2586 fprintf(stderr, "Using C blit\n"); 2507 fprintf(stderr, "Using C blit\n");
2587 else 2508 else
2588 fprintf(stderr, "Using optimized C blit\n"); 2509 fprintf(stderr, "Using optimized C blit\n");
2589 #endif /* DEBUG_ASM */ 2510 #endif /* DEBUG_ASM */