From cd6b1f73c1a87c2e9b6e0f8c9ec810e061dba43c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 5 Aug 2018 17:15:44 -0700 Subject: [PATCH] SoftGPU: Drop verts only when depth not clamped. Depth clamping bypasses the 4096x4096 box check. --- GPU/Software/TransformUnit.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 911bdbf94f..7bd578a25f 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -106,14 +106,16 @@ static inline ScreenCoords ClipToScreenInternal(const ClipCoords& coords, bool * // This matches hardware tests - depth is clamped when this flag is on. if (gstate.isDepthClampEnabled()) { + // Note: if the depth is clamped, the outside_range_flag should NOT be set, even for x and y. if (z < 0.f) z = 0.f; - if (z > 65535.f) + else if (z > 65535.f) z = 65535.f; - } - - if (outside_range_flag && (x > 4095.9375f || y > 4095.9375f || x < 0 || y < 0 || z < 0 || z > 65535.f)) + else if (outside_range_flag && (x > 4095.9375f || y > 4095.9375f || x < 0 || y < 0)) + *outside_range_flag = true; + } else if (outside_range_flag && (x > 4095.9375f || y > 4095.9375f || x < 0 || y < 0 || z < 0 || z > 65535.f)) { *outside_range_flag = true; + } // 16 = 0xFFFF / 4095.9375 // Round up at 0.625 to the nearest subpixel.