From 72ffe6b29716060880209e0c0295add2657cb9a9 Mon Sep 17 00:00:00 2001 From: Jaklyy <102590697+Jaklyy@users.noreply.github.com> Date: Sat, 27 Apr 2024 12:37:48 -0400 Subject: [PATCH] fix bugs with negative viewports it it renders out of bounds pixels........... --- src/GPU3D_Soft.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index e6e3a4e2..086bb885 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -957,7 +957,6 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* if (x < 0) x = 0; s32 xlimit; - if (xend > 256) xend = 256; if (accuracy) { @@ -973,6 +972,13 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* else abortscanline = false; } // note: if accuracy mode isn't enabled the abort flag never gets set, this is fine, because it also never gets used by fast mode. + + // we cap it to 256 *after* counting the cycles, because yes, it tries to render oob pixels. + if (xend > 256) + { + r_edgelen += 256 - xend; + xend = 256; + } // for shadow masks: set stencil bits where the depth test fails. // draw nothing. @@ -1213,7 +1219,6 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3 s32 xlimit; s32 xcov = 0; - if (xend > 256) xend = 256; if (accuracy) { @@ -1228,6 +1233,13 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3 else abortscanline = false; } // note: if accuracy mode isn't enabled the abort flag never gets set, this is fine, because it also never gets used by fast mode. + + // we cap it to 256 *after* counting the cycles, because yes, it tries to render oob pixels. + if (xend > 256) + { + r_edgelen += 256 - xend; + xend = 256; + } // part 1: left edge edge = yedge | 0x1;