PDA

View Full Version : PBO readback: different color format ATI vs NVIDIA



Valkyr
03-18-2008, 08:36 AM
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

Relic
03-18-2008, 10:04 AM
If you say above ATI is returning identical data in GL_RGBA and GL_BGRA format, that would be a bug inside their glReadPixels code.

Valkyr
03-19-2008, 01:40 AM
Yes it seems to be a bug indeed.
We will try a different ati card on xp in stead of vista today and see what happens...

Valkyr
03-19-2008, 07:19 AM
The other machine has the same problem. It really seems to be a driver issue.