Skip to content
May 13, 2009 / Abe Pralle

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!

Advertisements

2 Comments

Leave a Comment
  1. Jacob Stevens / May 14 2009 8:51 am

    Awesome! We can definitely work with this.

    Couple questions:

    1. What happens when you switch render modes, ie from normal to overexpose? I assume we should “batch” draw calls with the same blending mode if possible?

    2. The implementations I read about on message boards required sub-images to be powers of two in size. I never really understood why. It makes sense for the full sheet, but the sub-images seem like they could be totally arbitrary, in fact not even rectangular. Does this system have the same requirement?

    3. Are you still using a matrix stack for transformation? How many matrices are the above tests being run through? Does the amount of transformation seem to make much difference?

    4. Would it be possible to gather some statistics, like total number of images in the texture sheet(s), space remaining in the texture sheet(s) and number of draw calls being made per frame? That would help us fine-tune performance.

    Thanks!
    Jacob

  2. Abe Pralle / May 14 2009 11:41 am

    1. Yeah, when you switch render modes or primitive types (e.g. lines vs quads) it renders everything it has buffered so far. Batch calls are good.

    2. Plasmacore has no restrictions on texture size. The powers of 2 just make placement and defragmentation easier to implement, but my system should prove to be both versatile and efficient. While the image can be any size, what I do internally is round either the x or the y dimension up to a multiple of 16. If an image ends up being x=32, I’ll pack it vertically into a free chunk that’s already 32 pixels wide. Unreferenced images return their chunks to a free pool where they are recursively coalesced with other chunks to the side that are the same height or other chunks vertically that are the same width.

    3. Yes. Each image does a 2×3*2×3 matrix multiplication to define its transform, then each corner vertex is transformed via a 2×3*2×1 multiplication. It has negligible impact.

    4. Sure, I’ll add some profiling capabilities.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: