From 2217a34d3912d71a87e91cf90b04fb49cd329808 Mon Sep 17 00:00:00 2001 From: Jaklyy <102590697+Jaklyy@users.noreply.github.com> Date: Thu, 14 Dec 2023 23:00:12 -0500 Subject: [PATCH] misc improvements --- src/GPU3D.h | 19 ++++++++++++------- src/GPU3D_Soft.cpp | 30 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/GPU3D.h b/src/GPU3D.h index 57553782..2dfacdc0 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -341,15 +341,20 @@ public: // GPU 3D rasterization timings, for emulating the timeout static constexpr int ScanlinePairLength = 2130 * TimingFrac; - static constexpr int ScanlineTimeout = 1686 * TimingFrac; // 2126? 1686? - static constexpr int ScanlineBreak = 4 * TimingFrac; - static constexpr int ScanlineBreak2 = 40 * TimingFrac; - static constexpr int IncrementStrange = 1618 * TimingFrac; // 1882? 1442? 1618?? - static constexpr int FreeTiming = 440 * TimingFrac; + //static constexpr int ScanlineTimeout = 1686 * TimingFrac; // 2126? 1686? + //static constexpr int ScanlineBreak = 4 * TimingFrac; + //static constexpr int ScanlineBreak2 = 40 * TimingFrac; + static constexpr int ScanlineIncrement = 1618 * TimingFrac; // how much to increment per scanline pair + static constexpr int AbortIncrement = 12 * TimingFrac; // how much extra to increment after an aborted scanline (total 1630) + static constexpr int FreeTiming = 496 * TimingFrac; // every scanline has a free 496 pixels worth of timing for some reason. + static constexpr int InitialTiming = 48688 * TimingFrac; // add 1618*2 to get the timeout of the second scanline pair + static constexpr int Post50Max = 51116 * TimingFrac; // for some reason it doesn't care about how full it actually is, it just cares about if its the first 50 scanlines to speedrun rendering? // GPU 3D rasterization timings II, for counting each element with timing characteristics - static constexpr int PerPolyTiming = 12 * TimingFrac; // should be correct for *most* line polygons and polygons with vertical slopes - static constexpr int PerPixelTiming = 1 * TimingFrac; // does not apply to the first 4 pixels in a polygon (per scanline?) + static constexpr int FirstPolyScanline = 0 * TimingFrac; + static constexpr int PerPolyScanline = 12 * TimingFrac; // should be correct for *most* line polygons and polygons with vertical slopes + static constexpr int PerPixelTiming = 1 * TimingFrac; // 1 pixel = 1 pixel + static constexpr int NumFreePixels = 4; // First 4 pixels in a polygon scanline are free (for some reason) // static constexpr int RasterTimingCap = 51116 * TimingFrac; static constexpr int PerScanlineTiming = 1064 * TimingFrac; // approximate currently, used to calc RDLines. TEMPORARY UNTIL ACCURATE "FRAMEBUFFER" CAN BE IMPLEMENTED diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 7cb8002a..af23132d 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -993,7 +993,7 @@ bool SoftRenderer::RenderPolygonScanline(RendererPolygon* rp, s32 y, bool odd) CheckSlope(rp, y); - if (DoTimings(PerPolyTiming, odd)) + if (DoTimings(PerPolyScanline, odd)) { Step(rp); return true; @@ -1439,18 +1439,19 @@ bool SoftRenderer::RenderScanline(s32 y, int npolys, bool odd) RendererPolygon* rp = &PolygonList[i]; Polygon* polygon = rp->PolyData; - if (abort) - { - CheckSlope(rp, y); - Step(rp); - } - else if (y == polygon->YBottom && y != polygon->YTop) + if (y == polygon->YBottom && y != polygon->YTop) { if (DoTimings(EmptyPolyScanline, odd)) abort = true; } else if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop))) { - if (polygon->IsShadowMask) + if (y == polygon->YTop) if(DoTimings(FirstPolyScanline, odd)) abort = true; + if (abort) + { + CheckSlope(rp, y); + Step(rp); + } + else if (polygon->IsShadowMask) ;//RenderShadowMaskScanline(rp, y); else if (RenderPolygonScanline(rp, y, odd)) abort = true; @@ -1768,17 +1769,18 @@ void SoftRenderer::RenderPolygons(bool threaded, Polygon** polygons, int npolys) RasterTimingOdd = 0; RasterTimingEven = 0; - if (buffersize > 48) + RasterTiming += ScanlineIncrement; + if (abort) RasterTiming += AbortIncrement; // if previous scanline was aborted, allow an extra 12 pixels worth of timing + + if (y >= 50) { - RasterTiming = ScanlinePairLength * 23; + if (RasterTiming > Post50Max) RasterTiming = Post50Max; timingadvance = 0; buffersize = 48; } - if (!abort) RasterTiming += IncrementStrange; - else RasterTiming += ScanlineTimeout; abort = RenderScanline(y, j, true); - abort = RenderScanline(y+1, j, false); + abort |= RenderScanline(y+1, j, false); buffersize += 2; //RasterTiming += ScanlineBreak; @@ -1795,6 +1797,8 @@ void SoftRenderer::RenderPolygons(bool threaded, Polygon** polygons, int npolys) timespent -= FreeTiming; }*/ //if (!abort) + //if (buffersize > 48) timespent -= PerScanlineRecup; + /*else*/ timespent -= FreeTiming; if (timespent > 0)