Take the 2-minute tour ×

I'm interested in some performance tweaks for a relatively simple OpenGL ES based 2D iPhone game. What performance tweaks have you found? The performance of the game is pretty good on most devices (3G, 2nd gen touch, and iPhone 4)... But I still want to give the user the best experience possible.

p.s. I'm still using OpenGL ES 1.1

share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

Some low-level things that might help:

  • Turn "thumb mode" off. This is especially important if you have lots of floating-point operations, like most games do.
  • Use CADisplayLink to drive your loop
  • If you're using a lot of floating point math, consider using the vector floating point processor or the new intrinsics library.

And of course, profile your game with Instruments and Shark to narrow down where the performance bottlenecks are.

Check out my presentation from last year's GDC Austin for more details on iPhone performance optimizations.

share|improve this answer
The "thumb mode" tweak only applies if you're compiling for armv6. On the newer processors (i.e. ones that can run armv7 code, so the 3GS and up), using thumb is faster for floating point calculations. If you end up actually compiling for both (most people don't since it increases download size because you bundle two executables), you can set up a build order rule on that project setting where armv6 doesn't use thumb, and armv7 does. –  Tetrad Jul 25 '10 at 16:46
add comment

I'll add another few nuggets that I noticed gave me a speed increase on the 2G (I tested a lot of permutations on 2G to know what was feasible).

  • use shorts for indices if you can, or in general, experiment with vertex formats.
  • experiment with tile sizes. 16x16 tiles may or may not be faster. CPU overhead differs little, data uploaded is more, but cache might be better utilized. As below, I wish I had my tests handy (and organized)
  • use as short a format as you can for texture coordinates. I found it was faster to have shorter format and do the multiplication of the texture coords by the texture matrix.
  • Test different screen formats. I don't have my tests at hand anymore (I gave up on iPhone aeons ago), but texture depths and display depths/orientation made for all kinds of different performance stats (logical but still, try it).

The biggest thing however, make sure your game is framerate independent. I never tested on my 3GS, but on the 2G you will get spikes. Even in a very tight, always the same testcase (just scrolling 4 layers), there was a 8ms spike every second or so.

As for plain C optimizations, the same goes as pretty much anywhere else. Memory layout, avoiding dynamic allocations, avoiding unnecessary branches.

share|improve this answer
add comment

When it comes to textures it's also important to note that you should stay away from large transparent areas in images. If you e.g. have a mask that you put in front of the whole game scene, it's faster to assemble it out of 4 images (just the borders) than to use 1 large image that covers the entire screen.

share|improve this answer
add comment

What I found very interesting, and never mentioned to anyone, was that I noticed a speed difference (on the rendering side of things) when rendering my sprites and tiles 90 degrees rotated. I can't remember whether it was faster portrait or landscape. You'd have to rotate all your graphics for correct usage of course, but the phenomenon itself was interesting. Must be a memory organization/cache access issue. This was doing 4 layers of parallax on a 2G. I found this the biggest win, as there was ample time to run a game in the background (on a 2G you're locked to 30fps pretty much anyhow imo).

share|improve this answer
add comment

In the course of the famous Stanford lectures on iPhone development, Tim Omernick from ngmoco presented many ways to optimize opengl for iPhone (Youtube link). The keynote lasts ~30min and I found it very informative.

share|improve this answer
It's a great presentation. –  MrDatabase Feb 5 '11 at 18:22
add comment

Your Answer


