From 2006bdc6a35ad79ee54e40e697220ebba3455908 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 2 Sep 2013 21:28:50 -0700 Subject: [PATCH] Fix negative texel wrapping in softgpu. No longer crashes in Jeanne d'Arc, still looks awful. Also faster on x64 at least. --- GPU/Software/Rasterizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index d571ebb84c..c42d671b57 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -104,15 +104,15 @@ static inline void GetTexelCoordinates(int level, float s, float t, unsigned int if (s > 1.0) s = 1.0; if (s < 0) s = 0; } else { - // TODO: Does this work for negative coords? - s = fmod(s, 1.0f); + // Subtracting floor works for negative and positive to discard the non-fractional part. + s -= floor(s); } if (gstate.isTexCoordClampedT()) { if (t > 1.0) t = 1.0; if (t < 0.0) t = 0.0; } else { - // TODO: Does this work for negative coords? - t = fmod(t, 1.0f); + // Subtracting floor works for negative and positive to discard the non-fractional part. + t -= floor(t); } int width = 1 << (gstate.texsize[level] & 0xf);