From af2fd7b038aa58c297b9176752d2b6f2758a0544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 25 Feb 2023 18:31:13 +0100 Subject: [PATCH] Move Vulkan clear detection logic into DrawEngine like the other backends. --- GPU/Vulkan/DrawEngineVulkan.cpp | 20 +++++++++++++++----- GPU/Vulkan/FramebufferManagerVulkan.cpp | 19 ------------------- GPU/Vulkan/FramebufferManagerVulkan.h | 4 ---- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index c4a3be72de..78f561376e 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -983,11 +983,21 @@ void DrawEngineVulkan::DoFlush() { } } else if (result.action == SW_CLEAR) { // Note: we won't get here if the clear is alpha but not color, or color but not alpha. - - // We let the framebuffer manager handle the clear. It can use renderpasses to optimize on tilers. - // If non-buffered though, it'll just do a plain clear. - framebufferManager_->NotifyClear(gstate.isClearModeColorMask(), gstate.isClearModeAlphaMask(), gstate.isClearModeDepthMask(), result.color, result.depth); - + bool clearColor = gstate.isClearModeColorMask(); + bool clearAlpha = gstate.isClearModeAlphaMask(); // and stencil + bool clearDepth = gstate.isClearModeDepthMask(); + int mask = 0; + // The Clear detection takes care of doing a regular draw instead if separate masking + // of color and alpha is needed, so we can just treat them as the same. + if (clearColor || clearAlpha) mask |= Draw::FBChannel::FB_COLOR_BIT; + if (clearDepth) mask |= Draw::FBChannel::FB_DEPTH_BIT; + if (clearAlpha) mask |= Draw::FBChannel::FB_STENCIL_BIT; + // Note that since the alpha channel and the stencil channel are shared on the PSP, + // when we clear alpha, we also clear stencil to the same value. + draw_->Clear(mask, result.color, result.depth, result.color >> 24); + if (clearColor || clearAlpha) { + framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); + } if (gstate_c.Use(GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate.FrameBufFormat() == GE_FORMAT_565)) { int scissorX1 = gstate.getScissorX1(); int scissorY1 = gstate.getScissorY1(); diff --git a/GPU/Vulkan/FramebufferManagerVulkan.cpp b/GPU/Vulkan/FramebufferManagerVulkan.cpp index d5d4bdae50..0cc7c5c9ac 100644 --- a/GPU/Vulkan/FramebufferManagerVulkan.cpp +++ b/GPU/Vulkan/FramebufferManagerVulkan.cpp @@ -26,22 +26,3 @@ FramebufferManagerVulkan::FramebufferManagerVulkan(Draw::DrawContext *draw) : FramebufferManagerCommon(draw) { presentation_->SetLanguage(GLSL_VULKAN); } - -void FramebufferManagerVulkan::NotifyClear(bool clearColor, bool clearAlpha, bool clearDepth, uint32_t color, float depth) { - int mask = 0; - // The Clear detection takes care of doing a regular draw instead if separate masking - // of color and alpha is needed, so we can just treat them as the same. - if (clearColor || clearAlpha) - mask |= Draw::FBChannel::FB_COLOR_BIT; - if (clearDepth) - mask |= Draw::FBChannel::FB_DEPTH_BIT; - if (clearAlpha) - mask |= Draw::FBChannel::FB_STENCIL_BIT; - - // Note that since the alpha channel and the stencil channel are shared on the PSP, - // when we clear alpha, we also clear stencil to the same value. - draw_->Clear(mask, color, depth, color >> 24); - if (clearColor || clearAlpha) { - SetColorUpdated(gstate_c.skipDrawReason); - } -} diff --git a/GPU/Vulkan/FramebufferManagerVulkan.h b/GPU/Vulkan/FramebufferManagerVulkan.h index c2e575f0b2..2abb6008ce 100644 --- a/GPU/Vulkan/FramebufferManagerVulkan.h +++ b/GPU/Vulkan/FramebufferManagerVulkan.h @@ -25,8 +25,4 @@ class FramebufferManagerVulkan : public FramebufferManagerCommon { public: explicit FramebufferManagerVulkan(Draw::DrawContext *draw); - - // If within a render pass, this will just issue a regular clear. If beginning a new render pass, - // do that. - void NotifyClear(bool clearColor, bool clearAlpha, bool clearDepth, uint32_t color, float depth); };