diff --git a/renderdoc/driver/gl/gl_overlay.cpp b/renderdoc/driver/gl/gl_overlay.cpp index cf03c03a5..7f32ac6dd 100644 --- a/renderdoc/driver/gl/gl_overlay.cpp +++ b/renderdoc/driver/gl/gl_overlay.cpp @@ -2162,6 +2162,18 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, Debug eGL_CLAMP_TO_EDGE); drv.glFramebufferTextureLayer(eGL_FRAMEBUFFER, dsAttach, overridedepth, 0, 0); + + // this is a MEGA hack for mesa's behaviour - which is spec compliant. The problem is that + // the spec is absolutely stupid. When we called CopyTex2DMSToArray() above the + // framebuffer might have been incomplete since we hadn't bound this overridedepth here + // that we are setting up. This means that the effective stencil bits available in the FBO + // is 0, and mesa then clamps the query of the current stencil reference to 0. The render + // state push + pop inside CopyTex2DMSToArray then doesn't function correctly as it leaves + // the reference at 0 instead of whatever it should be - so we reset it here + GL.glStencilFuncSeparate(eGL_FRONT, rs.StencilFront.func, rs.StencilFront.ref, + rs.StencilFront.valuemask); + GL.glStencilFuncSeparate(eGL_BACK, rs.StencilBack.func, rs.StencilBack.ref, + rs.StencilBack.valuemask); } drv.glBindFramebuffer(eGL_DRAW_FRAMEBUFFER, curdrawfbo);