From d0ea3b32844db43d92ef4b95261a393a908e3607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 May 2022 01:15:56 +0200 Subject: [PATCH] Work around the Mali stencil discard bug the same way as the Adreno one. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 5 +++++ GPU/Common/ShaderId.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 66b800dae1..db01e817c0 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -823,6 +823,11 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) // corrupt the depth buffer. This is easily worked around by simply scaling Z down a tiny bit when this case // is detected. See: https://github.com/hrydgard/ppsspp/issues/11937 bugs_.Infest(Bugs::EQUAL_WZ_CORRUPTS_DEPTH); + + if (IsHashMaliDriverVersion(deviceProps) || VK_VERSION_MAJOR(deviceProps.driverVersion) <= 16) { + // At least one driver at the upper end of the range is known to be likely to suffer from the bug causing issue #13833 (Midnight Club map broken). + bugs_.Infest(Bugs::MALI_STENCIL_DISCARD_BUG); + } } caps_.deviceID = deviceProps.deviceID; diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 291c1afa8b..230de66e65 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -341,6 +341,10 @@ void ComputeFragmentShaderID(FShaderID *id_out, const Draw::Bugs &bugs) { if (g_Config.bVendorBugChecksEnabled) { if (bugs.Has(Draw::Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL)) { id.SetBit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL, !IsStencilTestOutputDisabled() && !gstate.isDepthWriteEnabled()); + } else if (bugs.Has(Draw::Bugs::MALI_STENCIL_DISCARD_BUG)) { + // Very similar driver bug to the Adreno one, with the same workaround (though might look into if there are cheaper ones!) + // Keeping the conditions separate since it can probably be made tighter. + id.SetBit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL, !IsStencilTestOutputDisabled() && !gstate.isDepthWriteEnabled()); } } }