From 79ef185d6ea65f6dcc37e3e1ffe7a8880685bfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 22 Dec 2018 18:29:56 +0100 Subject: [PATCH 1/2] Vulkan/adreno: Apply workaround for Harvest Moon issue #10421 --- GPU/Vulkan/StateMappingVulkan.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index ff6c141af570..2cc8f0822974 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -235,6 +235,18 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag } key.colorWriteMask = (rmask ? VK_COLOR_COMPONENT_R_BIT : 0) | (gmask ? VK_COLOR_COMPONENT_G_BIT : 0) | (bmask ? VK_COLOR_COMPONENT_B_BIT : 0) | (amask ? VK_COLOR_COMPONENT_A_BIT : 0); + + // Workaround proposed in #10421 + if ((gstate.pmskc & 0x00FFFFFF) == 0x00FFFFFF && vulkan_->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDevice()).vendorID == VULKAN_VENDOR_QUALCOMM) { + key.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + key.blendEnable = true; + key.blendOpColor = VK_BLEND_OP_ADD; + key.blendOpAlpha = VK_BLEND_OP_ADD; + key.srcColor = VK_BLEND_FACTOR_ZERO; + key.srcAlpha = VK_BLEND_FACTOR_ZERO; + key.destColor = VK_BLEND_FACTOR_ONE; + key.destAlpha = VK_BLEND_FACTOR_ONE; + } } } From 0037da55a183cf5ff285d59471a95e9d3c214ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Dec 2018 11:57:06 +0100 Subject: [PATCH 2/2] Avoid breaking any alpha-stencil emulation in Adreno bug workaround --- GPU/Vulkan/StateMappingVulkan.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 2cc8f0822974..e72df78c3557 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -236,16 +236,18 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag key.colorWriteMask = (rmask ? VK_COLOR_COMPONENT_R_BIT : 0) | (gmask ? VK_COLOR_COMPONENT_G_BIT : 0) | (bmask ? VK_COLOR_COMPONENT_B_BIT : 0) | (amask ? VK_COLOR_COMPONENT_A_BIT : 0); - // Workaround proposed in #10421 + // Workaround proposed in #10421, for bug where the color write mask is not applied correctly on Adreno. if ((gstate.pmskc & 0x00FFFFFF) == 0x00FFFFFF && vulkan_->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDevice()).vendorID == VULKAN_VENDOR_QUALCOMM) { key.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - key.blendEnable = true; + if (!key.blendEnable) { + key.blendEnable = true; + key.blendOpAlpha = VK_BLEND_OP_ADD; + key.srcAlpha = VK_BLEND_FACTOR_ZERO; + key.destAlpha = VK_BLEND_FACTOR_ONE; + } key.blendOpColor = VK_BLEND_OP_ADD; - key.blendOpAlpha = VK_BLEND_OP_ADD; key.srcColor = VK_BLEND_FACTOR_ZERO; - key.srcAlpha = VK_BLEND_FACTOR_ZERO; key.destColor = VK_BLEND_FACTOR_ONE; - key.destAlpha = VK_BLEND_FACTOR_ONE; } } }