Copy depth buffer to R32F texture ??

QUESTION: Does OpenGL provide any built-in way to copy a depth buffer to an R32F texture, without reading back to the CPU and pushing back to the GPU (glReadPixels/glTexSubImage2D)? What about a 32F depth buffer (same format)?

BACKGROUND: Figured that would be faster than writing a redundant R32F color channel alongside depth (especially with double-speed Z only).

I did consider glCopyTexSubImage2D, but it apparently doesn’t allow copying depth to “color” (even when it’s the same component format: 32F). Only color-to-color and depth-to-depth. It apparently uses the target texture’s internal format to determine the “source” framebuffer attachment to copy from…

(This in reference to this thread, where I “really” just want to “typecast” an 32F depth texture/renderbuffer to an 32F color texture/renderbuffer.

You can use the depth values of the 32F depth-texture in a shader, so maybe you don’t need any typecasting? Or if you explicitly need to read from a copy, you can blit/copytexsubimage to another depth texture, and use that from within the shader.

Edit: just read the link, you may need to draw a fullscreen triangle, that reads from the depth-tex and outputs to R32F. Might even cram the first pass of your depthbuf reduction there, as glsl.

Thanks. First part is what I’m coding now. However, good point about the first stage reduce. Be interesting to see if that’s faster. The whole OpenCL reduce is only 0.26 ms on a 1024x1024 R32F texture (GTX480).

I think not.
There is this but I think it isn’t what you want.

Thanks for the pointer, V-man. Didn’t know about that one.

I didn’t mention NV_copy_depth_to_color, as ARB_depth_buffer_float explicitly states that NV_copy_depth_to_color must fail when trying to convert from 32F depth (or maybe it’s only if you copy depth+stencil).