Hi,
We have an application that reads back data from the backbuffer asynchronously by using PBOs.
Every odd frame we copy the backbuffer to the PBO using glReadpixels
glReadBuffer(GL_BACK);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, pixelBuffer);
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, 0);
Every even frame we analyse the data by mapping the PBO:
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, pixelBuffer);
pPixelBufferData = (BYTE*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_ONLY);
//analyze...
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
This works great on NVIDIA cards without a big performance hit.
It also works on ATI cards except the red and blue color components are flipped.
Using GL_RGBA in glReadpixels causes both cards to return the colors in the same order but causes nvidia performance to drop bigtime (because it has to flip the colors).
Asking the pixel format to the device context gives us the same values on nvidia and ati: resdhift is always 16 blueshift is always 0 and greenshift is always 8.
iPixelFormat = GetPixelFormat(hdc);
DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
Does anyone know whats going on here?
Thanks in advance