From 13bab780f26c197fa86763583ef0884339d86b14 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sun, 2 Aug 2026 04:55:05 -0400 Subject: [PATCH] [Fix] (DirectGLES): gate the replicate blit's stencil pass on ES 3.1 Reading the stencil half of a packed depth/stencil texture goes through GL_DEPTH_STENCIL_TEXTURE_MODE, which is ES 3.1 state. On an older driver the pname would raise GL_INVALID_ENUM and the shader would go on sampling depth bits as if they were stencil, so decline the emulation instead. --- MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp index fe35c6f4..f2aea66d 100644 --- a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp @@ -2597,8 +2597,13 @@ namespace MobileGL::MG_Backend::DirectGLES { if (!wantDepth && !wantStencil) { return false; } - // Reading the stencil back needs a stencil texture view, which is ES 3.1 state. - if (wantStencil && !g_GLESFuncs.glTexParameteri) { + // Sampling the stencil half of a packed texture goes through + // GL_DEPTH_STENCIL_TEXTURE_MODE, which is ES 3.1 state; on an older driver the pname + // would just raise GL_INVALID_ENUM and the shader would read depth bits as stencil. + const Bool supportsStencilTextureMode = g_GLESCapabilities.GLESVersion.Major > 3 || + (g_GLESCapabilities.GLESVersion.Major == 3 && + g_GLESCapabilities.GLESVersion.Minor >= 1); + if (wantStencil && !supportsStencilTextureMode) { return false; }