diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 25 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 15 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.h | 13 |
4 files changed, 51 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 01e76a82c..0201c4d08 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -1043,15 +1043,34 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { | |||
| 1043 | regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || | 1043 | regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || |
| 1044 | regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || | 1044 | regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || |
| 1045 | regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; | 1045 | regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; |
| 1046 | if (is_d24 && !device.SupportsD24DepthBuffer()) { | 1046 | bool force_unorm = ([&] { |
| 1047 | if (!is_d24 || device.SupportsD24DepthBuffer()) { | ||
| 1048 | return false; | ||
| 1049 | } | ||
| 1050 | if (device.IsExtDepthBiasControlSupported()) { | ||
| 1051 | return true; | ||
| 1052 | } | ||
| 1047 | // the base formulas can be obtained from here: | 1053 | // the base formulas can be obtained from here: |
| 1048 | // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias | 1054 | // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias |
| 1049 | const double rescale_factor = | 1055 | const double rescale_factor = |
| 1050 | static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); | 1056 | static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); |
| 1051 | units = static_cast<float>(static_cast<double>(units) * rescale_factor); | 1057 | units = static_cast<float>(static_cast<double>(units) * rescale_factor); |
| 1052 | } | 1058 | return false; |
| 1059 | })(); | ||
| 1053 | scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, | 1060 | scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, |
| 1054 | factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) { | 1061 | factor = regs.slope_scale_depth_bias, force_unorm, |
| 1062 | precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) { | ||
| 1063 | if (force_unorm) { | ||
| 1064 | VkDepthBiasRepresentationInfoEXT info{ | ||
| 1065 | .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT, | ||
| 1066 | .pNext = nullptr, | ||
| 1067 | .depthBiasRepresentation = | ||
| 1068 | VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, | ||
| 1069 | .depthBiasExact = precise ? VK_TRUE : VK_FALSE, | ||
| 1070 | }; | ||
| 1071 | cmdbuf.SetDepthBias(constant, clamp, factor, &info); | ||
| 1072 | return; | ||
| 1073 | } | ||
| 1055 | cmdbuf.SetDepthBias(constant, clamp, factor); | 1074 | cmdbuf.SetDepthBias(constant, clamp, factor); |
| 1056 | }); | 1075 | }); |
| 1057 | } | 1076 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 488fdd313..2063f58b5 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) \ |
| @@ -93,6 +94,7 @@ VK_DEFINE_HANDLE(VmaAllocator) | |||
| 93 | // Define extensions where the absence of the extension may result in a degraded experience. | 94 | // Define extensions where the absence of the extension may result in a degraded experience. |
| 94 | #define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \ | 95 | #define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \ |
| 95 | EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \ | 96 | EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \ |
| 97 | EXTENSION_NAME(VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME) \ | ||
| 96 | EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \ | 98 | EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \ |
| 97 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \ | 99 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \ |
| 98 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \ | 100 | EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \ |
| @@ -143,6 +145,9 @@ VK_DEFINE_HANDLE(VmaAllocator) | |||
| 143 | // Define features where the absence of the feature may result in a degraded experience. | 145 | // Define features where the absence of the feature may result in a degraded experience. |
| 144 | #define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \ | 146 | #define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \ |
| 145 | FEATURE_NAME(custom_border_color, customBorderColors) \ | 147 | FEATURE_NAME(custom_border_color, customBorderColors) \ |
| 148 | FEATURE_NAME(depth_bias_control, depthBiasControl) \ | ||
| 149 | FEATURE_NAME(depth_bias_control, leastRepresentableValueForceUnormRepresentation) \ | ||
| 150 | FEATURE_NAME(depth_bias_control, depthBiasExact) \ | ||
| 146 | FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \ | 151 | FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \ |
| 147 | FEATURE_NAME(index_type_uint8, indexTypeUint8) \ | 152 | FEATURE_NAME(index_type_uint8, indexTypeUint8) \ |
| 148 | FEATURE_NAME(primitive_topology_list_restart, primitiveTopologyListRestart) \ | 153 | FEATURE_NAME(primitive_topology_list_restart, primitiveTopologyListRestart) \ |
| @@ -449,6 +454,12 @@ public: | |||
| 449 | return extensions.depth_clip_control; | 454 | return extensions.depth_clip_control; |
| 450 | } | 455 | } |
| 451 | 456 | ||
| 457 | /// Returns true if the device supports VK_EXT_depth_bias_control. | ||
| 458 | bool IsExtDepthBiasControlSupported() const { | ||
| 459 | return extensions.depth_bias_control && features.depth_bias_control.depthBiasControl && | ||
| 460 | features.depth_bias_control.leastRepresentableValueForceUnormRepresentation; | ||
| 461 | } | ||
| 462 | |||
| 452 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. | 463 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. |
| 453 | bool IsExtShaderViewportIndexLayerSupported() const { | 464 | bool IsExtShaderViewportIndexLayerSupported() const { |
| 454 | return extensions.shader_viewport_index_layer; | 465 | return extensions.shader_viewport_index_layer; |
| @@ -600,6 +611,10 @@ public: | |||
| 600 | return features.robustness2.nullDescriptor; | 611 | return features.robustness2.nullDescriptor; |
| 601 | } | 612 | } |
| 602 | 613 | ||
| 614 | bool HasExactDepthBiasControl() const { | ||
| 615 | return features.depth_bias_control.depthBiasExact; | ||
| 616 | } | ||
| 617 | |||
| 603 | u32 GetMaxVertexInputAttributes() const { | 618 | u32 GetMaxVertexInputAttributes() const { |
| 604 | return properties.properties.limits.maxVertexInputAttributes; | 619 | return properties.properties.limits.maxVertexInputAttributes; |
| 605 | } | 620 | } |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index c3f388d89..97fb09d46 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp | |||
| @@ -109,6 +109,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept { | |||
| 109 | X(vkCmdPushDescriptorSetWithTemplateKHR); | 109 | X(vkCmdPushDescriptorSetWithTemplateKHR); |
| 110 | X(vkCmdSetBlendConstants); | 110 | X(vkCmdSetBlendConstants); |
| 111 | X(vkCmdSetDepthBias); | 111 | X(vkCmdSetDepthBias); |
| 112 | X(vkCmdSetDepthBias2EXT); | ||
| 112 | X(vkCmdSetDepthBounds); | 113 | X(vkCmdSetDepthBounds); |
| 113 | X(vkCmdSetEvent); | 114 | X(vkCmdSetEvent); |
| 114 | X(vkCmdSetScissor); | 115 | X(vkCmdSetScissor); |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 049fa8038..679c2ffa8 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h | |||
| @@ -222,6 +222,7 @@ struct DeviceDispatch : InstanceDispatch { | |||
| 222 | PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants{}; | 222 | PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants{}; |
| 223 | PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT{}; | 223 | PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT{}; |
| 224 | PFN_vkCmdSetDepthBias vkCmdSetDepthBias{}; | 224 | PFN_vkCmdSetDepthBias vkCmdSetDepthBias{}; |
| 225 | PFN_vkCmdSetDepthBias2EXT vkCmdSetDepthBias2EXT{}; | ||
| 225 | PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds{}; | 226 | PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds{}; |
| 226 | PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT{}; | 227 | PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT{}; |
| 227 | PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT{}; | 228 | PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT{}; |
| @@ -1315,6 +1316,18 @@ public: | |||
| 1315 | dld->vkCmdSetDepthBias(handle, constant_factor, clamp, slope_factor); | 1316 | dld->vkCmdSetDepthBias(handle, constant_factor, clamp, slope_factor); |
| 1316 | } | 1317 | } |
| 1317 | 1318 | ||
| 1319 | void SetDepthBias(float constant_factor, float clamp, float slope_factor, | ||
| 1320 | VkDepthBiasRepresentationInfoEXT* extra) const noexcept { | ||
| 1321 | VkDepthBiasInfoEXT info{ | ||
| 1322 | .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_INFO_EXT, | ||
| 1323 | .pNext = extra, | ||
| 1324 | .depthBiasConstantFactor = constant_factor, | ||
| 1325 | .depthBiasClamp = clamp, | ||
| 1326 | .depthBiasSlopeFactor = slope_factor, | ||
| 1327 | }; | ||
| 1328 | dld->vkCmdSetDepthBias2EXT(handle, &info); | ||
| 1329 | } | ||
| 1330 | |||
| 1318 | void SetDepthBounds(float min_depth_bounds, float max_depth_bounds) const noexcept { | 1331 | void SetDepthBounds(float min_depth_bounds, float max_depth_bounds) const noexcept { |
| 1319 | dld->vkCmdSetDepthBounds(handle, min_depth_bounds, max_depth_bounds); | 1332 | dld->vkCmdSetDepthBounds(handle, min_depth_bounds, max_depth_bounds); |
| 1320 | } | 1333 | } |