View Full Version : Reading and testing a depth buffer

Jose Goruka
06-08-2009, 02:03 PM
Imagine i have a FBO with a depth buffer texture bound. is it possible to write geometry to it using glDepthMask disabled (so no z-writes) while reading from the same depth buffer texture bound? as in.. using it for reading value and testing at the same time. The FBO extension docs don't really mention this as being forbidden, just say that if you create a feedback loop (which won't happen in this case), the results are undefined..

yet, i wonder if this is legal to do..

06-08-2009, 03:07 PM
If it's not specified it's an "implementation" thing. If not spelled out explicitly in a vendor document, it's likely an "undefined" thing.

Next generation hardware will have support for generic read/write access to a limited set of specialized buffers, though official word on the form this will take in GL hasn't reached us yet (that I know of).

06-08-2009, 03:08 PM
I do that; it works. (at least on nVidia HW :-) )

It should be perfectly legal, since no writing to the texture happens. It is just one texture, bound as both, texture and depth buffer.

06-08-2009, 04:09 PM
I do see any problem doing that apart from concurrent accesses to the same ressource... but I have no clue of how hardware handle this. IMO you are just playing with fire at the moment. :) For portability reasons I would not venture to do it.