Permalink
Browse files

SoftGPU: Avoid extra lookup of old stencil.

  • Loading branch information...
unknownbrackets committed Sep 10, 2018
1 parent ae73b8f commit 772ed302887903263a9f39c3226ef8f305270366
Showing with 5 additions and 6 deletions.
  1. +5 −6 GPU/Software/Rasterizer.cpp
@@ -484,9 +484,8 @@ static inline bool StencilTestPassed(u8 stencil)
return true;
}
static inline u8 ApplyStencilOp(int op, int x, int y)
{
u8 old_stencil = GetPixelStencil(x, y); // TODO: Apply mask?
static inline u8 ApplyStencilOp(int op, u8 old_stencil) {
// TODO: Apply mask to reference or old stencil?
u8 reference_stencil = gstate.getStencilTestRef(); // TODO: Apply mask?
switch (op) {
@@ -916,20 +915,20 @@ inline void DrawSinglePixel(const DrawingCoords &p, u16 z, u8 fog, const Vec4<in
// TODO: Is it safe to ignore gstate.isDepthTestEnabled() when clear mode is enabled? Probably yes
if (!clearMode && (gstate.isStencilTestEnabled() || gstate.isDepthTestEnabled())) {
if (gstate.isStencilTestEnabled() && !StencilTestPassed(stencil)) {
stencil = ApplyStencilOp(gstate.getStencilOpSFail(), p.x, p.y);
stencil = ApplyStencilOp(gstate.getStencilOpSFail(), stencil);
SetPixelStencil(p.x, p.y, stencil);
return;
}
// Also apply depth at the same time. If disabled, same as passing.
if (gstate.isDepthTestEnabled() && !DepthTestPassed(p.x, p.y, z)) {
if (gstate.isStencilTestEnabled()) {
stencil = ApplyStencilOp(gstate.getStencilOpZFail(), p.x, p.y);
stencil = ApplyStencilOp(gstate.getStencilOpZFail(), stencil);
SetPixelStencil(p.x, p.y, stencil);
}
return;
} else if (gstate.isStencilTestEnabled()) {
stencil = ApplyStencilOp(gstate.getStencilOpZPass(), p.x, p.y);
stencil = ApplyStencilOp(gstate.getStencilOpZPass(), stencil);
}
if (gstate.isDepthTestEnabled() && gstate.isDepthWriteEnabled()) {

0 comments on commit 772ed30

Please sign in to comment.