为了进行基准测试,请使用此著名的PBO Read-back code

问题:

  • 使用PBO对我的PC没有任何作用。即使使用最新的驱动程序更新和正确的像素格式BGRA。

  • 更新1:我也用3个PBO尝试了相同的示例。但是即使那样也没有区别。

    注:英特尔®酷睿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系列中均正常工作。

    PC配置:
    英特尔®酷睿TM i7-3770 CPU @ 3.40GHz,3400 Mhz,4核,8逻辑处理器,视频卡:Geforce210。因此,事实证明这是集成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中:



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

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

    09-10 03:59