Reading and testing a depth buffer

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…

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).

I do that; it works. (at least on nVidia HW :slight_smile: )

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

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. :slight_smile: For portability reasons I would not venture to do it.