Add ultra dirty specific hack to work around mesa following GL spec

* The GL spec is absolutely and maliciously unhinged and the queried stencil
  value will be clamped to 0 if no stencil texture is currently bound. This of
  course will break in so many different places that will never get fixed, but
  this minimal change at least allows autotests to run on mesa.
This commit is contained in:
baldurk
2026-08-24 20:17:37 +01:00
parent 4de445d2f5
commit a87c93bf0b
+12
View File
@@ -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);