如何优化 OpenGL ES 1.1 中大型模型的渲染?
我刚刚在 3D 应用程序中完成 VBO 的实现,发现渲染速度提高了大约 5-10 倍。过去以每秒 1-2 帧的速度渲染,现在以每秒 10-11 帧的速度渲染。
我的问题是,我可以做进一步的改进来提高渲染速度吗?三角带会有很大的不同吗?目前,面之间不共享顶点,每个面的顶点都是唯一的但重叠。
我的设备利用率为 100%,Tiler 利用率为 100%,渲染器利用率为 11%,资源字节为 114819072。这在 CAD 模型上渲染 912,120 个面。
有什么建议吗?
I just finished implementing VBO's in my 3D app and saw a roughly 5-10x speed increase in rendering. What used to render at 1-2 frames per second now renders at 10-11 frames per second.
My question is, are there any further improvements I can make to increase rendering speed? Will triangle strips make a big difference? Currently vertices are not being shared between faces, each faces vertices are unique but overlapping.
My Device Utilization is 100%, Tiler Utilization is 100%, Renderer Utilization is 11%, and resource bytes is 114819072. This is rendering 912,120 faces on a CAD model.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tiler 利用率为 100% 表示您的瓶颈在于发送到 GPU 的几何图形的大小。根据我的经验,无论你能做什么来缩小几何尺寸,都可以导致渲染时间几乎线性减少。这些调整步骤过去对我有用:
如果您还没有这样做,您可以考虑使用索引,这可能会通过消除一些冗余顶点来减少几何体。 iOS 设备中的 PowerVR GPU 也针对使用索引几何体进行了优化。
尝试为顶点信息使用较小的数据类型。我发现我可以使用 GLshort 而不是 GLfloat 来处理我的顶点和法线,而不会在渲染中损失太多精度。这将显着压缩您的几何图形,并显着提高渲染速度。
将相似颜色的顶点分类并以一组颜色将它们渲染为一组,而不是提供每个顶点的颜色信息。不需要发送所有颜色信息而获得的加速将大大超过所需的一些额外绘制调用的开销。通过将颜色分箱到一个较大的模型中,我发现渲染时间减少了约 18%。
您已经在使用 VBO,因此您已经利用了该优化。
任何时候都不要停止渲染管道。删除任何读取当前状态的内容,例如所有 glGet* 调用,因为它们确实会扰乱 PowerVR GPU 的流程。
您还可以做其他一些事情,这些事情会带来较小的性能改进,例如在 VBO 中使用交错顶点、法线、纹理数据,将数据与 4 字节边界对齐等,但上面的内容是我发现的对我自己的 OpenGL ES 1.1 应用程序的调整影响最大。
其中大部分要点都在“
A Tiler Utilization of 100% indicates that your bottleneck is in the size of the geometry being sent to the GPU. Whatever you can do to shrink the geometry size can lead to an almost linear reduction in rendering time, in my experience. These tuning steps have worked for me in the past:
If you're not already, you could look at using indexing, which might cut down on geometry by eliminating some redundant vertices. The PowerVR GPUs in the iOS devices are optimized for using indexed geometry, as well.
Try using a smaller data type for your vertex information. I found that I could use GLshort instead of GLfloat for my vertices and normals without losing much precision in the rendering. This will significantly compact your geometry and lead to a nice speed boost in rendering.
Bin similarly colored vertices and render them as one group at a set color, rather than supplying per-vertex color information. The overhead from the few extra draw calls this requires will be vastly outweighed by the speedup you get from not having to send all that color information. I saw a ~18% reduction in rendering time by binning the colors in one of my larger models.
You're already using VBOs, so you've taken advantage of that optimization.
Don't halt the rendering pipeline at any point. Cut out anything that reads the current state, like all glGet* calls, because they really mess with the flow of the PowerVR GPUs.
There are other things you can do that will lead to smaller performance improvements, like using interleaved vertex, normal, texture data in your VBOs, aligning your data to 4 byte boundaries, etc., but the ones above are what I've found to have the largest impact in the tuning of my own OpenGL ES 1.1 application.
Most of these points are covered well in the "Best Practices for Working with Vertex Data" section of Apple's OpenGL ES Programming Guide for iOS.