From c212bd0fec532d1aedb676cfc694cc5b84093714 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Aug 2022 21:18:48 -0700 Subject: [PATCH] GPU: Clarify new framebuf stencil upload. Actually, this doesn't need alpha either. --- GPU/Common/FramebufferManagerCommon.cpp | 3 ++- GPU/Common/StencilCommon.cpp | 6 +++--- GPU/GPUInterface.h | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 070f6f02db..0a5675c298 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -471,7 +471,8 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame if (useBufferedRendering_ && !g_Config.bDisableSlowFramebufEffects) { gpu->PerformMemoryUpload(params.fb_address, byteSize); - PerformStencilUpload(params.fb_address, byteSize, StencilUpload::STENCIL_IS_ZERO); + // Alpha was already done by PerformMemoryUpload. + PerformStencilUpload(params.fb_address, byteSize, StencilUpload::STENCIL_IS_ZERO | StencilUpload::IGNORE_ALPHA); // TODO: Is it worth trying to upload the depth buffer (only if it wasn't copied above..?) } diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index cc218a44ca..489c0f6560 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -176,14 +176,14 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU } if (usedBits == 0) { - if (flags == StencilUpload::STENCIL_IS_ZERO) { + if (flags & StencilUpload::STENCIL_IS_ZERO) { // Common when creating buffers, it's already 0. // We're done. return false; } // Otherwise, we can skip alpha in many cases, in which case we don't even use a shader. - if (flags == StencilUpload::IGNORE_ALPHA) { + if (flags & StencilUpload::IGNORE_ALPHA) { shaderManager_->DirtyLastShader(); if (dstBuffer->fbo) { @@ -267,7 +267,7 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU useBlit = false; } // The blit path doesn't set alpha, so we can't use it if that's needed. - if (flags != StencilUpload::IGNORE_ALPHA) { + if (!(flags & StencilUpload::IGNORE_ALPHA)) { useBlit = false; } diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 34977eba8e..1d2c74021a 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -21,6 +21,7 @@ #include #include +#include "Common/Common.h" #include "Common/Swap.h" #include "GPU/GPU.h" #include "Core/MemMap.h" @@ -107,10 +108,11 @@ enum GPUSyncType { }; enum class StencilUpload { - NEEDS_CLEAR, - STENCIL_IS_ZERO, - IGNORE_ALPHA, + NEEDS_CLEAR = 1, + STENCIL_IS_ZERO = 2, + IGNORE_ALPHA = 4, }; +ENUM_CLASS_BITOPS(StencilUpload); // Used for debug struct FramebufferInfo {