10
votes

I'm coding an OpenGL ES 1.1 app for Android and iPhone. The OpenGL ES engine lives in a shared library and is accessed via NDK on Android.

I'm looking to optimise my OpenGL performance. There's plenty of videos and resources out there, e.g.:

http://www.vizworld.com/2010/02/ngmocos-tim-omernick-optimizing-opengl-iphone/

http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Performance/Performance.html#//apple_ref/doc/uid/TP40008793-CH105

http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesforWorkingwithVertexData/TechniquesforWorkingwithVertexData.html

OpenGL ES 2.0 : Seeking VBO Performance/Optimisation Tips For Many Moving Vertices

When are VBOs faster than "simple" OpenGL primitives (glBegin())?

https://gamedev.stackexchange.com/questions/1068/opengl-optimization-tips

But generally there are well known techniques that apply universally, such as:

  • Use vertex buffer objects (VBOs)
  • Minimise OpenGL state changes
  • Use texture atlassing where possible to avoid having to select many different textures

Some techniques are, or may be, a bit more sensitive in their specifics, and may differ between Android and iPhone, and that's what I'm interested in. For example:

  • Interleave your vertex data inside each vertex: e.g. vertex coord; texture coord; normal. Is there a preferred order of items in the interleaving?
  • Pad out each vertex to the next multiple of some number of bytes. I see the number 32 bandied about, but have also see 4 or 8 in some places.
  • Consider using a short or similar for each Vertex's coordinate, rather than a float

So my question is: what are the finer details of the magic optimisations such as the last list above that differ between Android and iPhone? Where they differ, what is the best strategy? Just use a value that suits both worlds? (Fine-tuning such details at runtime depending on the platform might be a bit over the top?)

1
I'm no expert in this area, but AFAIK the optimizations mainly depend on the underlying chip. The iPhones are (a bit) more consistent in the GPU chips, but in android you can have several GPU chips: Adreno 2xx, PowerVR SGXxxx, Malixxx, Tegra2. There are differences in functionalities as well. Also, just out of curiosity? Why do you use 1.1 and not 2.0? I think with programable shaders you can optimize the code better (and of course your application will suport less devices ... but AFAIK nowadays every android device supoorts 2.0)Pal Szasz
As for using OpenGL ES1.1: It's a matter of supporting some older devices. Good point about the chipsets!MeinHeinlein

1 Answers

1
votes

The major (orthodox) optimizations are mentioned in the answer. However, there some other less known techniques that are applicable to rendering on mobile devices:

  1. The clock rate and memory bandwidth of mobile GPUs are significantly lower compared to desktop monsters. It would be wise to reduce overdraw and textures access as much as possible. Consider using CPU-level hidden surface removal algorithms and techniques.

  2. Use vendor-specific profilers to fine tune your code for specific chips. Use different code paths if the performance varies significantly from vendor to vendor.

  3. Once again, fillrate on mobile devices is of the essence. Use smaller data types, fewer texture fetches. This is especially true for Apple's retina display on the new iPad. Prefer calculations over texture lookups for reasonable formulas (you should profile).