From e0365c1d10f2a2849fe54795b140a35c5a81ce69 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Thu, 28 May 2026 15:24:02 +0200 Subject: [PATCH] GS/GL: Discard stencil when not in use while using depth. Backport from DX12, clear the stencil when it's not used. --- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 1acd198cc1..c1fd689523 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -2963,6 +2963,12 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config) constexpr GLint clear_color = 1; glClearBufferiv(GL_STENCIL, 0, &clear_color); } + else if (draw_ds && !(config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::Stencil || + config.destination_alpha == GSHWDrawConfig::DestinationAlphaMode::StencilOne)) + { + const GLenum attachments[] = {GL_STENCIL_ATTACHMENT}; + glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, std::size(attachments), attachments); + } SendHWDraw(config, rt_feedbackloop_pass1 ? draw_rt_clone : nullptr, draw_rt, ds_feedbackloop_pass1 ? draw_ds_clone : nullptr, draw_ds, config.require_one_barrier, config.require_full_barrier);