From c787a0759af94ecf1a344c259ce9f2081755f214 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Thu, 16 Jul 2020 02:26:54 +0200 Subject: [PATCH] don't render 3d again without a GX flush speedup in 30 FPS games --- src/GPU3D.cpp | 20 ++++++++++++++++++++ src/GPU3D.h | 2 ++ src/GPU3D_Soft.cpp | 14 +++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index 4120fe7e4d..1e484790f7 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -174,6 +174,8 @@ u8 FogDensityTable[32]; u32 ClearAttr1, ClearAttr2; +bool RenderFrameIdentical; + u32 RenderDispCnt; u8 RenderAlphaRef; @@ -379,6 +381,8 @@ void Reset() NumPolygons = 0; NumOpaquePolygons = 0; + RenderFrameIdentical = false; + // TODO: confirm initial polyid/color/fog values ClearAttr1 = 0x3F000000; ClearAttr2 = 0x00007FFF; @@ -395,6 +399,8 @@ void Reset() void DoSavestate(Savestate* file) { + RenderFrameIdentical = false; + file->Section("GP3D"); CmdFIFO.DoSavestate(file); @@ -2774,6 +2780,20 @@ void VBlank() } RenderNumPolygons = NumPolygons; + + RenderFrameIdentical = false; + } + else + { + RenderFrameIdentical = RenderDispCnt == DispCnt + && RenderAlphaRef == AlphaRef + && RenderClearAttr1 == ClearAttr1 + && RenderClearAttr2 == ClearAttr2 + && RenderFogColor == FogColor + && RenderFogOffset == FogOffset * 0x200 + && memcmp(RenderEdgeTable, EdgeTable, 8*2) == 0 + && memcmp(RenderFogDensityTable + 1, FogDensityTable, 32) == 0 + && memcmp(RenderToonTable, ToonTable, 32*2) == 0; } RenderDispCnt = DispCnt; diff --git a/src/GPU3D.h b/src/GPU3D.h index a7bc5c12b2..426a66353e 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -76,6 +76,8 @@ typedef struct } Polygon; +extern bool RenderFrameIdentical; + extern u32 RenderDispCnt; extern u8 RenderAlphaRef; diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 8397898da3..547a52c0e5 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -2084,7 +2084,7 @@ void RenderFrame() { Platform::Semaphore_Post(Sema_RenderStart); } - else + else if (!RenderFrameIdentical) { ClearBuffers(); RenderPolygons(false, &RenderPolygonRAM[0], RenderNumPolygons); @@ -2099,8 +2099,16 @@ void RenderThreadFunc() if (!RenderThreadRunning) return; RenderThreadRendering = true; - ClearBuffers(); - RenderPolygons(true, &RenderPolygonRAM[0], RenderNumPolygons); + if (!RenderFrameIdentical) + { + ClearBuffers(); + RenderPolygons(true, &RenderPolygonRAM[0], RenderNumPolygons); + } + else + { + for (int i = 0; i < 192; i++) + Platform::Semaphore_Post(Sema_ScanlineCount); + } Platform::Semaphore_Post(Sema_RenderDone); RenderThreadRendering = false;