From 1121a6fb6896dc2929fcdccd337ee38732c42373 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 2 Dec 2022 10:20:30 -0800 Subject: [PATCH] softgpu: Handle inf-end + negative constant slope. --- GPU/Software/TransformUnit.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 9f82d85116..1369dcdf25 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -304,9 +304,13 @@ void ComputeTransformState(TransformState *state, const VertexReader &vreader) { // The PSP treats these exponents as if they were valid. if (my_isnanorinf(fogEnd)) { bool sign = std::signbit(fogEnd); - // The multiply would reverse it. - if (my_isnanorinf(fogSlope) && std::signbit(fogSlope)) + // The multiply would reverse it if it wasn't infinity (doesn't matter if it's infnan.) + if (std::signbit(fogSlope)) sign = !sign; + // Also allow a multiply by zero (slope) to result in zero, regardless of sign. + // Act like it was negative and clamped to zero. + if (fogSlope == 0.0f) + sign = true; // Since this is constant for the entire draw, we don't even use infinity. float forced = sign ? 0.0f : 1.0f;