I am having an odd problem, occasionally my glReadPixels() from FBO returns garbage. Sometimes it’s just mangled pixels, sometimes it’s an old image (from rendering before). This happens rarely and seemingly at random. It’s very hard to track down the cause because of that. Also this doesn’t seem to happen on another machine running ATI drivers. I’m tempted to blame it on the driver.
I’m running nVidia 258.49 drivers. Also tried older version of the drivers 197.xx. Same results
My code is basically:
glBindFramebufferEXT(myBuffer);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
...Do My Rendering...
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glFinish(); //I initially didn't have this, but why not
unsigned char * pixelBuffer = new unsigned char[readWidth*height*3];
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) pixelBuffer);
glFinish(); //wait for read to finish
GLenum err = glGetError(); //no problems reported here!
Anyone experience anything similar? I’m out of ideas.
Thanks.
I believe I have found the problem - as far as being able to replicate it on demand.
The images come back as garbage whenever I establish or quit a connection to the machine running the OpenGL using RAdmin. RAdmin installs a “mirror driver” so it does interface to the display adapter in some way, and obviously one of the drivers (nVidia or RAdmin) messes something up.
So I connect via RAdmin, there’s a glitch in glReadPixels, then everything goes back to normal and things work. I disconnect (session expires) and there’s another glitch and everything works again. Accounting for the “random” behavior.
Pure luck that I caught it.
Thanks skynet for your suggestions.
Do you know of any actual (and recent) benchmark results for that?
I have tried recently a few ways of glReadPixels - with rgba vs rgb vs bgra vs bgr and saw virtually no difference in dl rate. That said my benchmark could be flawed, my gfx card special etc etc.
So … does special formating for performance reasons of readback of framebuffer still applies on modern gfx cards?