0

我在使用 expo 插件绘制桌面时检查了 Compiz 的性能。Compiz 和 nvidia-settings 中的 VSync 已启用。我这样测量时间:

paint()
{   
   //get time
   //all opengl commands
   glFlush();
   glFinish();
   //get time
   //calculate paint time

   //get time
   glXSwapBuffers (mDpy, mOutput);
   glFlush();
   glFinish();
   //get time
   //calculate sync/swap time
}

当绘制命令需要 8 毫秒时,同步/交换时间大约等于 7 毫秒,因为当 vsync 开启时,在 glXSwapBuffers 之后使用 glFinish 应该会阻塞。当我在 expo 模式下运行更多 opengl 窗口时,paint 命令需要 18 毫秒,同步/交换时间约为 13 毫秒。怎么解释?为什么 glXSwapBuffers 这么慢?

此外,当我在 nvidia-settings 和 Compiz 中关闭 vsync 并生成需要 28 毫秒的绘图命令时,同步/交换时间约为 14 毫秒。

4

1 回答 1

0

Well, you probably drive your display with 60Hz, so waiting for vblank can take up to 16.67ms.

The render time and the wait time at the swap buffers should always add up to a multiple of the frame time of 16.67 ms (assuming that drawing begins right after the previous buffer swap). Both 8+7=15 as well as 18+13=31 are close enough for that. When your drawing takes 18ms, you of course will miss one vblank interval and have to wait for the next.

What is going on in your "vsync off" case, I don't know. The swap buffer call itself should not take a significant amount of time in that case.

于 2015-04-21T20:52:09.043 回答