diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 00516a632..1c3d1fab1 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -1975,10 +1975,7 @@ bool GLReplay::RenderTextureInternal(TextureDisplay cfg, int flags) ubo->Channels.x = 1.0f; ubo->Channels.y = 0.0f; ubo->Channels.z = 0.0f; - // to prevent depth only format from having non-zero values in other channels, we have to - // prevent splatting (the shader will splat the red channel when only the red channel contains - // a value of 1). - ubo->Channels.w = dsTexMode == eGL_DEPTH_COMPONENT ? 1.0f : 0.0f; + ubo->Channels.w = 0.0f; } ubo->RangeMinimum = cfg.rangemin; diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 5020253da..f05b551e5 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -2320,7 +2320,7 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, else gl.glFramebufferTexture(eGL_FRAMEBUFFER, eGL_COLOR_ATTACHMENT0, tempTex, 0); - float col[] = {0.3f, 0.6f, 0.9f, 1.0f}; + float col[] = {0.0f, 0.0f, 0.0f, 1.0f}; gl.glClearBufferfv(eGL_COLOR, 0, col); // render to the temp texture to do the downcast @@ -2361,7 +2361,20 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, gl.glViewport(0, 0, width, height); + GLboolean color_mask[4]; + gl.glGetBooleanv(eGL_COLOR_WRITEMASK, color_mask); + + // for depth, ensure we only write to the red channel, don't write into 'stencil' in green + // with depth data + if(GetBaseFormat(intFormat) == eGL_DEPTH_COMPONENT || + GetBaseFormat(intFormat) == eGL_DEPTH_STENCIL) + { + gl.glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); + } + RenderTextureInternal(texDisplay, 0); + + gl.glColorMask(color_mask[0], color_mask[1], color_mask[2], color_mask[3]); } // do one more time for the stencil