我正在使用 CADisplayLink 为 iOS 上一个非常简单的 OpenGL ES 动画触发“更新”事件。动画有大约 10 个带纹理的四边形。我试图以 60 FPS 的速度运行它,但我看到了一些故障。将此更改为 30 FPS 时,动画运行更流畅。在对此进行分析之后,我看到大部分时间都花在了 presentRenderBuffer 中。
这些是结果:
m_displayLink.frameInterval = 2;
[379406923.204] Update time 0.000358
[379406923.206] Render time 0.001402
[379406923.207] Present time 0.001136
[379406923.238] Update time 0.000370
[379406923.239] Render time 0.001393
[379406923.241] Present time 0.001148
[379406923.271] Update time 0.000368
[379406923.273] Render time 0.001377
[379406923.274] Present time 0.001226
[379406923.305] Update time 0.000380
[379406923.307] Render time 0.001390
[379406923.308] Present time 0.001183
[379406923.338] Update time 0.000375
[379406923.339] Render time 0.001376
[379406923.341] Present time 0.001178
[379406923.372] Update time 0.000981
[379406923.375] Render time 0.001418
[379406923.379] Present time 0.004452
从m_displayLink.frameInterval = 2
分析的结果中我可以看到总帧时间足以达到 60 FPS,但是当将m_displayLink.frameInterval
值更改1
为结果时是出乎意料的:
m_displayLink.frameInterval = 1;
[379407317.151] Update time 0.000204
[379407317.152] Render time 0.000827
[379407317.172] Present time 0.019173
[379407317.172] Update time 0.000231
[379407317.173] Render time 0.000856
[379407317.201] Present time 0.027540
[379407317.202] Update time 0.000204
[379407317.202] Render time 0.000834
[379407317.218] Present time 0.015187
[379407317.218] Update time 0.000192
[379407317.219] Render time 0.000803
[379407317.251] Present time 0.031392
[379407317.252] Update time 0.000215
[379407317.253] Render time 0.000858
[379407317.267] Present time 0.014433
[379407317.268] Update time 0.000196
[379407317.269] Render time 0.001248
[379407317.301] Present time 0.031312
正如您所看到的,使用时它会大几倍
m_displayLink.frameInterval = 1;
请注意,最后一个命令Render()
是glFinish()
您知道为什么会出现这种意外行为吗?是否有可能达到 60 FPS(从我的第一次分析开始,我有大约 500 FPS!)?