Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL on Android versus iOS: optimisations, and where they differ

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?)

like image 511
MeinHeinlein Avatar asked Dec 16 '11 10:12

MeinHeinlein


1 Answers

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).

like image 150
Sergey K. Avatar answered Nov 15 '22 19:11

Sergey K.