优化iPhone OpenGL ES填充率 [英] optimizing iPhone OpenGL ES fill rate

查看:131
本文介绍了优化iPhone OpenGL ES填充率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPhone上有一个Open GL ES游戏。我的帧率非常糟糕,大约20fps。在iPhone 3G上使用Xcode OpenGL ES性能工具,它显示:

I have an Open GL ES game on the iPhone. My framerate is pretty sucky, ~20fps. Using the Xcode OpenGL ES performance tool on an iPhone 3G, it shows:

渲染器利用率:95%至99%

Renderer Utilization: 95% to 99%

Tiler利用率:~27%

Tiler Utilization: ~27%

我正在绘制大量具有大量混合的非常大的图像。如果我减少绘制的图像数量,帧速率从大约20到大约40,尽管性能工具结果保持不变(渲染器仍然是最大值)。我认为我受限于iPhone 3G的填充率,但我不确定。

I am drawing a lot of pretty large images with a lot of blending. If I reduce the number of images drawn, framerates go from ~20 to ~40, though the performance tool results stay about the same (renderer still maxed). I think I'm being limited by the fill rate of the iPhone 3G, but I'm not sure.

我的问题是:如何更细致地确定哪里瓶颈是?这是我最大的问题,我只是不知道一直在做什么。如果它是填充物,除了画得少之外,还有什么可以改进的吗?

My questions are: How can I determine with more granularity where the bottleneck is? That is my biggest problem, I just don't know what is taking all the time. If it is fillrate, is there anything I do to improve it besides just drawing less?

我正在使用纹理地图集。我试图最小化图像绑定,虽然它并不总是可能的(绘制顺序,并非所有东西都适合一个1024x1024纹理等)。我做的每一帧10个图像绑定。这看起来很合理,但我可能会弄错。

I am using texture atlases. I have tried to minimize image binds, though it isn't always possible (drawing order, not everything fits on one 1024x1024 texture, etc). Every frame I do 10 image binds. This seem pretty reasonable, but I could be mistaken.

我正在使用顶点数组和glDrawArrays。我真的没有很多几何形状。如果需要,我可以尝试更精确。每个图像都是2个三角形,我尝试批量处理是可能的,尽管经常(可能有一半的时间)图像是用单独的glDrawArrays调用绘制的。除了图像,我还有大约60个三角形的三角形在~6个glDrawArrays调用中呈现。我经常在调用glDrawArrays之前进行glTranslate。

I'm using vertex arrays and glDrawArrays. I don't really have a lot of geometry. I can try to be more precise if needed. Each image is 2 triangles and I try to batch things were possible, though often (maybe half the time) images are drawn with individual glDrawArrays calls. Besides the images, I have ~60 triangles worth of geometry being rendered in ~6 glDrawArrays calls. I often glTranslate before calling glDrawArrays.

它会改善帧速率以切换到VBO吗?我不认为这是一个巨大的几何形状,但也许它因其他原因更快?

Would it improve the framerate to switch to VBOs? I don't think it is a huge amount of geometry, but maybe it is faster for other reasons?

是否有一些值得注意的事情会降低性能?例如,我应该避免使用glTranslate,glColor4g等吗?

Are there certain things to watch out for that could reduce performance? Eg, should I avoid glTranslate, glColor4g, etc?

我在每帧3个位置使用glScissor。每次使用都包含2个glScissor调用,一个用于设置,另一个用于将其重置为原来的状态。我不知道这里是否会产生很大的性能影响。

I'm using glScissor in a 3 places per frame. Each use consists of 2 glScissor calls, one to set it up, and one to reset it to what it was. I don't know if there is much of a performance impact here.

如果我使用PVRTC它能否更快地渲染?目前我所有的图像都是GL_RGBA。我没有内存问题。

If I used PVRTC would it be able to render faster? Currently all my images are GL_RGBA. I don't have memory issues.

我的全屏纹理之一是256x256。使用480x320会更好吗,这样手机不需要进行任何缩放吗?纹理尺寸是否还有其他一般性能建议?

One of my fullscreen textures is 256x256. Would it be better to use 480x320 so the phone doesn't have to do any scaling? Are there any other general performance advice for texture sizes?

以下是按照以下顺序对我正在绘制的内容进行粗略概述:

Here is a rough idea of what I'm drawing, in this order:

1)切换到透视矩阵。
2)绘制全屏背景图像
3)绘制半透明的全屏图像(此图像具有滚动纹理)。
4)画几个精灵。
5)切换到ortho矩阵。
6)画几个精灵。
7)切换到透视矩阵。
8)绘制精灵和其他一些纹理几何体。
9)切换到ortho矩阵。
10)画几个精灵(例如游戏HUD)。

1) Switch to perspective matrix. 2) Draw a full screen background image 3) Draw a full screen image with translucency (this one has a scrolling texture). 4) Draw a few sprites. 5) Switch to ortho matrix. 6) Draw a few sprites. 7) Switch to perspective matrix. 8) Draw sprites and some other textured geometry. 9) Switch to ortho matrix. 10) Draw a few sprites (eg, game HUD).

步骤1-6画出一堆背景资料。 8绘制了大部分游戏内容。 10绘制HUD。

Steps 1-6 draw a bunch of background stuff. 8 draws most of the game content. 10 draws the HUD.

如你所见,有很多层,其中一些全屏,一些精灵相当大(屏幕的1/4) )。这些图层使用半透明,所以我必须按照从前到后的顺序绘制它们。由于需要在正交和其他方面以透视方式绘制各种图层,因此更加复杂。

As you can see, there are many layers, some of them full screen and some of the sprites are pretty large (1/4 of the screen). The layers use translucency, so I have to draw them in back-to-front order. This is further complicated by needing to draw various layers in ortho and others in perspective.

如果需要,我很乐意提供其他信息。提前感谢您提供有关我的问题的任何表现提示或一般建议!

I will gladly provide additional information if reqested. Thanks in advance for any performance tips or general advice on my problem!

修改:

我添加了一些日志记录,看看我正在做多少glDrawArrays调用,以及有多少数据。我每帧做大约20次glDrawArray调用。通常,这些中的大约1到多达6个具有大约40个顶点。其余的调用通常只有2个顶点(一个图像)。我只是使用glVertexPointer和glTexCoordPointer。

I added some logging to see how many glDrawArrays calls I am doing, and with how much data. I do about 20 glDrawArray calls per frame. Usually about 1 to up to 6 of these has about 40 vertices each. The rest of the calls are usually just 2 vertices (one image). I'm just using glVertexPointer and glTexCoordPointer.

推荐答案

鉴于渲染器利用率基本上是100%,这表明瓶颈填充,纹理化和混合像素。旨在优化顶点处理(VBO和顶点格式)或CPU使用(绘制调用批处理)的技术可能无济于事,因为它们不会加速像素处理。

Given that the Renderer Utilization is basically at 100%, that indicates that the bottleneck is filling, texturing, and blending pixels. Techniques intended to optimize vertex processing (VBOs and vertex formats) or CPU usage (draw call batching) will likely not help, as they will not speed up pixel processing.

您的最好的办法是减少你填充的像素数量,同时还要考虑不同的纹理格式,以便更好地利用第一代设备上可用的非常有限的内存带宽。尽可能使用PVRTC纹理,否则优先使用16bit无压缩纹理。

Your best bet is to reduce the number of pixels that you are filling, and also look at different texture formats that make better use of the very limited memory bandwidth available on the first generation devices. Prefer the use of PVRTC textures wherever possible, and 16bit uncompressed textures otherwise.

这篇关于优化iPhone OpenGL ES填充率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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