From 68bd4cd79a7f00214fd0a21127cab5edce7b4af4 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 15 Jul 2019 19:45:36 +1000 Subject: [PATCH] Vulkan: Use reversed depth range in viewport Also adds a DriverDetails bug to disable on drivers where this is still broken. --- Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | 9 +++++++-- Source/Core/VideoCommon/DriverDetails.cpp | 5 ++++- Source/Core/VideoCommon/DriverDetails.h | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 1f0955c921..46ce571bd5 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -272,6 +272,7 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config) config->backend_info.bSupportsPostProcessing = true; // Assumed support. config->backend_info.bSupportsBackgroundCompiling = true; // Assumed support. config->backend_info.bSupportsCopyToVram = true; // Assumed support. + config->backend_info.bSupportsReversedDepthRange = true; // Assumed support. config->backend_info.bSupportsDualSourceBlend = false; // Dependent on features. config->backend_info.bSupportsGeometryShaders = false; // Dependent on features. config->backend_info.bSupportsGSInstancing = false; // Dependent on features. @@ -283,8 +284,7 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config) config->backend_info.bSupportsBPTCTextures = false; // Dependent on features. config->backend_info.bSupportsLogicOp = false; // Dependent on features. config->backend_info.bSupportsLargePoints = false; // Dependent on features. - config->backend_info.bSupportsReversedDepthRange = false; // No support yet due to driver bugs. - config->backend_info.bSupportsFramebufferFetch = false; // No support. + config->backend_info.bSupportsFramebufferFetch = false; // No support. } void VulkanContext::PopulateBackendInfoAdapters(VideoConfig* config, const GPUList& gpu_list) @@ -340,6 +340,11 @@ void VulkanContext::PopulateBackendInfoFeatures(VideoConfig* config, VkPhysicalD // Seems to be fine on GCN Gen 1-2, unconfirmed on GCN Gen 3, causes driver resets on GCN Gen 4. if (DriverDetails::HasBug(DriverDetails::BUG_PRIMITIVE_RESTART)) config->backend_info.bSupportsPrimitiveRestart = false; + + // Reversed depth range is broken on some drivers, or is broken when used in combination + // with depth clamping. Fall back to inverted depth range for these. + if (DriverDetails::HasBug(DriverDetails::BUG_BROKEN_REVERSED_DEPTH_RANGE)) + config->backend_info.bSupportsReversedDepthRange = false; } void VulkanContext::PopulateBackendInfoMultisampleModes( diff --git a/Source/Core/VideoCommon/DriverDetails.cpp b/Source/Core/VideoCommon/DriverDetails.cpp index 8acf227f12..85d94d5622 100644 --- a/Source/Core/VideoCommon/DriverDetails.cpp +++ b/Source/Core/VideoCommon/DriverDetails.cpp @@ -108,7 +108,10 @@ constexpr BugInfo m_known_bugs[] = { BUG_BROKEN_CLEAR_LOADOP_RENDERPASS, -1.0, -1.0, true}, {API_VULKAN, OS_ALL, VENDOR_QUALCOMM, DRIVER_QUALCOMM, Family::UNKNOWN, BUG_BROKEN_D32F_CLEAR, -1.0, -1.0, true}, -}; + {API_VULKAN, OS_ALL, VENDOR_MESA, DRIVER_I965, Family::UNKNOWN, BUG_BROKEN_REVERSED_DEPTH_RANGE, + -1.0, -1.0, true}, + {API_VULKAN, OS_ALL, VENDOR_QUALCOMM, DRIVER_QUALCOMM, Family::UNKNOWN, + BUG_BROKEN_REVERSED_DEPTH_RANGE, -1.0, -1.0, true}}; static std::map m_bugs; diff --git a/Source/Core/VideoCommon/DriverDetails.h b/Source/Core/VideoCommon/DriverDetails.h index 12f4c56225..4c0f280856 100644 --- a/Source/Core/VideoCommon/DriverDetails.h +++ b/Source/Core/VideoCommon/DriverDetails.h @@ -276,6 +276,11 @@ enum Bug // Started version: -1 // Ended version: -1 BUG_BROKEN_D32F_CLEAR, + + // BUG: Reversed viewport depth range does not work as intended on some Vulkan drivers. + // The Vulkan spec allows the minDepth/maxDepth fields in the viewport to be reversed, + // however the implementation is broken on some drivers. + BUG_BROKEN_REVERSED_DEPTH_RANGE, }; // Initializes our internal vendor, device family, and driver version