From 2f9392083a8a0826ca74b933cfbf2d18e8a9658f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 11 Oct 2022 22:26:31 -0700 Subject: [PATCH] GPU: Respect stencil state in shader blend. --- GPU/Common/FragmentShaderGenerator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 5b8b9ae070..c9bb2d0992 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -1160,7 +1160,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu // Note that the mask has already been flipped to the PC way - 1 means write. if (colorWriteMask) { - WRITE(p, " v32 = (v32 & u_colorWriteMask) | (d32 & ~u_colorWriteMask);\n"); + if (stencilToAlpha != REPLACE_ALPHA_NO) + WRITE(p, " v32 = (v32 & u_colorWriteMask) | (d32 & ~u_colorWriteMask);\n"); + else + WRITE(p, " v32 = (v32 & u_colorWriteMask & 0x00FFFFFFu) | (d32 & (~u_colorWriteMask | 0xFF000000u));\n"); } WRITE(p, " %s = unpackUnorm4x8(v32);\n", compat.fragColor0); }