diff options
| author | 2023-08-28 00:54:39 +0200 | |
|---|---|---|
| committer | 2023-09-16 11:58:55 -0400 | |
| commit | 6a1ecab2dde1db7d3183d9c98eda393341cca50b (patch) | |
| tree | cf82bb3aa122ba7e0d73094157bf134b430f2bad /src/video_core/renderer_vulkan | |
| parent | Merge pull request #11519 from german77/system-policy (diff) | |
| download | yuzu-6a1ecab2dde1db7d3183d9c98eda393341cca50b.tar.gz yuzu-6a1ecab2dde1db7d3183d9c98eda393341cca50b.tar.xz yuzu-6a1ecab2dde1db7d3183d9c98eda393341cca50b.zip | |
Vulkan: Implement Depth Bias Control
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 25 |
1 files changed, 22 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 | } |