diff options
| author | 2021-10-23 18:02:23 -0400 | |
|---|---|---|
| committer | 2021-10-23 18:02:23 -0400 | |
| commit | 494e34af6a247ebe18baaa237d6aab547feb3fba (patch) | |
| tree | 60c61302d9ffc00b398ce6fbb53b7b74bbe17d51 /src/video_core/renderer_vulkan | |
| parent | Merge pull request #7217 from yuzu-emu/revert-6515-gc_thread_safe (diff) | |
| parent | Vulran Rasterizer: address feedback. (diff) | |
| download | yuzu-494e34af6a247ebe18baaa237d6aab547feb3fba.tar.gz yuzu-494e34af6a247ebe18baaa237d6aab547feb3fba.tar.xz yuzu-494e34af6a247ebe18baaa237d6aab547feb3fba.zip | |
Merge pull request #7070 from FernandoS27/want-you-bad
Vulkan Rasterizer: Correct DepthBias/PolygonOffset on Vulkan.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.h | 3 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 3bcd6d6cc..30b47a7a0 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -627,9 +627,21 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { | |||
| 627 | if (!state_tracker.TouchDepthBias()) { | 627 | if (!state_tracker.TouchDepthBias()) { |
| 628 | return; | 628 | return; |
| 629 | } | 629 | } |
| 630 | scheduler.Record([constant = regs.polygon_offset_units, clamp = regs.polygon_offset_clamp, | 630 | float units = regs.polygon_offset_units / 2.0f; |
| 631 | const bool is_d24 = regs.zeta.format == Tegra::DepthFormat::S8_UINT_Z24_UNORM || | ||
| 632 | regs.zeta.format == Tegra::DepthFormat::D24X8_UNORM || | ||
| 633 | regs.zeta.format == Tegra::DepthFormat::D24S8_UNORM || | ||
| 634 | regs.zeta.format == Tegra::DepthFormat::D24C8_UNORM; | ||
| 635 | if (is_d24 && !device.SupportsD24DepthBuffer()) { | ||
| 636 | // the base formulas can be obtained from here: | ||
| 637 | // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias | ||
| 638 | const double rescale_factor = | ||
| 639 | static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); | ||
| 640 | units = static_cast<float>(static_cast<double>(units) * rescale_factor); | ||
| 641 | } | ||
| 642 | scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp, | ||
| 631 | factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { | 643 | factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { |
| 632 | cmdbuf.SetDepthBias(constant, clamp, factor / 2.0f); | 644 | cmdbuf.SetDepthBias(constant, clamp, factor); |
| 633 | }); | 645 | }); |
| 634 | } | 646 | } |
| 635 | 647 | ||
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index d90935f52..2f2d6b31f 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h | |||
| @@ -79,7 +79,8 @@ public: | |||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | bool TouchDepthBias() { | 81 | bool TouchDepthBias() { |
| 82 | return Exchange(Dirty::DepthBias, false); | 82 | return Exchange(Dirty::DepthBias, false) || |
| 83 | Exchange(VideoCommon::Dirty::DepthBiasGlobal, false); | ||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | bool TouchBlendConstants() { | 86 | bool TouchBlendConstants() { |