OpenGL 4.2, How to Copy a color texture into a depth texture ?
To my surprise, most of the things I tried don't work. I know I could make some workarounds but it just baffles me that I can't do it.
So I'm using multisampled textures for color & depth in a framebuffer. I then want to resolve color AND depth textures. glBlitFramebuffer apparently only resolves color, depth is simply ignored, even when calling it with just the depth flag. (this is on a HD7850 with latest drivers, btw). So I resorted to using a sampler2DMS in a pixel shader and doing a full screen quad resolve manually. I then come across another issue, writing the resolved depth to gl_FragDepth is getting ignored... I disable depth test, enable depth write (through glDepthMask), reset glPolygonOffset to 0,0 and I still can't get a write there...
Further down the line I tried writing depth to color, this works as expected, however my pipeline still uses a GL_DEPTH_COMPONENT32 texture and for the sake of easing up my workload, the simplest thing to do would be to somehow copy from that color to my original depth buffer, to get the resolve I need. So I tried glCopyTexImage2D which is simply getting ignored. I assume it just doesn't want to convert GL_DEPTH_COMPONENT32 to GL_RED_32 or GL_RGBA32F (tried both). So like, I wonder if depth resolving has a driver issue or something.