[SDL] 2D API evolution (SDL 1.3/2.0)
René Dudfield
renesd at gmail.com
Thu Aug 17 20:11:36 PDT 2006
All it is doing is reusing the loop part of the code. Since the
looping parts are going to be the same for almost every blending type
of function. So you just need to optimize the loop once for each
combination of surface types and reuse it for each blending mode.
The speed is not that great... there is only one special case
optimization, and that could be improved too. I can't remember what
the benchmarks were like, however the SDL 3dnow/mmx alpha blit was
lots faster. They have been fast enough for two games which have used
these blitters.
The other part it is doing is keeping them within one function, and
sharing some of the code. This saves code size by not having to
declare so many functions, and uses the same setup code.
It does no checks for blending mode within the inner loops. It uses
separate loops for each condition.
I've uploaded the file here.
http://rene.f0o.com/~rene/stuff/alphablit.c
Anyway... I'll keep you updated when I get around to doing some more
on them. I'm interested in optimizing the 32bit case, so I'll
probably do that one with mmx. Any tips appreciated!
I'm also going to implement fill methods with blending... since that
is a lot faster as you only have one image to apply the color too.
It's quite common to fade to black, or fade to white.
I'll explain what the macros do a little more.
// this sets up variables. and sets up the top of the loop for the
// this checks to see if source and dest are both 32bit,
// and does a special case blending function.
// Note that the looping is in here
BLEND_TOP_4;
// this is the special case 32bit blend macro.
BLEND_ADD4(*src,*dst);
// it checks that we do not have any special blending parts.
// this gets the different components out of the
BLEND_START_GENERIC;
// this is the generic blending macro.
BLEND_ADD(sR, sG, sB, sA, dR, dG, dB, dA);
// this finishs off the loop for the generic blending part.
BLEND_END_GENERIC;
On 8/18/06, Sam Lantinga <slouken at devolution.com> wrote:
> > For each blend mode you have one case statement.
>
> > case PYGAME_BLEND_ADD: {
> > BLEND_TOP_4;
> > BLEND_ADD4(*src,*dst);
> > BLEND_START_GENERIC;
> > BLEND_ADD(sR, sG, sB, sA, dR, dG, dB, dA);
> > BLEND_END_GENERIC;
> > break;
> > }
>
> SDL's blitters are mostly incredibly tuned C. Do you get really good
> performance from this method?
>
> -Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
More information about the SDL
mailing list