Advice on speeding up OpenGL ES 1.1 on the iPhone

I'm working on an iPhone App that relies heavily on OpenGL. Right now it runs a bit slow on the iPhone 3G, but looks snappy on the new 32G iPod Touch. I assume this is hardware related. Anyway, I want to get the iPhone performance to resemble the iPod Touch performance. I believe I'm doing a lot of things sub-optimally in OpenGL and I'd like advice on what improvements will give me the most bang for the buck.

My scene rendering goes something like this:

  • Repeat 35 times
  • glPushMatrix
  • glLoadIdentity
  • glTranslate
  • Repeat 7 times
  • glBindTexture
  • glVertexPointer
  • glNormalPointer
  • glTexCoordPointer
  • glDrawArrays(GL_TRIANGLES, ...)
  • glPopMatrix
  • My Vertex, Normal and Texture Coords are already interleaved.

    So, what steps should I take to speed this up? What step would you try first?

    My first thought is to eliminate all those glBindTexture() calls by using a Texture Atlas.

    What about some more efficient matrix operations? I understand the gl*() versions aren't too efficient.

    What about VBOs?

    Update

    There are 8260 triangles. Texture sizes are 64x64 pngs. There are 58 different textures.

    I have not run instruments.

    Update 2

    After running the OpenGL ES Instrument on the iPhone 3G I found that my Tiler Utilization is in the 90-100% range, and my Render Utilization is in the 30% range.

    Update 3

    Texture Atlasing had no noticeable affect on the problem. Utilization ranges are still as noted above.

    Update 4

    Converting my Vertex and Normal pointers to GL_SHORT seemed to improve FPS, but the Tiler Utilization is still in the 90% range a lot of the time. I'm still using GL_FLOAT for my texture coordinates. I suppose I could knock those down to GL_SHORT and save four more bytes per vertex.

    Update 5

    Converting my texture coordinates to GL_SHORT yielded another performance increase. I'm now consistently getting >30 FPS. Tiler Utilization is still around 90%, but frequently drops down in the the 70-80% range. The Renderer Utilization is hovering around 50%. I suppose this might have something to do with scaling the texture coordinates from GL_TEXTURE Matrix Mode.

    I'm still seeking additional improvements. I'd like to get closer to 40 FPS, as that's what my iPod Touch gets and it's silky smooth there. If anyone is still paying attention, what other low-hanging fruit can I pick?


    With a tiler utilization still above 90%, you're likely still vertex throughput-bound. Your renderer utilization is higher because the GPU is rendering more frames. If your primary focus is improving performance on older devices, then the key is still to cut down on the amount of vertex data needed per triangle. There are two sides to this:

    Reducing the amount of data per vertex : Now that all of your vertex attributes are already GL_SHORT s, the next thing to pursue is finding a way to do what you want using fewer attributes or components. For example, if you can live without specular highlights, using DOT3 lighting instead of OpenGL ES fixed-function lighting would replace your 3 shorts (+ 1 short of padding) for normals with 2 shorts for an extra texture coordinate. As an additional bonus, you'd be able to light your models per-pixel.

    Reducing the number of vertices needed per triangle : When drawing with indexed triangles, you should make sure that your indices are sorted for maximum reuse. Running your geometry through Imagination Technologies' PVRTTriStrip tool would probably be your best bet here.


    If you only have 58 different 64x64 textures, a texture atlas seems like a good idea, since they'd all fit in a single 512x512 texture... if you don't rely on texture wrap modes, I'd certainly at least try this.

    What format are your textures in? You might try using a compressed PVRTC texture; I think that's less load on the Tiler, and I've been pleasantly surprised by the image quality even for 2-bit-per-pixel textures. (Good for natural images, not good if you're doing something that looks like an 8-bit video game)


    The first thing I would do is run Instruments profiling on the hardware device that is slow. It should show you pretty quickly where the bottlenecks are for your particular case.

    Update after instruments results:

    This question has a similar result in Instruments to you, perhaps the advice is also applicable in your case (basically reducing number vertex data)

    链接地址: http://www.djcxy.com/p/33892.html

    上一篇: 尝试在设备上绘制纹理三角形失败,但模拟器工作。 为什么?

    下一篇: 关于在iPhone上加速OpenGL ES 1.1的建议