From 625595c6cce2a103fad8eb301a864fec25c959ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 8 Feb 2018 16:59:03 +0100 Subject: [PATCH] For some reason we use DrawActiveTexture in the GL stencil stuff, don't want to disable stencil unconditionally.. --- GPU/Common/FramebufferCommon.h | 1 + GPU/GLES/FramebufferManagerGLES.cpp | 8 +++++--- GPU/GLES/StencilBufferGLES.cpp | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index d88dced994..89db174c8e 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -150,6 +150,7 @@ enum DrawTextureFlags { DRAWTEX_NEAREST = 0, DRAWTEX_LINEAR = 1, DRAWTEX_KEEP_TEX = 2, + DRAWTEX_KEEP_STENCIL = 4, }; inline Draw::DataFormat GEFormatToThin3D(int geFormat) { diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 00f7da4195..e951ec2467 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -419,11 +419,13 @@ void FramebufferManagerGLES::DrawActiveTexture(float x, float y, float w, float pos[i * 3 + 1] = pos[i * 3 + 1] * invDestH - 1.0f; } - // We always want a plain state here. + // We always want a plain state here, well, except for when it's used by the stencil stuff... render_->SetNoBlendAndMask(0xF); render_->SetDepth(false, false, GL_ALWAYS); - render_->SetStencilDisabled(); - render_->SetRaster(false, GL_CCW, GL_FALSE, GL_FALSE); + render_->SetRaster(false, GL_CCW, GL_FRONT, GL_FALSE); + if (!(flags & DRAWTEX_KEEP_STENCIL)) { + render_->SetStencilDisabled(); + } // Upscaling postshaders don't look well with linear if (flags & DRAWTEX_LINEAR) { diff --git a/GPU/GLES/StencilBufferGLES.cpp b/GPU/GLES/StencilBufferGLES.cpp index d29e2bbf56..170fb997f4 100644 --- a/GPU/GLES/StencilBufferGLES.cpp +++ b/GPU/GLES/StencilBufferGLES.cpp @@ -170,6 +170,7 @@ bool FramebufferManagerGLES::NotifyStencilUpload(u32 addr, int size, bool skipZe render_->SetDepth(false, false, GL_ALWAYS); render_->Clear(0, 0, 0, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, 0x8, 0, 0, 0, 0); render_->SetStencilFunc(GL_TRUE, GL_ALWAYS, 0xFF, 0xFF); + render_->SetRaster(false, GL_CCW, GL_FRONT, GL_FALSE); render_->BindProgram(stencilUploadProgram_); render_->SetNoBlendAndMask(0x8); @@ -188,14 +189,14 @@ bool FramebufferManagerGLES::NotifyStencilUpload(u32 addr, int size, bool skipZe render_->SetStencilOp(i, GL_REPLACE, GL_REPLACE, GL_REPLACE); render_->SetUniformF1(&u_stencilValue, i * (1.0f / 255.0f)); } - DrawActiveTexture(0, 0, dstBuffer->width, dstBuffer->height, dstBuffer->bufferWidth, dstBuffer->bufferHeight, 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST); + DrawActiveTexture(0, 0, dstBuffer->width, dstBuffer->height, dstBuffer->bufferWidth, dstBuffer->bufferHeight, 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST | DRAWTEX_KEEP_STENCIL); } if (useBlit) { draw_->BlitFramebuffer(blitFBO, 0, 0, w, h, dstBuffer->fbo, 0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight, Draw::FB_STENCIL_BIT, Draw::FB_BLIT_NEAREST); } - gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE); + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE); RebindFramebuffer(); return true; }