Faster blit with no ColorKey

Applied to following formats:

ABGR8888 -> BGRX8888 :  faster x5   (3177493 -> 630439)
ABGR8888 -> RGBX8888 :  faster x5   (3178104 -> 628925)

ARGB8888 -> BGRX8888 :  faster x4   (3141089 -> 629448)
ARGB8888 -> RGBX8888 :  faster x5   (3216413 -> 630465)

BGR888 -> BGRA8888 :  faster x4   (3145403 -> 637701)
BGR888 -> BGRX8888 :  faster x4   (3142106 -> 630144)
BGR888 -> RGBA8888 :  faster x4   (3202685 -> 649384)
BGR888 -> RGBX8888 :  faster x4   (3170617 -> 658670)

BGRA8888 -> BGR888 :  faster x4   (3203308 -> 657697)
BGRA8888 -> RGB888 :  faster x5   (3201475 -> 631747)
BGRA8888 -> RGBX8888 :  faster x5   (3274544 -> 630409)

BGRX8888 -> ABGR8888 :  faster x4   (3149753 -> 638682)
BGRX8888 -> ARGB8888 :  faster x5   (3164101 -> 631273)
BGRX8888 -> BGR888 :  faster x4   (3144454 -> 630712)
BGRX8888 -> RGB888 :  faster x4   (3160490 -> 638047)
BGRX8888 -> RGBA8888 :  faster x5   (3308988 -> 631232)
BGRX8888 -> RGBX8888 :  faster x5   (3216775 -> 638065)

RGB888 -> BGRA8888 :  faster x4   (3143135 -> 655146)
RGB888 -> BGRX8888 :  faster x4   (3141790 -> 653771)
RGB888 -> RGBA8888 :  faster x5   (3214402 -> 637001)
RGB888 -> RGBX8888 :  faster x4   (3143082 -> 630009)

RGBA8888 -> BGR888 :  faster x3   (3157048 -> 920375)
RGBA8888 -> BGRX8888 :  faster x5   (3196692 -> 632996)
RGBA8888 -> RGB888 :  faster x4   (3141570 -> 652151)

RGBX8888 -> ABGR8888 :  faster x5   (3175401 -> 631218)
RGBX8888 -> ARGB8888 :  faster x4   (3144690 -> 639440)
RGBX8888 -> BGR888 :  faster x4   (3144250 -> 630171)
RGBX8888 -> BGRA8888 :  faster x5   (3220321 -> 630731)
RGBX8888 -> BGRX8888 :  faster x4   (3178453 -> 637445)
RGBX8888 -> RGB888 :  faster x5   (3203623 -> 632596)
Sylvain Becker 2019-02-07 18:51:14 +01:00
parent 7372295ec9
commit e5192384d0
1 changed files with 70 additions and 0 deletions

View File

@ -2163,7 +2163,77 @@ BlitNtoN(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? info->a : 0;
/* Any src/dst 8888 for CopyAlpha, no ARGB2101010 */
if (srcbpp == 4 && dstbpp == 4 &&
srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
Uint32 *src32 = (Uint32*)src;
Uint32 *dst32 = (Uint32*)dst;
/* Find the appropriate permutation */
int missing = 0, r, g, b, a;
int Pixel = 0x04030201; /* +1 */
RGB_FROM_PIXEL(Pixel, srcfmt, r, g, b);
if (dstfmt->Amask) {
PIXEL_FROM_RGBA(Pixel, dstfmt, r, g, b, 0);
} else {
PIXEL_FROM_RGB(Pixel, dstfmt, r, g, b);
}
r = Pixel & 0xFF;
g = (Pixel >> 8) & 0xFF;
b = (Pixel >> 16) & 0xFF;
a = (Pixel >> 24) & 0xFF;
{
int val;
for (val = 0; val <= 3; val++) {
if (r != val && g != val && b != val && a != val) {
missing = val;
}
}
}
if (r == 0) {
r = missing;
missing = 0;
} else if (g == 0) {
g = missing;
missing = 1;
} else if (b == 0) {
b = missing;
missing = 2;
} else if (a == 0) {
a = missing;
missing = 3;
}
/* -1 */
r -= 1; g -= 1; b -= 1; a -= 1;
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(
{
Uint8 *s8 = (Uint8 *)src32;
Uint8 *d8 = (Uint8 *)dst32;
d8[0] = s8[r];
d8[1] = s8[g];
d8[2] = s8[b];
d8[3] = s8[a];
d8[missing] = alpha;
++src32;
++dst32;
}, width);
/* *INDENT-ON* */
src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
}
return;
}
while (height--) {
/* *INDENT-OFF* */
DUFFS_LOOP(