为了达到基准测试的目的,让我们使用这个著名的PBO读回码。
问题:
更新1:我也用3 PBO尝试过相同的例子,但即使这样也没有什么区别。
注: Intel(R) Core(TM) i5-3470S CPU @ 2.90GHz,2901 Mhz,4 Core(s),视频卡:Intel(R) HD Graphics 2500
PBO: off
Read Time: 9 ms
Process Time: 2 ms
Transfer Rate: 39.5 Mpixels/s. (45.0 FPS)
PBO: on
Read Time: 7 ms
Process Time: 2 ms
PBO: on Transfer Rate: 38.8 Mpixels/s. (44.2 FPS)更新2:PBO在外部GPU中正常工作&也在Inteli-7系列中工作。。
PC配置: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz,3400 Mhz,4 Core,8个逻辑处理器,视频卡: Geforce 210。因此,这就是集成GPU和外部GPU的问题。我相信这将是一个有用的提示,为许多人,谁想知道为什么他们的代码不工作!
PBO: on
PBO: on Read Time: 0.06 ms
Process Time: 2 ms
Transfer Rate: 112.4 Mpixels/s. (127.9 FPS)
PBO: off
Read Time: 4 ms
Process Time: 2 ms
Transfer Rate: 93.3 Mpixels/s. (106.1 FPS)发布于 2015-02-05 07:51:18
在链接中:
映射PBO ..。 注意,如果GPU仍然在使用缓冲区对象,glMapBufferARB()将在GPU使用相应的缓冲区对象完成其工作之前不会返回。为了避免这种停滞(等待),在glBufferDataARB()之前调用带有空指针的glMapBufferARB()。然后,OpenGL将丢弃旧缓冲区,并为缓冲区对象分配新的内存空间。
您可能需要将上面提议的更改应用于以下代码:
// "index" is used to read pixels from framebuffer to a PBO
// "nextIndex" is used to update pixels in the other PBO
index = (index + 1) % 2;
nextIndex = (index + 1) % 2;
// set the target framebuffer to read
glReadBuffer(GL_FRONT);
// read pixels from framebuffer to PBO
// glReadPixels() should return immediately.
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]);
glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0);
// map the PBO to process its data by CPU
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, 0, NULL, GL_STATIC_DRAW_ARB);
GLubyte* ptr = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,
GL_READ_ONLY_ARB);
if(ptr)
{
processPixels(ptr, ...);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
}
// back to conventional pixel operation
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);https://stackoverflow.com/questions/28338390
复制相似问题