为什么建议使用多个像素缓冲区对象。肯定是多余的?

Why is using multiple Pixel buffer Objects advised. Surely it is redundant?

This 当有人询问 OpenGL 中的视频流纹理时,通常会参考这篇文章。

它说:

To maximize the streaming transfer performance, you may use multiple pixel buffer objects. The diagram shows that 2 PBOs are used simultaneously; glTexSubImage2D() copies the pixel data from a PBO while the texture source is being written to the other PBO.

For nth frame, PBO 1 is used for glTexSubImage2D() and PBO 2 is used to get new texture source. For n+1th frame, 2 pixel buffers are switching the roles and continue to update the texture. Because of asynchronous DMA transfer, the update and copy processes can be performed simultaneously. CPU updates the texture source to a PBO while GPU copies texture from the other PBO.

他们提供了一个简单的基准程序,允许您在没有 PBO、使用单个 PBO 和使用两个 PBO 的纹理更新之间循环,如上所述。

启用一个 PBO 后,我发现性能略有提高。 但是第二个 PBO 没有真正的区别。

就在代码 glMapBuffer 的 PBO 之前,它调用 glBufferData 并将指针设置为 NULL。它这样做是为了避免同步停顿。

// map the buffer object into client's memory
// Note that glMapBufferARB() causes sync issue.
// If GPU is working with this buffer, glMapBufferARB() will wait(stall)
// for GPU to finish its job. To avoid waiting (stall), you can call
// first glBufferDataARB() with NULL pointer before glMapBufferARB().
// If you do that, the previous data in PBO will be discarded and
// glMapBufferARB() returns a new allocated pointer immediately
// even if GPU is still working with the previous data.

所以,这是我的问题... 这不是让第二个 PBO 完全没用了吗?只是浪费内存!?

使用两个 PBO,纹理数据存储了 3 次。纹理中1个,每个PBO中1个。

只有一个 PBO。数据有两个副本。如果 glMapBuffer 创建新缓冲区,暂时只有第三个,因为现有缓冲区目前正在 DMA 到纹理?

这些评论似乎表明 OpenGL 驱动程序内部能够创建第二个缓冲区 IF,并且仅在需要时才创建,以避免停止管道。正在使用的缓冲区正在被 DMA 处理,我对 map 的调用产生了一个新的缓冲区供我写入。

那篇文章的作者似乎在这方面比我自己更了解。我完全误解了这一点吗?

回答我自己的问题...但我不会接受它作为答案...(尚未)。

问题中链接的基准程序有很多问题。它使用即时模式。它使用过剩!

该程序大部分时间都在做我们对分析不感兴趣的事情。主要是通过 GLUT 渲染文本,并在纹理上写出漂亮的条纹。所以我删除了那些功能。

我将纹理结果提高到 8K,并添加了更多 PBO 模式

  • 无 PBO(产生 6fps)

  • 1 个公益组织。孤立以前的缓冲区。 (产生 12.2 fps)。

  • 2 个 PBO。 Orpha 先前的缓冲区。 (产生 12.2 fps)。

  • 1 个公益组织。不要孤立以前的 PBO(可能的停顿 - 由我自己添加。产生 12.4 fps)。

  • 2 个 PBO。不要孤立以前的 PBO(可能的停顿 - 由我自己添加。产生 12.4 fps)。

如果有人想检查我的代码,可以使用 here

我已经尝试过不同的纹理大小...和不同的 updatePixels 函数...尽管我尽了最大的努力,但我无法使双 PBO 实现比单 PBO 实现更好。

此外...不孤立以前的缓冲区,实际上会产生更好的性能。与文章所说的完全相反。

也许现代驱动程序/硬件不会遇到此设计试图修复的问题...

也许我的图形硬件/驱动程序有问题,没有利用双 PBO...

也许经常引用的文章是完全错误的?

谁知道呢。 . . . 我的测试硬件是 Intel(R) HD Graphics 5500 (Broadwell GT2)。