presentRenderbuffer:GL_RENDERBUFFER_OES需要很长时间

时间:2011-02-27 16:54:07

标签: iphone opengl-es

我在游戏中添加了一个分析器并隔离了这个功能。它有时会导致FPS下降。这是我的结果:

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

你知道为什么每隔几帧这个功能需要更多的时间吗?

这是我的代码:


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

2 个答案:

答案 0 :(得分:3)

如果没有显式调用glFlush(),则在呈现缓冲区时强制驱动程序执行此操作,因为在presentRenderbuffer调用时,缓冲区上的呈现操作可能尚未完成

在呈现缓冲区并分别测量它的时间之前,请尝试调用glFlush

答案 1 :(得分:0)

实际进入显示器的渲染缓冲器演示可以被量化为30Hz或60Hz刷新率。快速渲染实际上可能只是在前一个渲染完成之前丢弃了之前的渲染。