iPhone OpenGL quicktip

If you want to see resource usage of your openGL code, Instruments is really handy for this with multiple different aspects of OpenGL ES performance and resource usage available for tracking.

Run your application in Instruments from Xcode by selecting Run -> Run With Performance Tool -> OpenGL ES

Note that this will not be available if the project Target is currently set to “Simulator”.  Just hook up your device and set the target to “Device” and you’ll now be able to select Run -> Run With Performance Tool -> OpenGL ES

Once in Instruments, note the “i” button icon at the right edge of the OpenGL ES instrument entry on the left “Instruments” column.  Select it and then select the “Configure…” button to configure even more options on what to track.

Some performance data:

Just as a test, I set my test app to allocate 4800 of the 32 x 32 pixel uncompressed GL_RGBA, GL_UNSIGNED_BYTE  textures.  Oh, and one big texture atlas that is 128 x 128 pixels, same depth etc.

This test is drawing 64,516 Point Sprites (point size is 16) using 8 different textures at 45 Core Animation Frames Per Second (CAFPS). Note that only 768 of them are visible on screen, the rest are offscreen and culled by OpenGL.  The points are x,y as GL_SHORTs in a single large vertex buffer and grouped by texture.  They are then drawn with eight glDrawArrays calls each frame (with the appropriate texture bound before each call) and GL_COORD_REPLACE_OES is true so the textures are drawing mapped over the points.

Actually, just for fun I made that selectable and without the VBO use the frame rate goes down to 40 CAFPS.  That’s good to know.

Showing 24-32MB Resource Bytes (Debug/Release, ?) and 69% Resource utilization.  Hugh, that doesn’t change even when I only allocate 8 of the 32×32 bit textures..  odd.

Anyway, ES 1.1, obviously.  iPhone OS 3.2 on Wi-Fi iPad.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: