diff options
| author | 2023-09-28 09:35:37 -0400 | |
|---|---|---|
| committer | 2023-09-28 09:35:37 -0400 | |
| commit | 7bae22a3ca55e2e4ed985fed1cf2abe848de60c2 (patch) | |
| tree | efa6396c6c43d84f046343efd41a0204244e0f53 /src/video_core/renderer_vulkan | |
| parent | Merge pull request #11590 from liamwhite/attribute (diff) | |
| parent | Vulkan: add temporary workaround for AMDVLK (diff) | |
| download | yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.gz yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.xz yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.zip | |
Merge pull request #11402 from FernandoS27/depth-bias-control
Vulkan: Implement Depth Bias Control
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
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 | } |