From 6ed8f96e98e395d13dadc1e090d9c5a31242792e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 May 2024 20:36:51 +0200 Subject: [PATCH 1/3] Indentation fix --- GPU/Common/VertexDecoderHandwritten.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/VertexDecoderHandwritten.cpp b/GPU/Common/VertexDecoderHandwritten.cpp index 30be6d6f98..07de5fa90d 100644 --- a/GPU/Common/VertexDecoderHandwritten.cpp +++ b/GPU/Common/VertexDecoderHandwritten.cpp @@ -84,12 +84,12 @@ void VtxDec_Tu16_C8888_Pfloat(const u8 *srcp, u8 *dstp, int count, const UVScale float32x2_t finalUV = vadd_f32(vmul_f32(vcvt_f32_u32(fuv), uvScale), uvOff); u32 normal = src[i].packed_normal; uint32x4_t colpos = vld1q_u32((const u32 *)&src[i].col); - alphaMask = vandq_u32(alphaMask, colpos); + alphaMask = vandq_u32(alphaMask, colpos); vst1_f32(&dst[i].u, finalUV); dst[i].packed_normal = normal; vst1q_u32(&dst[i].col, colpos); } - alpha = vgetq_lane_u32(alphaMask, 0); + alpha = vgetq_lane_u32(alphaMask, 0); #else for (int i = 0; i < count; i++) { float u = src[i].u * uscale + uoff; From c38ce2a5bea0e6a4e0646710c192032a5052b5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 May 2024 21:28:26 +0200 Subject: [PATCH 2/3] Fix an issue when bringin up the dev menu with transparent background disabled --- Common/GPU/Vulkan/VulkanRenderManager.h | 4 ++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 7 ++++++ Common/GPU/thin3d.h | 9 +++++++ Common/UI/Screen.cpp | 6 ++++- Common/UI/Screen.h | 10 +++++++- UI/EmuScreen.cpp | 32 ++++++++++++++++++------- UI/EmuScreen.h | 2 +- 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 44031a54fa..ea452de49f 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -533,6 +533,10 @@ public: void StartThreads(); void StopThreads(); + size_t GetNumSteps() const { + return steps_.size(); + } + private: void EndCurRenderStep(); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 8061ba1cf7..6e3af3cf2b 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -380,6 +380,13 @@ public: VKContext(VulkanContext *vulkan, bool useRenderThread); ~VKContext(); + BackendState GetCurrentBackendState() const override { + return BackendState{ + (u32)renderManager_.GetNumSteps(), + true, + }; + } + void DebugAnnotate(const char *annotation) override; void Wait() override { vkDeviceWaitIdle(vulkan_->GetDevice()); diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 83101eeb1c..dc7ba23b24 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -687,6 +687,11 @@ enum class DebugFlags { }; ENUM_CLASS_BITOPS(DebugFlags); +struct BackendState { + u32 passes; + bool valid; +}; + class DrawContext { public: virtual ~DrawContext(); @@ -705,6 +710,10 @@ public: virtual std::vector GetPresentModeList(std::string_view currentMarkerString) const { return std::vector(); } virtual std::vector GetSurfaceFormatList() const { return std::vector(); } + virtual BackendState GetCurrentBackendState() const { + return BackendState{}; + } + // Describes the primary shader language that this implementation prefers. const ShaderLanguageDesc &GetShaderLanguageDesc() { return shaderLanguageDesc_; diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index 12c360d6f5..0ffb30b16d 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -187,7 +187,8 @@ ScreenRenderFlags ScreenManager::render() { bool first = true; do { --iter; - if (!foundBackgroundScreen && iter->screen->canBeBackground(first)) { + ScreenRenderRole role = iter->screen->renderRole(first); + if (!foundBackgroundScreen && (role & ScreenRenderRole::CAN_BE_BACKGROUND)) { // There still might be a screen that wants to be background - generally the EmuScreen if present. layers.push_back(iter->screen); foundBackgroundScreen = iter->screen; @@ -198,6 +199,9 @@ ScreenRenderFlags ScreenManager::render() { coveringScreen = iter->screen; } first = false; + if (role & ScreenRenderRole::MUST_BE_FIRST) { + break; + } } while (iter != stack_.begin()); if (backgroundScreen_ && !foundBackgroundScreen) { diff --git a/Common/UI/Screen.h b/Common/UI/Screen.h index de40bae684..8b015c925a 100644 --- a/Common/UI/Screen.h +++ b/Common/UI/Screen.h @@ -61,6 +61,14 @@ enum class ScreenRenderFlags { }; ENUM_CLASS_BITOPS(ScreenRenderFlags); + +enum class ScreenRenderRole { + NONE = 0, + CAN_BE_BACKGROUND = 1, + MUST_BE_FIRST = 2, +}; +ENUM_CLASS_BITOPS(ScreenRenderRole); + class Screen { public: Screen() : screenManager_(nullptr) { } @@ -74,7 +82,7 @@ public: virtual void sendMessage(UIMessage message, const char *value) {} virtual void deviceLost() {} virtual void deviceRestored() {} - virtual bool canBeBackground(bool isTop) const { return false; } + virtual ScreenRenderRole renderRole(bool isTop) const { return ScreenRenderRole::NONE; } virtual bool wantBrightBackground() const { return false; } // special hack for DisplayLayoutScreen. virtual void focusChanged(ScreenFocusChange focusChange); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 0f79c36663..da7d4f278f 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1279,17 +1279,25 @@ bool EmuScreen::checkPowerDown() { return false; } -bool EmuScreen::canBeBackground(bool isTop) const { - if (g_Config.bSkipBufferEffects) { - return isTop || (g_Config.bTransparentBackground && Core_ShouldRunBehind()); - } +ScreenRenderRole EmuScreen::renderRole(bool isTop) const { + auto CanBeBackground = [&]() -> bool { + if (g_Config.bSkipBufferEffects) { + return isTop || (g_Config.bTransparentBackground && Core_ShouldRunBehind()); + } - if (!g_Config.bTransparentBackground && !isTop) { - if (Core_ShouldRunBehind() || screenManager()->topScreen()->wantBrightBackground()) - return true; - return false; + if (!g_Config.bTransparentBackground && !isTop) { + if (Core_ShouldRunBehind() || screenManager()->topScreen()->wantBrightBackground()) + return true; + return false; + } + return true; + }; + + ScreenRenderRole role = ScreenRenderRole::MUST_BE_FIRST; + if (CanBeBackground()) { + role |= ScreenRenderRole::CAN_BE_BACKGROUND; } - return true; + return role; } void EmuScreen::darken() { @@ -1313,6 +1321,12 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { return flags; // shouldn't really happen but I've seen a suspicious stack trace.. } + // Sanity check +#ifdef _DEBUG + Draw::BackendState state = draw->GetCurrentBackendState(); + _dbg_assert_(!state.valid || state.passes == 0); +#endif + GamepadUpdateOpacity(); bool skipBufferEffects = g_Config.bSkipBufferEffects; diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 50157a6002..77df9e3816 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -46,7 +46,7 @@ public: void dialogFinished(const Screen *dialog, DialogResult result) override; void sendMessage(UIMessage message, const char *value) override; void resized() override; - bool canBeBackground(bool isTop) const override; + ScreenRenderRole renderRole(bool isTop) const override; // Note: Unlike your average boring UIScreen, here we override the Unsync* functions // to get minimal latency and full control. We forward to UIScreen when needed. From 336732afa8c69ee8e91f1279985579c7506d7d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 12 May 2024 00:07:51 +0200 Subject: [PATCH 3/3] Remove accidental enabling of Mali driver workaround on other GPUs. May help #19133 --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 6e3af3cf2b..4f8fb6465f 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1054,8 +1054,6 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread) INFO_LOG(G3D, "KHR_depth_stencil_resolve not supported, disabling multisampling"); } - bugs_.Infest(Draw::Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL_MALI); - // We limit multisampling functionality to reasonably recent and known-good tiling GPUs. if (multisampleAllowed) { // Check for depth stencil resolve. Without it, depth textures won't work, and we don't want that mess