From 53d3f49f45fc6a6703ae4c6522bac2284b024ac8 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 16 Mar 2026 01:58:03 +0300 Subject: [PATCH] overlays/gl: Fix misbehaving clip regions --- .../Program/GLSLSnippets/OverlayRenderVS.glsl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/Program/GLSLSnippets/OverlayRenderVS.glsl b/rpcs3/Emu/RSX/Program/GLSLSnippets/OverlayRenderVS.glsl index c583627251..46768d68a2 100644 --- a/rpcs3/Emu/RSX/Program/GLSLSnippets/OverlayRenderVS.glsl +++ b/rpcs3/Emu/RSX/Program/GLSLSnippets/OverlayRenderVS.glsl @@ -66,13 +66,29 @@ vec4 ndc_to_window(const in vec4 coord) return fma(coord, viewport.xyxy, viewport.zwzw); } +vec4 make_aabb(const in vec4 coords) +{ + // AABB requires the intersections to be concave + // i.e X1 < X2 and Y1 < Y2 + vec4 result = coords; + if (coords.x > coords.z) + { + result.xz = coords.zx; + } + if (coords.y > coords.w) + { + result.yw = coords.wy; + } + return result; +} + void main() { config_t config = unpack_vertex_options(); tc0.xy = in_pos.zw; color = albedo; - clip_rect = ndc_to_window(clip_to_ndc(clip_bounds, config.flip_vertically)); + clip_rect = make_aabb(ndc_to_window(clip_to_ndc(clip_bounds, config.flip_vertically))); vec4 pos = vec4(clip_to_ndc(in_pos, config.flip_vertically).xy, 0.5, 1.);