better implement when the line count reg is/isnt updated

This commit is contained in:
Jaklyy 2024-04-04 19:36:17 -04:00
parent e1cbadbe60
commit 75956b43c4
3 changed files with 31 additions and 11 deletions

View File

@ -240,9 +240,6 @@ void GPU3D::Reset() noexcept
DispCnt = 0; DispCnt = 0;
AlphaRefVal = 0; AlphaRefVal = 0;
AlphaRef = 0; AlphaRef = 0;
RDLines = 63; // defaults to 63 for one frame? (CHECKME: when does it reset?)
RDLinesTemp = 63;
memset(ToonTable, 0, sizeof(ToonTable)); memset(ToonTable, 0, sizeof(ToonTable));
memset(EdgeTable, 0, sizeof(EdgeTable)); memset(EdgeTable, 0, sizeof(EdgeTable));
@ -257,6 +254,8 @@ void GPU3D::Reset() noexcept
ResetRenderingState(); ResetRenderingState();
RDLines = 63;
AbortFrame = false; AbortFrame = false;
Timestamp = 0; Timestamp = 0;
@ -570,6 +569,7 @@ void GPU3D::SetEnabled(bool geometry, bool rendering) noexcept
RenderingEnabled = rendering; RenderingEnabled = rendering;
if (!rendering) ResetRenderingState(); 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 void GPU3D::VBlank() noexcept
{ {
RDLines = RDLinesTemp; if (RenderingEnabled)
RDLines = RDLinesTemp;
if (GeometryEnabled) if (GeometryEnabled)
{ {
if (RenderingEnabled) if (RenderingEnabled)
{ {
RDLines = RDLinesTemp;
if (FlushRequest) if (FlushRequest)
{ {
if (NumPolygons) if (NumPolygons)

View File

@ -246,9 +246,11 @@ public:
bool RenderingEnabled = false; bool RenderingEnabled = false;
u32 DispCnt = 0; u32 DispCnt = 0;
bool RDLinesUnderflow = false; bool RDLinesUnderflow = false;
u8 RDLines = 63; u8 RDLines = 0;
u8 RDLinesTemp = 46; u8 RDLinesTemp = 0;
u8 AlphaRefVal = 0; u8 AlphaRefVal = 0;
u8 AlphaRef = 0; u8 AlphaRef = 0;

View File

@ -1923,9 +1923,6 @@ void SoftRenderer::RenderPolygons(GPU& gpu, Polygon** polygons, int npolys)
SetupPolygon(&PolygonList[j++], polygons[i]); SetupPolygon(&PolygonList[j++], polygons[i]);
} }
//init internal buffer
ClearBuffers(gpu);
// reset scanline trackers // reset scanline trackers
gpu.GPU3D.RDLinesUnderflow = false; gpu.GPU3D.RDLinesUnderflow = false;
gpu.GPU3D.RDLinesTemp = 63; gpu.GPU3D.RDLinesTemp = 63;
@ -2022,7 +2019,16 @@ void SoftRenderer::RenderFrame(GPU& gpu)
// "Render thread, you're up! Get moving." // "Render thread, you're up! Get moving."
Platform::Semaphore_Post(Sema_RenderStart); 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) void SoftRenderer::RestartFrame(GPU& gpu)
@ -2050,7 +2056,16 @@ void SoftRenderer::RenderThreadFunc(GPU& gpu)
{ // If no rendering is needed, just say we're done. { // If no rendering is needed, just say we're done.
Platform::Semaphore_Post(Sema_ScanlineCount, 192); 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 // Tell the main thread that we're done rendering
// and that it's safe to access the GPU state again. // and that it's safe to access the GPU state again.