diff options
Diffstat (limited to 'src/GPU3D_Soft.h')
-rw-r--r-- | src/GPU3D_Soft.h | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index d9a6028..9bbbb21 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -354,13 +354,19 @@ private: else if (ret > xmax) ret = xmax; return ret; } - + + template<bool swapped> void EdgeParams_XMajor(s32* length, s32* coverage) { - if (side ^ Negative) - *length = (dx >> 18) - ((dx-Increment) >> 18); - else - *length = ((dx+Increment) >> 18) - (dx >> 18); + // only do length calc for right side when swapped as it's + // only needed for aa calcs, as actual line spans are broken + if constexpr (!swapped || side) + { + if (side ^ Negative) + *length = (dx >> 18) - ((dx-Increment) >> 18); + else + *length = ((dx+Increment) >> 18) - (dx >> 18); + } // for X-major edges, we return the coverage // for the first pixel, and the increment for @@ -371,33 +377,49 @@ private: s32 startcov = (((startx << 10) + 0x1FF) * ylen) / xlen; *coverage = (1<<31) | ((startcov & 0x3FF) << 12) | (xcov_incr & 0x3FF); + + if constexpr (swapped) *length = 1; } + template<bool swapped> void EdgeParams_YMajor(s32* length, s32* coverage) { *length = 1; if (Increment == 0) { - *coverage = 31; + // for some reason vertical edges' aa values + // are inverted too when the edges are swapped + if constexpr (swapped) + *coverage = 0; + else + *coverage = 31; } else { s32 cov = ((dx >> 9) + (Increment >> 10)) >> 4; if ((cov >> 5) != (dx >> 18)) cov = 31; cov &= 0x1F; - if (!(side ^ Negative)) cov = 0x1F - cov; + if constexpr (swapped) + { + if (side ^ Negative) cov = 0x1F - cov; + } + else + { + if (!(side ^ Negative)) cov = 0x1F - cov; + } *coverage = cov; } } - + + template<bool swapped> void EdgeParams(s32* length, s32* coverage) { if (XMajor) - return EdgeParams_XMajor(length, coverage); + return EdgeParams_XMajor<swapped>(length, coverage); else - return EdgeParams_YMajor(length, coverage); + return EdgeParams_YMajor<swapped>(length, coverage); } s32 Increment; |