Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Use fast path for RGB 565 -> 32-bit XRGB 8888
Browse files Browse the repository at this point in the history
Hello Sam,
while profiling ScummVM I noticed it was making use of the generic
BlitNToN blitter, which struck me as odd because it should be a very
classical codepath.
After investigating, I saw that in the blit op chooser:

    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x00FF0000,0x0000FF00,0x000000FF,
      0, NULL, Blit_RGB565_ARGB8888, SET_ALPHA },
    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x000000FF,0x0000FF00,0x00FF0000,
      0, NULL, Blit_RGB565_ABGR8888, SET_ALPHA },
    { 0x0000F800,0x000007E0,0x0000001F, 4, 0xFF000000,0x00FF0000,0x0000FF00,
      0, NULL, Blit_RGB565_RGBA8888, SET_ALPHA },
    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x0000FF00,0x00FF0000,0xFF000000,
      0, NULL, Blit_RGB565_BGRA8888, SET_ALPHA },

Couldn't the optimized versions be used for NO_ALPHA too? I take it
that the resulting alpha component can be undefined as it should never
be used.
I tried this (see attached patch) and it worked perfectly (and
therefore faster) on ScummVM but there might be a trick (I'm not
expert at the semantics of SDL, ie NO_ALPHA, SET_ALPHA and COPY_ALPHA
there).
What do you think?

Cheers,
Bertrand
  • Loading branch information
slouken committed Sep 2, 2012
1 parent 9894b5b commit fa92345
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/video/SDL_blit_N.c
Expand Up @@ -2360,16 +2360,16 @@ static const struct blit_table normal_blit_2[] = {
#endif
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00,
0x000000FF,
0, Blit_RGB565_ARGB8888, SET_ALPHA},
0, Blit_RGB565_ARGB8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00,
0x00FF0000,
0, Blit_RGB565_ABGR8888, SET_ALPHA},
0, Blit_RGB565_ABGR8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000,
0x0000FF00,
0, Blit_RGB565_RGBA8888, SET_ALPHA},
0, Blit_RGB565_RGBA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000,
0xFF000000,
0, Blit_RGB565_BGRA8888, SET_ALPHA},
0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA},

/* Default for 16-bit RGB source, used if no other blitter matches */
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
Expand Down

0 comments on commit fa92345

Please sign in to comment.