diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.h | 2 | ||||
| -rw-r--r-- | src/core/core.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 14 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.h | 13 |
7 files changed, 69 insertions, 3 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index ae5e5d2b8..98ab0ec2e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -351,6 +351,8 @@ struct Values { | |||
| 351 | linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; | 351 | linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; |
| 352 | Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", | 352 | Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", |
| 353 | Category::RendererDebug}; | 353 | Category::RendererDebug}; |
| 354 | // TODO: remove this once AMDVLK supports VK_EXT_depth_bias_control | ||
| 355 | bool renderer_amdvlk_depth_bias_workaround{}; | ||
| 354 | 356 | ||
| 355 | // System | 357 | // System |
| 356 | SwitchableSetting<Language, true> language_index{linkage, | 358 | SwitchableSetting<Language, true> language_index{linkage, |
diff --git a/src/core/core.cpp b/src/core/core.cpp index e8300cd05..08cbb8978 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -381,6 +381,10 @@ struct System::Impl { | |||
| 381 | room_member->SendGameInfo(game_info); | 381 | room_member->SendGameInfo(game_info); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | // Workarounds: | ||
| 385 | // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK | ||
| 386 | Settings::values.renderer_amdvlk_depth_bias_workaround = program_id == 0x1006A800016E000ULL; | ||
| 387 | |||
| 384 | status = SystemResultStatus::Success; | 388 | status = SystemResultStatus::Success; |
| 385 | return status; | 389 | return status; |
| 386 | } | 390 | } |
| @@ -440,6 +444,9 @@ struct System::Impl { | |||
| 440 | room_member->SendGameInfo(game_info); | 444 | room_member->SendGameInfo(game_info); |
| 441 | } | 445 | } |
| 442 | 446 | ||
| 447 | // Workarounds | ||
| 448 | Settings::values.renderer_amdvlk_depth_bias_workaround = false; | ||
| 449 | |||
| 443 | LOG_DEBUG(Core, "Shutdown OK"); | 450 | LOG_DEBUG(Core, "Shutdown OK"); |
| 444 | } | 451 | } |
| 445 | 452 | ||
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index c7ce7c312..1628d76d6 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -1014,15 +1014,37 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { | |||
| 1014 | regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || | 1014 | regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || |
| 1015 | regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || | 1015 | regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || |
| 1016 | regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; | 1016 | regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; |
| 1017 | if (is_d24 && !device.SupportsD24DepthBuffer()) { | 1017 | bool force_unorm = ([&] { |
| 1018 | if (!is_d24 || device.SupportsD24DepthBuffer()) { | ||
| 1019 | return false; | ||
| 1020 | } | ||
| 1021 | if (device.IsExtDepthBiasControlSupported()) { | ||
| 1022 | return true; | ||
| 1023 | } | ||
| 1024 | if (!Settings::values.renderer_amdvlk_depth_bias_workaround) { | ||
| 1025 | return false; | ||
| 1026 | } | ||
| 1018 | // the base formulas can be obtained from here: | 1027 | // the base formulas can be obtained from here: |
| 1019 | // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias | 1028 | // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias |
| 1020 | const double rescale_factor = | 1029 | const double rescale_factor = |
| 1021 | static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); | 1030 | static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); |
| 1022 | units = static_cast<float>(static_cast<double>(units) * rescale_factor); | 1031 | units = static_cast<float>(static_cast<double>(units) * rescale_factor); |
| 1023 | } | 1032 | return false; |
| 1033 | })(); | ||
| 1024 | scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, | 1034 | scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, |
| 1025 | factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) { | 1035 | factor = regs.slope_scale_depth_bias, force_unorm, |
| 1036 | precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) { | ||
| 1037 | if (force_unorm) { | ||
| 1038 | VkDepthBiasRepresentationInfoEXT info{ | ||
| 1039 | .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT, | ||
| 1040 | .pNext = nullptr, | ||
| 1041 | .depthBiasRepresentation = | ||
| 1042 | VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, | ||
| 1043 | .depthBiasExact = precise ? VK_TRUE : VK_FALSE, | ||
| 1044 | }; | ||
| 1045 | cmdbuf.SetDepthBias(constant, clamp, factor, &info); | ||
| 1046 | return; | ||
| 1047 | } | ||
| 1026 | cmdbuf.SetDepthBias(constant, clamp, factor); | 1048 | cmdbuf.SetDepthBias(constant, clamp, factor); |
| 1027 | }); | 1049 | }); |
| 1028 | } | 1050 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 18185610f..3960b135a 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -1059,6 +1059,13 @@ void Device::RemoveUnsuitableExtensions() { | |||
| 1059 | RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color, | 1059 | RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color, |
| 1060 | VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); | 1060 | VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 1061 | 1061 | ||
| 1062 | // VK_EXT_depth_bias_control | ||
| 1063 | extensions.depth_bias_control = | ||
| 1064 | features.depth_bias_control.depthBiasControl && | ||
| 1065 | features.depth_bias_control.leastRepresentableValueForceUnormRepresentation; | ||
| 1066 | RemoveExtensionFeatureIfUnsuitable(extensions.depth_bias_control, features.depth_bias_control, | ||
| 1067 | VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME); | ||
| 1068 | |||
| 1062 | // VK_EXT_depth_clip_control | 1069 | // VK_EXT_depth_clip_control |
| 1063 | extensions.depth_clip_control = features.depth_clip_control.depthClipControl; | 1070 | extensions.depth_clip_control = features.depth_clip_control.depthClipControl; |
| 1064 | RemoveExtensionFeatureIfUnsuitable(extensions.depth_clip_control, features.depth_clip_control, | 1071 | RemoveExtensionFeatureIfUnsuitable(extensions.depth_clip_control, features.depth_clip_control, |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index dd1e7ea8c..9be612392 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -41,6 +41,7 @@ VK_DEFINE_HANDLE(VmaAllocator) | |||
| 41 | // Define all features which may be used by the implementation and require an extension here. | 41 | // Define all features which may be used by the implementation and require an extension here. |
| 42 | #define FOR_EACH_VK_FEATURE_EXT(FEATURE) \ | 42 | #define FOR_EACH_VK_FEATURE_EXT(FEATURE) \ |
| 43 | FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \ | 43 | FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \ |
| 44 | FEATURE(EXT, DepthBiasControl, DEPTH_BIAS_CONTROL, depth_bias_control) \ | ||
| 44 | FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \ | 45 | FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \ |
| 45 | FEATURE(EXT, ExtendedDynamicState, EXTENDED_DYNAMIC_STATE, extended_dynamic_state) \ | 46 | FEATURE(EXT, ExtendedDynamicState, EXTENDED_DYNAMIC_STATE, extended_dynamic_state) \ |
| 46 | FEATURE(EXT, ExtendedDynamicState2, EXTENDED_DYNAMIC_STATE_2, extended_dynamic_state2) \ | 47 | FEATURE(EXT, ExtendedDynamicState2, EXTENDED_DYNAMIC_STATE_2, extended_dynamic_state2) \ |
| @@ -96,6 +97,7 @@ VK_DEFINE_HANDLE(VmaAllocator) | |||
| 96 | #define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \ | 97 | #define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \ |
| 97 | EXTENSION_NAME(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME) \ | 98 | EXTENSION_NAME(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME) \ |
| 98 | EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \ | 99 | EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \ |
| 100 | EXTENSION_NAME(VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME) \ | ||
| 99 | EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \ | 101 | EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \ |
| 100 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \ | 102 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \ |
| 101 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \ | 103 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \ |
| @@ -147,6 +149,9 @@ VK_DEFINE_HANDLE(VmaAllocator) | |||
| 147 | // Define features where the absence of the feature may result in a degraded experience. | 149 | // Define features where the absence of the feature may result in a degraded experience. |
| 148 | #define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \ | 150 | #define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \ |
| 149 | FEATURE_NAME(custom_border_color, customBorderColors) \ | 151 | FEATURE_NAME(custom_border_color, customBorderColors) \ |
| 152 | FEATURE_NAME(depth_bias_control, depthBiasControl) \ | ||
| 153 | FEATURE_NAME(depth_bias_control, leastRepresentableValueForceUnormRepresentation) \ | ||
| 154 | FEATURE_NAME(depth_bias_control, depthBiasExact) \ | ||
| 150 | FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \ | 155 | FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \ |
| 151 | FEATURE_NAME(format_a4b4g4r4, formatA4B4G4R4) \ | 156 | FEATURE_NAME(format_a4b4g4r4, formatA4B4G4R4) \ |
| 152 | FEATURE_NAME(index_type_uint8, indexTypeUint8) \ | 157 | FEATURE_NAME(index_type_uint8, indexTypeUint8) \ |
| @@ -464,6 +469,11 @@ public: | |||
| 464 | return extensions.depth_clip_control; | 469 | return extensions.depth_clip_control; |
| 465 | } | 470 | } |
| 466 | 471 | ||
| 472 | /// Returns true if the device supports VK_EXT_depth_bias_control. | ||
| 473 | bool IsExtDepthBiasControlSupported() const { | ||
| 474 | return extensions.depth_bias_control; | ||
| 475 | } | ||
| 476 | |||
| 467 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. | 477 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. |
| 468 | bool IsExtShaderViewportIndexLayerSupported() const { | 478 | bool IsExtShaderViewportIndexLayerSupported() const { |
| 469 | return extensions.shader_viewport_index_layer; | 479 | return extensions.shader_viewport_index_layer; |
| @@ -624,6 +634,10 @@ public: | |||
| 624 | return features.robustness2.nullDescriptor; | 634 | return features.robustness2.nullDescriptor; |
| 625 | } | 635 | } |
| 626 | 636 | ||
| 637 | bool HasExactDepthBiasControl() const { | ||
| 638 | return features.depth_bias_control.depthBiasExact; | ||
| 639 | } | ||
| 640 | |||
| 627 | u32 GetMaxVertexInputAttributes() const { | 641 | u32 GetMaxVertexInputAttributes() const { |
| 628 | return properties.properties.limits.maxVertexInputAttributes; | 642 | return properties.properties.limits.maxVertexInputAttributes; |
| 629 | } | 643 | } |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 5afba365c..2f3254a97 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp | |||
| @@ -113,6 +113,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept { | |||
| 113 | X(vkCmdPushDescriptorSetWithTemplateKHR); | 113 | X(vkCmdPushDescriptorSetWithTemplateKHR); |
| 114 | X(vkCmdSetBlendConstants); | 114 | X(vkCmdSetBlendConstants); |
| 115 | X(vkCmdSetDepthBias); | 115 | X(vkCmdSetDepthBias); |
| 116 | X(vkCmdSetDepthBias2EXT); | ||
| 116 | X(vkCmdSetDepthBounds); | 117 | X(vkCmdSetDepthBounds); |
| 117 | X(vkCmdSetEvent); | 118 | X(vkCmdSetEvent); |
| 118 | X(vkCmdSetScissor); | 119 | X(vkCmdSetScissor); |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 0d4bbe7f7..1e3c0fa64 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h | |||
| @@ -226,6 +226,7 @@ struct DeviceDispatch : InstanceDispatch { | |||
| 226 | PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants{}; | 226 | PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants{}; |
| 227 | PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT{}; | 227 | PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT{}; |
| 228 | PFN_vkCmdSetDepthBias vkCmdSetDepthBias{}; | 228 | PFN_vkCmdSetDepthBias vkCmdSetDepthBias{}; |
| 229 | PFN_vkCmdSetDepthBias2EXT vkCmdSetDepthBias2EXT{}; | ||
| 229 | PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds{}; | 230 | PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds{}; |
| 230 | PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT{}; | 231 | PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT{}; |
| 231 | PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT{}; | 232 | PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT{}; |
| @@ -1333,6 +1334,18 @@ public: | |||
| 1333 | dld->vkCmdSetDepthBias(handle, constant_factor, clamp, slope_factor); | 1334 | dld->vkCmdSetDepthBias(handle, constant_factor, clamp, slope_factor); |
| 1334 | } | 1335 | } |
| 1335 | 1336 | ||
| 1337 | void SetDepthBias(float constant_factor, float clamp, float slope_factor, | ||
| 1338 | VkDepthBiasRepresentationInfoEXT* extra) const noexcept { | ||
| 1339 | VkDepthBiasInfoEXT info{ | ||
| 1340 | .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_INFO_EXT, | ||
| 1341 | .pNext = extra, | ||
| 1342 | .depthBiasConstantFactor = constant_factor, | ||
| 1343 | .depthBiasClamp = clamp, | ||
| 1344 | .depthBiasSlopeFactor = slope_factor, | ||
| 1345 | }; | ||
| 1346 | dld->vkCmdSetDepthBias2EXT(handle, &info); | ||
| 1347 | } | ||
| 1348 | |||
| 1336 | void SetDepthBounds(float min_depth_bounds, float max_depth_bounds) const noexcept { | 1349 | void SetDepthBounds(float min_depth_bounds, float max_depth_bounds) const noexcept { |
| 1337 | dld->vkCmdSetDepthBounds(handle, min_depth_bounds, max_depth_bounds); | 1350 | dld->vkCmdSetDepthBounds(handle, min_depth_bounds, max_depth_bounds); |
| 1338 | } | 1351 | } |