diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-09-28 15:35:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-28 15:35:37 +0200 |
commit | 7bae22a3ca55e2e4ed985fed1cf2abe848de60c2 (patch) | |
tree | efa6396c6c43d84f046343efd41a0204244e0f53 /src/video_core/renderer_vulkan/vk_rasterizer.cpp | |
parent | Merge pull request #11590 from liamwhite/attribute (diff) | |
parent | Vulkan: add temporary workaround for AMDVLK (diff) | |
download | yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.gz yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.bz2 yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.lz yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.xz yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.tar.zst yuzu-7bae22a3ca55e2e4ed985fed1cf2abe848de60c2.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_rasterizer.cpp')
-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) { regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; - if (is_d24 && !device.SupportsD24DepthBuffer()) { + bool force_unorm = ([&] { + if (!is_d24 || device.SupportsD24DepthBuffer()) { + return false; + } + if (device.IsExtDepthBiasControlSupported()) { + return true; + } + if (!Settings::values.renderer_amdvlk_depth_bias_workaround) { + return false; + } // the base formulas can be obtained from here: // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias const double rescale_factor = static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); units = static_cast<float>(static_cast<double>(units) * rescale_factor); - } + return false; + })(); scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, - factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) { + factor = regs.slope_scale_depth_bias, force_unorm, + precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) { + if (force_unorm) { + VkDepthBiasRepresentationInfoEXT info{ + .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT, + .pNext = nullptr, + .depthBiasRepresentation = + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, + .depthBiasExact = precise ? VK_TRUE : VK_FALSE, + }; + cmdbuf.SetDepthBias(constant, clamp, factor, &info); + return; + } cmdbuf.SetDepthBias(constant, clamp, factor); }); } |