RE: [AD] improvements on alpha blending...

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Title: RE: [AD] improvements on alpha blending...

Javier González writes:
>> We can keep it global. AFAIK, it can be shared in between various calls
>> to draw_trans_sprite, and should remain valid unless a call to
>> set_blender() was made.
>
> certainly, i was thinking of draw_trans_sprite, but it is
> true it can be done even better per each set_trans_blender call

This is quite a dangerous optimisation, though, because building the table costs just as much as the current per-pixel blend, so it is only a win if you are drawing very large images, and could lose a huge amount of time if people are doing things like drawing clouds of 8x8 particles with a different alpha setting on each one (which is not such an unusual thing to do).

To give consistently good performance, you'd have to keep both implementations, and only decide to use the precalculated table once a draw call decided that the area being blended was large enough for this to be a win. This adds a lot of complexity and extra house-keeping logic, since at the time set_trans_blender() gets called, there's no way to know what the subsequent usage will be. I'm not convinced that the performance win in the very-big-image case would be enough to justify all that extra work, and having to maintain two completely separate code paths.

I reckon that doing the blending on a per-line basis would give a good speed boost, that would apply more equally in all situations and not need multiple versions of the code.


        Shawn.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/