fix a bunch of shit

This commit is contained in:
Jaklyy 2024-05-07 13:07:08 -04:00
parent 1f411c17d0
commit 4199c99cb6
3 changed files with 21 additions and 8 deletions

View file

@ -465,7 +465,7 @@ void GPU3D::DoSavestate(Savestate* file) noexcept
file->Bool32(&poly->FacingView);
file->Bool32(&poly->Translucent);
file->Bool3d(&poly->ClearStencil);
file->Bool32(&poly->ClearStencil);
file->Bool32(&poly->IsShadowMask);
file->Bool32(&poly->IsShadow);
@ -1233,13 +1233,13 @@ void GPU3D::SubmitPolygon() noexcept
poly->ClearStencil = false;
if (NDS.GetSCFGRasterBit() && (FlushAttributes & 1) && poly->Translucent)
{
if (poly->IsShadow) ShadowSent = true;
else if (poly->IsShadowMask && ShadowSent)
if (poly->IsShadowMask && ShadowSent)
{
ShadowSent = false;
poly->ClearStencil = true;
}
}
if (poly->IsShadow) ShadowSent = true;
if (!poly->Translucent) NumOpaquePolygons++;

View file

@ -125,6 +125,8 @@ void SoftRenderer::Reset(GPU& gpu)
ShadowRendered[0] = false;
ShadowRendered[1] = false;
ShadowRenderedi[0] = false;
ShadowRenderedi[1] = false;
SetupRenderThread(gpu);
EnableRenderThread();
}
@ -762,8 +764,9 @@ void SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon*
bool (*fnDepthTest)(s32 dstz, s32 z, u32 attr, u32 dstattr, u8 flags);
// stencil buffer is only cleared when beginning a shadow mask after a shadow polygon is rendered
// the state of whether a polygon was or wasn't rendered can persist between frames
// the Revised Rasterizer Circuit handles clearing the stencil buffer elsewhere
if (ShadowRendered[y&0x1] && !gpu3d.RenderRasterRev)
if (ShadowRendered[y&0x1] && (!gpu3d.RenderRasterRev || polygon->ClearStencil))
{
StencilCleared = true;
memset(&StencilBuffer[256 * (y&0x1)], 0, 256);
@ -959,7 +962,7 @@ void SoftRenderer::RenderPolygonScanline(GPU& gpu, RendererPolygon* rp, s32 y)
if (polygon->IsShadow)
{
ShadowRendered[y&0x1] = true;
if (!gpu.GPU3D.RenderRasterRev || !polygon->Translucent) ShadowRendered[y&0x1] = true;
if (wireframe) return; // TODO: this probably still counts towards timings.
if (!StencilCleared)
{
@ -1593,10 +1596,19 @@ void SoftRenderer::RenderScanline(GPU& gpu, s32 y, int npolys)
Polygon* polygon = rp->PolyData;
//we actually handle clearing the stencil buffer here when the revision bit is set, this allows for a polygon to clear it on every scanline, even ones it isn't part of.
if (gpu.GPU3D.RenderRasterRev && polygon->ClearStencil)
if (gpu.GPU3D.RenderRasterRev)
{
StencilCleared = true;
memset(&StencilBuffer[256 * (y&0x1)], 0, 256);
if (polygon->ClearStencil && polygon->Translucent && ShadowRenderedi[(y&0x1)])
{
StencilCleared = true;
memset(&StencilBuffer[256 * (y&0x1)], 0, 256);
ShadowRenderedi[(y&0x1)] = false;
}
else if (polygon->IsShadow && polygon->Translucent)
{
ShadowRenderedi[(y&0x1)] = true;
}
}
if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop)))

View file

@ -510,6 +510,7 @@ private:
u8 StencilBuffer[256*2];
bool ShadowRendered[2];
bool ShadowRenderedi[2];
bool StencilCleared;
bool Enabled;