From 7d2898b94c165b3b3a37629e281091c12b8f37ae Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 9 Jan 2025 20:23:25 +1000 Subject: [PATCH] GPU/HW: Exclude 2D polygons from depth buffer Fixes UI getting obscured in Kingsley's Adventure. --- src/core/gpu_hw.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 401f522a0..c61948ab3 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -2798,13 +2798,14 @@ void GPU_HW::DrawPrecisePolygon(const GPUBackendDrawPrecisePolygonCommand* cmd) GSVector4i clamped_draw_rect_012, clamped_draw_rect_123; if (BeginPolygonDraw(cmd, vertices, num_vertices, clamped_draw_rect_012, clamped_draw_rect_123)) { - const bool use_depth = m_pgxp_depth_buffer && cmd->valid_w; + // Use PGXP to exclude primitives that are definitely 3D. + const bool is_3d = (vertices[0].w != vertices[1].w || vertices[0].w != vertices[2].w || + (num_vertices == 4 && vertices[0].w != vertices[3].w)); + const bool use_depth = m_pgxp_depth_buffer && is_3d; SetBatchDepthBuffer(cmd, use_depth); if (use_depth) CheckForDepthClear(cmd, vertices.data(), num_vertices); - // Use PGXP to exclude primitives that are definitely 3D. - const bool is_3d = (vertices[0].w != vertices[1].w || vertices[0].w != vertices[2].w); FinishPolygonDraw(cmd, vertices, num_vertices, true, is_3d, clamped_draw_rect_012, clamped_draw_rect_123); }