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

时间:2015-02-05 07:27:07

标签: c++ opengl graphics pbo

为了进行基准测试,请使用这个着名的PBO Read-back code

问题:

  1. 使用PBO对我的电脑没有任何影响。即使有最新的驱动程序更新&正确的像素格式BGRA。
  2. 更新1:我也尝试了3个PBO的相同示例。但即便如此也没有区别。

    注意:Intel(R)Core(TM)i5-3470S CPU @ 2.90GHz,2901 Mhz,4 Core(s), 视频卡:英特尔(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&也适用于英特尔i-7系列。

    PC配置: Intel(R)Core(TM)i7-3770 CPU @ 3.40GHz,3400 Mhz,4 Core(s),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)
    

1 个答案:

答案 0 :(得分:1)

link

  

映射PBO ......

     

请注意,如果GPU仍在使用缓冲区对象,   glMapBufferARB()将不会返回,直到GPU完成其工作   相应的缓冲对象。为了避免这种失速(等待),请致电   在glMapBufferARB()之前使用NULL指针的glBufferDataARB()。   然后,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);