diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index 17f826fc..47f5fc52 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -240,9 +240,6 @@ void GPU3D::Reset() noexcept DispCnt = 0; AlphaRefVal = 0; AlphaRef = 0; - - RDLines = 63; // defaults to 63 for one frame? (CHECKME: when does it reset?) - RDLinesTemp = 63; memset(ToonTable, 0, sizeof(ToonTable)); memset(EdgeTable, 0, sizeof(EdgeTable)); @@ -257,6 +254,8 @@ void GPU3D::Reset() noexcept ResetRenderingState(); + RDLines = 63; + AbortFrame = false; Timestamp = 0; @@ -570,6 +569,7 @@ void GPU3D::SetEnabled(bool geometry, bool rendering) noexcept RenderingEnabled = rendering; if (!rendering) ResetRenderingState(); + else RDLinesTemp = 63; // resets to 63 when the rasterizer is toggled on } @@ -2431,11 +2431,14 @@ bool YSort(Polygon* a, Polygon* b) void GPU3D::VBlank() noexcept { - RDLines = RDLinesTemp; + if (RenderingEnabled) + RDLines = RDLinesTemp; + if (GeometryEnabled) { if (RenderingEnabled) { + RDLines = RDLinesTemp; if (FlushRequest) { if (NumPolygons) diff --git a/src/GPU3D.h b/src/GPU3D.h index eb671ed0..b1684ead 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -246,9 +246,11 @@ public: bool RenderingEnabled = false; u32 DispCnt = 0; + bool RDLinesUnderflow = false; - u8 RDLines = 63; - u8 RDLinesTemp = 46; + u8 RDLines = 0; + u8 RDLinesTemp = 0; + u8 AlphaRefVal = 0; u8 AlphaRef = 0; diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index bb801612..3d71db85 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -1923,9 +1923,6 @@ void SoftRenderer::RenderPolygons(GPU& gpu, Polygon** polygons, int npolys) SetupPolygon(&PolygonList[j++], polygons[i]); } - //init internal buffer - ClearBuffers(gpu); - // reset scanline trackers gpu.GPU3D.RDLinesUnderflow = false; gpu.GPU3D.RDLinesTemp = 63; @@ -2022,7 +2019,16 @@ void SoftRenderer::RenderFrame(GPU& gpu) // "Render thread, you're up! Get moving." Platform::Semaphore_Post(Sema_RenderStart); } - else if (!FrameIdentical) RenderPolygons(gpu, &gpu.GPU3D.RenderPolygonRAM[0], gpu.GPU3D.RenderNumPolygons); + else if (!FrameIdentical) + { + //init internal buffer + ClearBuffers(gpu); + + if (gpu.GPU3D.RenderNumPolygons > 0) + RenderPolygons(gpu, &gpu.GPU3D.RenderPolygonRAM[0], gpu.GPU3D.RenderNumPolygons); + else + memcpy(FinalBuffer, ColorBuffer, sizeof(FinalBuffer)); + } } void SoftRenderer::RestartFrame(GPU& gpu) @@ -2050,7 +2056,16 @@ void SoftRenderer::RenderThreadFunc(GPU& gpu) { // If no rendering is needed, just say we're done. Platform::Semaphore_Post(Sema_ScanlineCount, 192); } - else RenderPolygons(gpu, &gpu.GPU3D.RenderPolygonRAM[0], gpu.GPU3D.RenderNumPolygons); + else + { + //init internal buffer + ClearBuffers(gpu); + + if (gpu.GPU3D.RenderNumPolygons > 0) + RenderPolygons(gpu, &gpu.GPU3D.RenderPolygonRAM[0], gpu.GPU3D.RenderNumPolygons); + else + memcpy(FinalBuffer, ColorBuffer, sizeof(FinalBuffer)); + } // Tell the main thread that we're done rendering // and that it's safe to access the GPU state again.