From 467e8ef34ac3af2506b2b6ff58bc5ecd47946022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 1 Oct 2026 11:20:49 -0600 Subject: [PATCH] SoftGPU: Floor the exact pow product The GE's pow multiplies the exponent and the float's bits exactly and floors, instead of a rounded float multiply, which mattered for e = 1.1 (gpu/probe exp102). The hardware backends keep the float version. Co-Authored-By: Claude Opus 5.5 (1M context) --- GPU/Software/Lighting.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/GPU/Software/Lighting.cpp b/GPU/Software/Lighting.cpp index f479e680ec..25e7f561e3 100644 --- a/GPU/Software/Lighting.cpp +++ b/GPU/Software/Lighting.cpp @@ -51,7 +51,16 @@ static inline float pspLightPow(float v, float e) { return 1.0f; } if (v > 0.0f) { - return PSPLightPow(v, e); + // PSPLightPow, but the product is exact and floored rather than a rounded float multiply + // (gpu/probe exp102: e = 1.1). + int32_t ix; + memcpy(&ix, &v, sizeof(ix)); + double t = std::floor((double)e * (double)(ix - 0x3F800000)) + 1065353216.0; + t = t >= 0.0 ? (t < 2139095039.0 ? t : 2139095039.0) : 0.0; + int32_t iy = (int32_t)t; + float y; + memcpy(&y, &iy, sizeof(y)); + return y; } // Negative stays negative, so let's just return the original. return v;