1

Can anyone tell me if there is a limit to the maximum number of OpenGL ES calls that can be made on iPad (i.e. OpenGL draw calls and state changes)?

I am working on a game and seeing low FPS, so I wonder if it has any thing to with my large number of OpenGL calls.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
kd3D
  • 63
  • 1
  • 1
  • 5

3 Answers3

2

There's no real maximum for OpenGL ES commands, but each one does have some overhead associated with it. Redundant state changes should be eliminated, and expensive state changes should be reduced by grouping geometry in ways that everything using one state is drawn, then the next. Apple has some recommendations for this in their OpenGL ES Programming Guide for iOS.

However, I've rarely found the OpenGL ES commands to be the cause of significant performance degradation in my applications. The larger problems tend to be due to the size of your geometry or from the complexity of any shaders or other effects you apply to your scene. I share some tips that I've applied for reducing geometry size here, and one tool for profiling shaders here, but I'm still learning the ins-and-outs of shader tuning myself.

If you do really care about fine-tuning the OpenGL calls you're making, the best profiling tool to use is the new OpenGL ES Analyzer instrument that comes with Xcode 4. I show a couple of example screens from that instrument in my answer here, where I used it to identify some redundant settings. It will find these calls for you, and point out where they are in your code. You can also use Time Profiler to see if you're putting more load on the CPU than you should be when rendering your frames, and track down the offending lines of code.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • I did tried to use analyser tool but when ever i do that the tool crashes – kd3D May 30 '11 at 12:33
  • time profiler helped now i have fps around 24 but i would like not increase it more – kd3D May 31 '11 at 10:12
  • @kd3D - I've never had this instrument crash on me before. Are you using the latest stable version of Xcode 4, while running iOS 4.0+ on your target device? iOS 4.0 is needed for this instrument to run. – Brad Larson May 31 '11 at 14:08
  • I`m using Xcode 4 and profiling it on ipad with ios-4.2.1 but whenever i run it then instrument run for 3 secs and then it crashes here`s a part of crash log that i get *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFArray objectForIntKey:]: unrecognized selector sent to instance 0x118d3fd90' *** Call stack at first throw: – kd3D Jun 01 '11 at 09:10
1

As far as I know, there is no such limit as maximum number of glCalls. But definitely, the more the number of gl calls, time taken would be more. Batched rendering is one of the main optimizations that has to be made with OpenGL.

Ramya Maithreyi
  • 507
  • 3
  • 12
  • I am passing batches but to draw only those objects that are in the bounding volume I am loading every object separately if in bounding volume – kd3D May 26 '11 at 11:52
  • You could load the objects in a different thread. You can refer to the posts present in this thread :: http://stackoverflow.com/questions/1253145/how-to-use-opengl-es-on-a-separate-thread-on-iphone – Ramya Maithreyi May 26 '11 at 12:07
1

Instead of suspecting the bottleneck, use Instruments to locate it.

Trace Template OpenGL ES Analysis is the weapon of choice. Last time I used it, you had to manually attach it to a running process on the device (all other startup options failed).

Till
  • 27,559
  • 13
  • 88
  • 122
  • can you shed some light on which instrument to use and how to locate the bottleneck – kd3D May 26 '11 at 11:50
  • it shows that this instrument does not allow to attach to any process and every time i start it directly game with instrument it crashes the instrument – kd3D May 27 '11 at 04:59