(finally) change software renderer to use 32-bit division

This commit is contained in:
Arisotura 2025-08-08 19:51:04 +02:00
parent 13a9825c9a
commit 111fc6a343
1 changed files with 6 additions and 15 deletions

View File

@ -99,18 +99,9 @@ private:
{
// along Y
if ((w0 & 0x1) && !(w1 & 0x1))
{
this->w0n = w0 - 1;
this->w0d = w0 + 1;
this->w1d = w1;
}
else
{
this->w0n = w0 & 0xFFFE;
this->w0d = w0 & 0xFFFE;
this->w1d = w1 & 0xFFFE;
}
this->w0n = w0 >> 1;
this->w0d = (w0 + ((w0 & ~w1) & 1)) >> 1;
this->w1d = w1 >> 1;
this->shift = 9;
}
@ -132,13 +123,13 @@ private:
this->x = x;
if (xdiff != 0 && !linear)
{
s64 num = ((s64)x * w0n) << shift;
s32 den = (x * w0d) + ((xdiff-x) * w1d);
u32 num = (x * w0n) << shift;
u32 den = (x * w0d) + ((xdiff-x) * w1d);
// this seems to be a proper division on hardware :/
// I haven't been able to find cases that produce imperfect output
if (den == 0) yfactor = 0;
else yfactor = (s32)(num / den);
else yfactor = num / den;
}
}