https://bugs.freedesktop.org/show_bug.cgi?id=34495
--- Comment #30 from Pierre-Eric Pelloux-Prayer pelloux@gmail.com 2011-07-01 10:28:11 PDT --- (In reply to comment #28)
Yes but you're reading exacly the same buffer for each entry
The FBO is read once, but it contains ctx->Select.BatchEntryCount entries (each entry is a square of size : _OffscreenSurfaceWidth * _OffscreenSurfaceHeight, the total FBO width is _OffscreenSurfaceWidth * BatchSize)
By the way the glReadBack could be changed from : _mesa_ReadPixels(0, 0, fboW, fboH, GL_DEPTH_COMPONENT, GL_FLOAT, buffer); to : _mesa_ReadPixels(0, 0, _OffscreenSurfaceWidth * ctx->Select.BatchEntryCount, fboH, GL_DEPTH_COMPONENT, GL_FLOAT, buffer);
In the loop, we're reading this value : float z = buffer[y * fboW + xOffset + x];
with xOffset being modified according to the current entry being read (ie point at the correct square) So I keep thinking this is correct :-)
This got me thinking, and I think I know why. I believe currently minZ and maxZ values returned will almost always be incorrect.
Yup, you're right...
[...] I think that in order to correctly do this we would have to have 2 fbos.
Hmm... this would further complicate the process but maybe that's the only solution. I have to think about it too :-)