performance of sub-bitmaps
Peter Hull

noob question of my own!
If I have a load of small bitmaps to draw, it is, as I understand it, a good idea to put these all on one bigger bitmap and blit regions of it (a texture atlas I think is the term)
I could do this by keeping my own list of rectangles and al_draw_bitmap_region or I could create sub-bitmaps and just al_draw_bitmap them. As far as I know, all sub-bitmaps share the same backing bitmap but just apply a region automatically.
Are these the same thing performance-wise or are there other issues to consider?

SiegeLord

They're the same thing when drawing them, performance wise. Here's literally the totality of the code difference between drawing a bitmap, or its sub-bitmap:

   if (bitmap->parent) {
      parent = bitmap->parent;
      sx += bitmap->xofs;
      sy += bitmap->yofs;
   }

The only difference I can think of is that your custom rectangle will probably be more lightweight than a bitmap (e.g. every bitmap sets up an orthographic transform just in case its ever used as a target bitmap). But that shouldn't be a huge difference.

Dizzy Egg

On the KrampusHack I used al_hold_bitmap_drawing for the first time, and noticed a massive improvement when using a large bitmap and drawing regions from it. It was probably just in my brain but it seemed a bit faster than using subs. Given SiegeLords reply it was probably just background processes changing at the time of testing. The only thing that enforced it was that I was using OpenGL, and thought maybe it was a specific thing to that.

I suppose the only useful thing to take from that rant is that al_hold_bitmap_drawing is cool.

Peter Hull

Good shout on al_hold_bitmap_drawing I'd forgotten all about that. I'm not really close to having to worry about speed but, if I've time, I'll do some benchmarks to see what difference it makes.

tobing

The full performance comes with sub-bitmaps, hold bitmap drawing and HW acceleration. :)

Thread #618337. Printed from Allegro.cc