关于在iPhone上加速OpenGL ES 1.1的建议 [英] Advice on speeding up OpenGL ES 1.1 on the iPhone

查看:112
本文介绍了关于在iPhone上加速OpenGL ES 1.1的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款严重依赖OpenGL的iPhone应用程序。现在它在iPhone 3G上运行有点慢,但在新的32G iPod Touch上看起来很快。我认为这与硬件有关。无论如何,我想让iPhone的性能与iPod Touch的性能相似。我相信我在OpenGL中做了很多次优化的事情,我想知道哪些改进会给我带来最大的好处。

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场景渲染是这样的:

My scene rendering goes something like this:


  • 重复35次


    • glPushMatrix

    • glLoadIdentity

    • glTranslate

    • 重复7次


      • glBindTexture

      • glVertexPointer

      • glNormalPointer

      • glTexCoordPointer

      • glDrawArrays(GL_TRIANGLES,...)

      • Repeat 35 times
        • glPushMatrix
        • glLoadIdentity
        • glTranslate
        • Repeat 7 times
          • glBindTexture
          • glVertexPointer
          • glNormalPointer
          • glTexCoordPointer
          • glDrawArrays(GL_TRIANGLES, ...)

          我的顶点,法线和纹理坐标已经交错。

          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?

          我的第一个想法是通过使用纹理图集来消除所有那些glBindTexture()调用。

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

          一些更有效的矩阵运算怎么样?我理解gl *()版本效率不高。

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

          VBOs怎么样?

          更新

          Update

          有8260个三角形。
          纹理大小为64x64 png。有58种不同的纹理。

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

          我还没有运行工具。

          更新2

          Update 2

          在iPhone 3G上运行OpenGL ES仪器后,我发现我的Tiler利用率在90-100%范围内,而我的渲染利用率在30%范围内。

          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.

          更新3

          Update 3

          纹理图集对问题没有明显的影响。使用范围仍然如上所述。

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

          更新4

          Update 4

          将我的Vertex和Normal指针转换为GL_SHORT似乎可以提高FPS,但Tiler利用率在很多时候仍然在90%范围内。我仍在使用GL_FLOAT作为纹理坐标。我想我可以把它们打到GL_SHORT并为每个顶点节省四个字节。

          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

          Update 5

          将纹理坐标转换为GL_SHORT会产生另一个性能提升。我现在一直都超过30 FPS。 Tiler利用率仍然在90%左右,但经常在70-80%的范围内下降。渲染器利用率徘徊在50%左右。我想这可能与从GL_TEXTURE矩阵模式缩放纹理坐标有关。

          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.

          我仍在寻求其他改进。我想接近40 FPS,因为这是我的iPod Touch获得的,它在那里如丝般顺畅。如果有人还在关注,我还能选择哪些其他低调的水果?

          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?

          推荐答案

          平铺利用率仍高于90% ,你可能仍然是顶点吞吐量限制。渲染器利用率较高,因为GPU渲染的帧数较多。如果您的主要关注点是提高旧设备的性能,那么关键还在于减少每个三角形所需的顶点数据量。这有两个方面:

          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:

          减少每个顶点的数据量:现在所有的顶点属性都已经 GL_SHORT s,接下来要做的就是找到一种方法,使用更少的属性或组件来做你想做的事。例如,如果您可以在没有镜面高光的情况下生活,使用DOT3照明而不是OpenGL ES固定功能照明将替换您的3条短裤(+ 1短填充)用于具有2条短裤的法线,以获得额外的纹理坐标。作为额外的奖励,您可以逐像素地点亮模型。

          Reducing the amount of data per vertex: Now that all of your vertex attributes are already GL_SHORTs, 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.

          减少每个三角形所需的顶点数量:使用索引三角形绘制时,应确保对索引进行排序以便最大程度地重用。通过Imagination Technologies的PVRTTriStrip工具运行几何图形可能是您最好的选择。

          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.

          这篇关于关于在iPhone上加速OpenGL ES 1.1的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆