Re: [AD] clipping line algorithm

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


Eric wrote:
So, basically, if this new flag is not set, the library would be allowed to bypass entirely the vtable of the bitmap? I'm still a bit uncomfortable with this idea.

Bob replied:
I don't like the idea of bypassing the vtable. If we can, we should have a putpixel and _putpixel vtable entry.

I understand it's uglier to not use the vtable, but a bit of profiling indicates that it really speeds things up. The following are the cases I tested.

 (1) rotate_sprite() uses bmp->vtable->putpixel and bmp->vtable-getpixel.
(2) rotate_sprite() uses _putpixel and _getpixel, but as function pointers (should be equivalent to having a vtable entry for _putpixel, in terms of speed). (3) rotate_sprite() as it is now, using bmp_write*() for writing and BITMAP->line[y][x] for reading.

Method (1) was surprisingly a bit faster than method (2); however, method (3) was (in color depths 8, 15, 16, 24, and 32, respectively) about 8, 7, 7, 3.4, and 3.8 times faster than any of the other ones. (I profiled 10000 calls to rotate_sprite() from a 320x200 memory sprite to the centre of a 640x480 memory bitmap, with angles evenly distributed around the circle, and trying all color depths. See http://peg.it.uu.se/~sven/rotate-profile.zip )

Although bypassing the vtable is a little bit ugly, is there any particular situation where it is really significantly bad? As long as we have a version that uses the vtable, and BITMAP->id is able to indicate when the optimized version can be used instead, I think we should be fine?

--
Sven





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