Restore single-channel selection for depth/stencil display

* Use color mask to prevent depth from being splatted out across all
  channels and writing into where 'stencil' data should be.
This commit is contained in:
baldurk
2017-07-21 17:21:19 +01:00
parent 06502e12c4
commit 1c75ee886c
2 changed files with 15 additions and 5 deletions
+1 -4
View File
@@ -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;
+14 -1
View File
@@ -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