diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/dirty_flags.h | 3 | ||||
| -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 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 3 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 5 |
6 files changed, 31 insertions, 3 deletions
diff --git a/src/video_core/dirty_flags.h b/src/video_core/dirty_flags.h index 504465d3f..f0d545f90 100644 --- a/src/video_core/dirty_flags.h +++ b/src/video_core/dirty_flags.h | |||
| @@ -38,6 +38,9 @@ enum : u8 { | |||
| 38 | 38 | ||
| 39 | Shaders, | 39 | Shaders, |
| 40 | 40 | ||
| 41 | // Special entries | ||
| 42 | DepthBiasGlobal, | ||
| 43 | |||
| 41 | LastCommonEntry, | 44 | LastCommonEntry, |
| 42 | }; | 45 | }; |
| 43 | 46 | ||
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() { |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 329df2e49..f70c1f764 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -221,6 +221,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 221 | BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); | 221 | BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); |
| 222 | } | 222 | } |
| 223 | const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; | 223 | const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; |
| 224 | |||
| 224 | PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); | 225 | PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); |
| 225 | 226 | ||
| 226 | for (size_t index = 0; index < NUM_RT; ++index) { | 227 | for (size_t index = 0; index < NUM_RT; ++index) { |
| @@ -230,6 +231,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 230 | maxwell3d.regs.render_area.width, | 231 | maxwell3d.regs.render_area.width, |
| 231 | maxwell3d.regs.render_area.height, | 232 | maxwell3d.regs.render_area.height, |
| 232 | }; | 233 | }; |
| 234 | |||
| 235 | flags[Dirty::DepthBiasGlobal] = true; | ||
| 233 | } | 236 | } |
| 234 | 237 | ||
| 235 | template <class P> | 238 | template <class P> |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 6388ed2eb..0f807990c 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -623,6 +623,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 623 | is_float16_supported = false; | 623 | is_float16_supported = false; |
| 624 | } | 624 | } |
| 625 | 625 | ||
| 626 | supports_d24_depth = | ||
| 627 | IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, | ||
| 628 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal); | ||
| 629 | |||
| 626 | graphics_queue = logical.GetQueue(graphics_family); | 630 | graphics_queue = logical.GetQueue(graphics_family); |
| 627 | present_queue = logical.GetQueue(present_family); | 631 | present_queue = logical.GetQueue(present_family); |
| 628 | } | 632 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index d9e74f1aa..2d5daf6cd 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -332,6 +332,10 @@ public: | |||
| 332 | return sets_per_pool; | 332 | return sets_per_pool; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | bool SupportsD24DepthBuffer() const { | ||
| 336 | return supports_d24_depth; | ||
| 337 | } | ||
| 338 | |||
| 335 | private: | 339 | private: |
| 336 | /// Checks if the physical device is suitable. | 340 | /// Checks if the physical device is suitable. |
| 337 | void CheckSuitability(bool requires_swapchain) const; | 341 | void CheckSuitability(bool requires_swapchain) const; |
| @@ -425,6 +429,7 @@ private: | |||
| 425 | bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit | 429 | bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit |
| 426 | bool has_renderdoc{}; ///< Has RenderDoc attached | 430 | bool has_renderdoc{}; ///< Has RenderDoc attached |
| 427 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached | 431 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached |
| 432 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. | ||
| 428 | 433 | ||
| 429 | // Telemetry parameters | 434 | // Telemetry parameters |
| 430 | std::string vendor_name; ///< Device's driver name. | 435 | std::string vendor_name; ///< Device's driver name. |