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

查看:13
本文介绍了在 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 scene rendering goes something like this:

  • 重复 35 次
    • glPushMatrix
    • glLoadIdentity
    • gl翻译
    • 重复 7 次
      • 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.

      VBO 呢?

      更新

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

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

      我没有运行仪器.

      更新 2

      在 iPhone 3G 上运行 OpenGL ES Instrument 后,我​​发现我的 Tiler Utilization 在 90-100% 范围内,而我的 Render Utilization 在 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

      纹理图集对该问题没有明显影响.使用范围仍如上文所述.

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

      更新 4

      将我的 Vertex 和 Normal 指针转换为 GL_SHORT 似乎提高了 FPS,但 Tiler Utilization 在很多时候仍处于 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.

      更新 5

      将我的纹理坐标转换为 GL_SHORT 产生了另一个性能提升.我现在一直获得> 30 FPS.瓷砖利用率仍然在 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?

      推荐答案

      在 tiler 利用率仍高于 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,接下来要做的就是找到一种方法来做您想做的事希望使用更少的属性或组件.例如,如果您可以在没有镜面高光的情况下生活,使用 DOT3 光照而不是 OpenGL ES 固定功能光照将用 2 条短裤代替法线的 3 条短裤(+ 1 条填充)以获得额外的纹理坐标.作为额外的奖励,您可以按像素点亮模型.

      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天全站免登陆