iPhone drawing speed – Part 2

I just finished implementing an automatic texture sheet system for iPhone Plasmacore.  By default it automatically places image textures onto a single 1024×1024 texture sheet, creating additional sheets if you run out of room.  In addition I’ve transparently buffered all drawing calls, so drawing 50 images will just store up 100 triangles and then render them all at once later.

There’s significant speed-up over my previous implementation, but you’ll still have to be careful.  The results:

  • I altered the system to redraw at 30 fps instead of 60.  Even a blank screen can’t quite hold steady at 60 fps, so I’d rather aim for a steady 30 fps on iPhone.  No changes required to your Plasmacore programs.
  • iPhone Plasmacore can draw about 9280/x square images in 1/30 second, where x is the size of a single dimension of the image (16 px or higher; smaller images are roughly the same).  [Edit: make that "9280 / sqrt(x)" where x is the number of pixels per image].  So around 580 16×16 pixel images, 290 32×32 images, or 145 64×64 images.
  • Sound effects will probably slow it down a bit more; I need to do some further testing with that.

Looking good for modestly complex games!

iPhone drawing speed

I’ve been doing some initial drawing tests on the iPhone with so-so results.

Turns out it uses a graphics chip that renders different tile sections of the screen in parallel.  I couldn’t find any info on how big the tiles are offhand.

Here are my very informal results. [Clarification: I'm drawing tile/sprite images as a series of individual calls, each with its own 2D transform]

In 1/60th of a second, the iPhone can draw about:
24 textured polygons in the same spot, quarter-screen size or less.
OR 75 spaced-out polys (32×32 in this case)
OR 6 full-screen polys.

Notes:
- This is with a tight drawing-only loop.  Logic & sound adds a bit of overhead – not an excessive amount but then again every bit hurts.
- Things that didn’t significantly improve the speed: turning off texturing, turning off back-buffer clear, turning off alpha blending, using texture formats with fewer bytes per pixel.

In light of this I’m gonna tweak Plasmacore for iPhone so that it’s CYOB (Clear Your Own Backbuffer).  Not to save time clearing the backbuffer, but to allow you to get tricky (if you want) and only redraw altered portions of the screen.  The good news is that Plasmacore (as usual) will still update() at 60fps no matter how slow the draw() is going, so things might get a little rougher but they won’t get slower.

A final tip will be to avoid drawing font-based text – use prerendered words!

Slag wrapper methods

I’ve been encountering some programming situations lately that cried out for some aspect-oriented features that weren’t in Slag – until tonight!

Read the rest of this entry »