HELP low performance in PBO readback !!

Hi

i use a PBO approach to grab a bitmap from my 3d scene :stuck_out_tongue: . steps are the following :

glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo1);

glReadPixels(0, 0,bWIDTH,bHEIGHT,GL_BGRA, GL_UNSIGNED_BYTE, 0);

copymem(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,GL_READ_ONLY_ARB)^, buffer,BWidth * BHeigh * 4);

glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo2);

glReadPixels(0, 0,pWIDTH,pHEIGHT ,GL_BGRA, GL_UNSIGNED_BYTE, 0);

copymem(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB)^,bitmapbuf, bWidth * bHeigh * 4);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);

swap(pbo1,pbo2)

with methode i get 15~25 fps low than a direct :

glReadPixels(0, 0,pWIDTH,pHEIGHT ,GL_BGRA, GL_UNSIGNED_BYTE, bitmapbuf);

as i see in many forum the PBO should be more Faster than the glReadPixels one :eek:

my card is : nVidia Geforce 7600 GS
forceware version : 169.21
Bus PCI Express x16
CPU : P4 3.0Ghz

are there any bad implementation in my PBO code, how can i boost it ?

help please

Thanks in Advance :slight_smile:

The point of using a PBO to do transfers, is that it can happen asynchronously. However, from in the code you posted, you immediately call MapBuffer, which forces the graphics card to wait for the transfer to happen, thus negating much, if not all, of the effect of the async transfer.

You should do other things between the ReadPixel call and the MapBuffer call. For instance, you could start the ReadPixel using pbo2, THEN call MapBuffer/CopyMem with pbo1, and then swap the two pbo handles (you’ll have to skip the map/copy the first time around). Ie something like

glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo2);

glReadPixels(0, 0,bWIDTH,bHEIGHT,GL_BGRA, GL_UNSIGNED_BYTE, 0);

if (!firstFrame) {
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo1);
copymem(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB,GL_READ_ONLY_ARB)^, buffer, BWidth * BHeigh * 4);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
firstFrame = false;
}

swap(pbo1, pbo2);

If I remember correctly that is, been a while since I messed with PBO’s.