gpt4 book ai didi

c++ - PBO 在集成 GPU 中无法正常工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:19:39 25 4
gpt4 key购买 nike

为了进行基准测试,让我们采用这个著名的 PBO Read-back code .

问题:

  1. 在我的 PC 上使用 PBO 无效。即使使用最新的驱动程序更新并更正像素格式 BGRA。

更新 1:我也用 3 个 PBO 尝试过同样的例子。但即使那样也没有区别。

注意:Intel(R) Core(TM) i5-3470S CPU @ 2.90GHz,2901 Mhz,4 核,显卡: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 和 Intel i-7 系列中正常工作。

电脑配置:Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz, 3400 Mhz, 4 Core(s), 8 Logical Processor(s),Video Card: 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)

最佳答案

link :

Mapping PBO ...

Note that if GPU is still working with the buffer object, glMapBufferARB() will not return until GPU finishes its job with the corresponding buffer object. To avoid this stall(wait), call glBufferDataARB() with NULL pointer right before glMapBufferARB(). Then, OpenGL will discard the old buffer, and allocate new memory space for the buffer object.

您可能需要将上述建议的更改应用到以下代码:

// "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);

关于c++ - PBO 在集成 GPU 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28338390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com