Skip to content

Commit

Permalink
don't render 3d again without a GX flush
Browse files Browse the repository at this point in the history
speedup in 30 FPS games
  • Loading branch information
RSDuck committed Jul 16, 2020
1 parent 674a169 commit c787a07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/GPU3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ u8 FogDensityTable[32];

u32 ClearAttr1, ClearAttr2;

bool RenderFrameIdentical;

u32 RenderDispCnt;
u8 RenderAlphaRef;

Expand Down Expand Up @@ -379,6 +381,8 @@ void Reset()
NumPolygons = 0;
NumOpaquePolygons = 0;

RenderFrameIdentical = false;

// TODO: confirm initial polyid/color/fog values
ClearAttr1 = 0x3F000000;
ClearAttr2 = 0x00007FFF;
Expand All @@ -395,6 +399,8 @@ void Reset()

void DoSavestate(Savestate* file)
{
RenderFrameIdentical = false;

file->Section("GP3D");

CmdFIFO.DoSavestate(file);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/GPU3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ typedef struct

} Polygon;

extern bool RenderFrameIdentical;

extern u32 RenderDispCnt;
extern u8 RenderAlphaRef;

Expand Down
14 changes: 11 additions & 3 deletions src/GPU3D_Soft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ void RenderFrame()
{
Platform::Semaphore_Post(Sema_RenderStart);
}
else
else if (!RenderFrameIdentical)
{
ClearBuffers();
RenderPolygons(false, &RenderPolygonRAM[0], RenderNumPolygons);
Expand All @@ -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;
Expand Down

0 comments on commit c787a07

Please sign in to comment.