GLES: Enable the clip planes the vertex shader actually writes

The vertex shader puts min/max Z in clip distances 0 and 1 and the near plane
in 2, but the program flags still followed an older layout and never enabled
plane 2. Geometry crossing the near plane was then only depth clamped, and
smeared across the screen (Hellboy, FIFA Soccer, Hoto no Ken frame dumps).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-08 16:16:24 +02:00
1 parent d74f16ef51
commit 709e6729ad
1 file changed
+8 -5
+8 -5
View File
@@ -186,12 +186,15 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs,
GLRProgramFlags flags{};
flags.supportDualSource = gstate_c.Use(GPU_USE_DUALSOURCE_BLEND);
if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Use(GPU_USE_DEPTH_CLAMP)) {
flags.useClipDistance0 = true;
if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_USE_CLIP_DISTANCE))
// Must match the planes GenerateVertexShader writes: min/max Z in 0 and 1, the near plane in 2.
if (gstate_c.Use(GPU_USE_CLIP_DISTANCE)) {
if (!VSID.Bit(VS_BIT_IS_THROUGH)) {
flags.useClipDistance0 = true;
flags.useClipDistance1 = true;
} else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_USE_CLIP_DISTANCE)) {
flags.useClipDistance0 = true;
}
if (VSID.Bit(VS_BIT_USE_HW_TRANSFORM)) {
flags.useClipDistance2 = true;
}
}
program = render->CreateProgram(shaders, semantics, queries, initialize, nullptr, flags);