From ad8afaf1ef0c2f6c9ecb4e3670d4a3e4192ab0a9 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 17 Oct 2021 03:49:18 +0200 Subject: [PATCH] Vulran Rasterizer: address feedback. --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 04ecc034dc..30b47a7a0f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -633,10 +633,12 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { regs.zeta.format == Tegra::DepthFormat::D24S8_UNORM || regs.zeta.format == Tegra::DepthFormat::D24C8_UNORM; if (is_d24 && !device.SupportsD24DepthBuffer()) { - const double f = static_cast(1ULL << (32 - 24)) / (static_cast(0x1.ep+127)); - units = static_cast(static_cast(units) * f); + // 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(1ULL << (32 - 24)) / (static_cast(0x1.ep+127)); + units = static_cast(static_cast(units) * rescale_factor); } - scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp, factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { cmdbuf.SetDepthBias(constant, clamp, factor);