presentRenderbuffer : GL_RENDERBUFFER_OES takes long time

若如初见. 提交于 2019-12-07 17:55:47

问题


I added a profiler to my game and isolated this function. It, sometimes, cause FPS drop. This is my result:

Present buffer time: 22
Present buffer time: 1
Present buffer time: 9
Present buffer time: 1
Present buffer time: 20
Present buffer time: 6
Present buffer time: 4
Present buffer time: 4
Present buffer time: 22
Present buffer time: 4
Present buffer time: 8
Present buffer time: 4
Present buffer time: 4
Present buffer time: 15
Present buffer time: 1
Present buffer time: 1
Present buffer time: 1
Present buffer time: 11
Present buffer time: 1
Present buffer time: 6
Present buffer time: 1
Present buffer time: 1
Present buffer time: 25
Present buffer time: 6
Present buffer time: 7
Present buffer time: 1
Present buffer time: 10
Present buffer time: 7
Present buffer time: 3
Present buffer time: 1
Present buffer time: 12
Present buffer time: 9
Present buffer time: 6
Present buffer time: 9

Do you know why at every few frames this function takes more time?

This is my code:


    f64 time = -System::GetTime();      
    [m_context presentRenderbuffer:GL_RENDERBUFFER_OES];
    Log("Present buffer time: %d\n", u32((System::GetTime() + time) * 1000.));

回答1:


If you are not calling glFlush() explicitly, the driver is forced to do it when you present the buffer, because at the point of presentRenderbuffer call the rendering operations on the buffer may not be completed yet.

Try calling glFlush before presenting the buffer and measuring time of it separately.




回答2:


The render buffer presentations that actually go to the display may be being quantized to a 30 Hz or 60 Hz refresh rate. The fast renders may actually just be throwing away the previous render before the earlier one completes.



来源:https://stackoverflow.com/questions/5134488/presentrenderbuffer-gl-renderbuffer-oes-takes-long-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!