From 8a2115be463cacedace4d63c07a5f35c73a0a123 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 11 Sep 2022 18:39:39 -0700 Subject: [PATCH] softgpu: Enable early Z tests a bit more often. This helps in cases where sfail doesn't matter. --- GPU/Software/FuncId.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GPU/Software/FuncId.cpp b/GPU/Software/FuncId.cpp index 0471114caa..f66064f0cf 100644 --- a/GPU/Software/FuncId.cpp +++ b/GPU/Software/FuncId.cpp @@ -93,13 +93,6 @@ void ComputePixelFuncID(PixelFuncID *id, bool throughMode) { if (gstate.FrameBufFormat() != GE_FORMAT_565 && gstate.getStencilOpZPass() <= GE_STENCILOP_DECR) id->zPass = gstate.getStencilOpZPass(); - // Always treat zPass/zFail the same if there's no depth test. - if (!gstate.isDepthTestEnabled() || gstate.getDepthTestFunction() == GE_COMP_ALWAYS) - id->zFail = id->zPass; - // And same for sFail if there's no stencil test. - if (id->StencilTestFunc() == GE_COMP_ALWAYS) - id->sFail = id->zPass; - // Normalize REPLACE 00 to ZERO, especially if using a mask. if (gstate.getStencilTestRef() == 0) { if (id->SFail() == GE_STENCILOP_REPLACE) @@ -120,6 +113,13 @@ void ComputePixelFuncID(PixelFuncID *id, bool throughMode) { id->zPass = GE_STENCILOP_ZERO; } + // Always treat zPass/zFail the same if there's no depth test. + if (!gstate.isDepthTestEnabled() || gstate.getDepthTestFunction() == GE_COMP_ALWAYS) + id->zFail = id->zPass; + // And same for sFail if there's no stencil test. Prefer KEEP, though. + if (id->StencilTestFunc() == GE_COMP_ALWAYS) + id->sFail = id->ZFail() == GE_STENCILOP_KEEP ? GE_STENCILOP_KEEP : id->zPass; + // Turn off stencil testing if it's doing nothing. if (id->SFail() == GE_STENCILOP_KEEP && id->ZFail() == GE_STENCILOP_KEEP && id->ZPass() == GE_STENCILOP_KEEP) { if (id->StencilTestFunc() == GE_COMP_ALWAYS)