I’m porting my game from Android to iOS and am just looking for a bit of confirmation about the most performance optimal way to handle textures on iOS, before I go and change a large amount of code.
The game works great on anything from a Galaxy S2 up on Android but the performance is very poor on an iPhone 4 with OS 6.1, with the frame rate consistently dropping from 30 to the low 20s.
From what I’m reading on various forums, it’s better to use a few large sprite sheets as opposed to many small ones. I pretty much have one sprite sheet per game object, resulting in around 100 small textures. Any advice would be appreciated.
I would first be sure you’re batching your sprites correctly. You should be using SpriteBatch, you should avoid SpriteSortMode.Immediate, and you should make sure you’re not rendering sprites that are offscreen.
Second run a C# memory profiling tool over your game. If you are allocating too much temporary data during gameplay you could be getting slowdowns from the garbage collector. If this is happening no amount of graphics optimization will improve your performance.
Less textures is always better. You can either manually combine these into bigger sprite sheets or use some tools to do it.
Also using the PVRTC texture compression (when the quality is acceptable for your game) also helps as you get 8 to 1 compression. This not only makes for smaller textures on disk, but also improves loading times, reduces GPU memory usage, and even improved texturing performance.
My SpriteBatch code wasn’t structured very well (too many Begin and End calls) and I was actually using Immediate mode, so fixing those issues helped a bit. I also ran my code through Instruments and noticed that my Update method was running for the same percentage of time as my Draw because my collision detection code was very inefficient, so I’ve improved that as well.
The FPS is now sitting at the high 20s for most of the time but does seem to jump down to 15 every so often. I’m assuming this is the garbage collector so I’ll keep analyzing my code to see if I’m creating too many unnecessary objects.