presentRenderbuffer: GL_RENDERBUFFER_OES需要很长时间

时间:2022-04-06 04:38:32

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

我在游戏中添加了一个分析器,并隔离了这个函数。它有时会导致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

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.));

2 个解决方案

#1


3  

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.

如果您没有显式地调用glFlush(),那么当您呈现缓冲区时,驱动程序将*执行它,因为在presentRenderbuffer调用的时候,缓冲区的呈现操作可能还没有完成。

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

在分别显示缓冲区和测量它的时间之前,尝试调用glFlush。

#2


0  

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.

实际显示的渲染缓冲区表示可能被量化为30赫兹或60赫兹的刷新率。快速的呈现实际上可能只是在之前的呈现完成之前丢弃之前的呈现。

#1


3  

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.

如果您没有显式地调用glFlush(),那么当您呈现缓冲区时,驱动程序将*执行它,因为在presentRenderbuffer调用的时候,缓冲区的呈现操作可能还没有完成。

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

在分别显示缓冲区和测量它的时间之前,尝试调用glFlush。

#2


0  

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.

实际显示的渲染缓冲区表示可能被量化为30赫兹或60赫兹的刷新率。快速的呈现实际上可能只是在之前的呈现完成之前丢弃之前的呈现。