From b66ac09e431fccfb8d4cf5977245b3538d2382f4 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Mon, 22 May 2017 22:22:26 +0200 Subject: make the renderer truly per-scanline --- src/GPU3D_Soft.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index d16138b..f8c741b 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -1427,6 +1427,18 @@ void RenderPolygon(RendererPolygon* rp) } } +void RenderScanline(s32 y, int npolys) +{ + for (int i = 0; i < npolys; i++) + { + RendererPolygon* rp = &PolygonList[i]; + Polygon* polygon = rp->PolyData; + + if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop))) + RenderPolygonScanline(rp, y); + } +} + void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys) { u32 polyid = RenderClearAttr1 & 0x3F000000; @@ -1483,14 +1495,21 @@ void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys) } } + // TODO: Y-sorting of translucent polygons + + int j = 0; for (int i = 0; i < npolys; i++) { - SetupPolygon(&PolygonList[i], &polygons[i]); + if (polygons[i].Translucent) continue; + SetupPolygon(&PolygonList[j++], &polygons[i]); } - - // TODO: Y-sorting of translucent polygons - for (int i = 0; i < npolys; i++) + { + if (!polygons[i].Translucent) continue; + SetupPolygon(&PolygonList[j++], &polygons[i]); + } + + /*for (int i = 0; i < npolys; i++) { if (polygons[i].Translucent) continue; RenderPolygon(&PolygonList[i]); @@ -1500,6 +1519,10 @@ void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys) { if (!polygons[i].Translucent) continue; RenderPolygon(&PolygonList[i]); + }*/ + for (s32 y = 0; y < 192; y++) + { + RenderScanline(y, npolys); } } -- cgit v1.2.3