diff options
| -rw-r--r-- | src/video_core/dirty_flags.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 14 | ||||
| -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, 29 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..04ecc034d 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -627,9 +627,19 @@ 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 | const double f = static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); | ||
| 637 | units = static_cast<float>(static_cast<double>(units) * f); | ||
| 638 | } | ||
| 639 | |||
| 640 | scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp, | ||
| 631 | factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { | 641 | factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { |
| 632 | cmdbuf.SetDepthBias(constant, clamp, factor / 2.0f); | 642 | cmdbuf.SetDepthBias(constant, clamp, factor); |
| 633 | }); | 643 | }); |
| 634 | } | 644 | } |
| 635 | 645 | ||
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 24b809242..c6e50bb5f 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -216,6 +216,7 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 216 | BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); | 216 | BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); |
| 217 | } | 217 | } |
| 218 | const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; | 218 | const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; |
| 219 | |||
| 219 | PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); | 220 | PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); |
| 220 | 221 | ||
| 221 | for (size_t index = 0; index < NUM_RT; ++index) { | 222 | for (size_t index = 0; index < NUM_RT; ++index) { |
| @@ -225,6 +226,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { | |||
| 225 | maxwell3d.regs.render_area.width, | 226 | maxwell3d.regs.render_area.width, |
| 226 | maxwell3d.regs.render_area.height, | 227 | maxwell3d.regs.render_area.height, |
| 227 | }; | 228 | }; |
| 229 | |||
| 230 | flags[Dirty::DepthBiasGlobal] = true; | ||
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | template <class P> | 233 | template <class P> |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index c2ec9f76a..3a048900b 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -618,6 +618,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 618 | is_float16_supported = false; | 618 | is_float16_supported = false; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | supports_d24_depth = | ||
| 622 | IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, | ||
| 623 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal); | ||
| 624 | |||
| 621 | graphics_queue = logical.GetQueue(graphics_family); | 625 | graphics_queue = logical.GetQueue(graphics_family); |
| 622 | present_queue = logical.GetQueue(present_family); | 626 | present_queue = logical.GetQueue(present_family); |
| 623 | } | 627 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index bc180a32a..f14e4001e 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -327,6 +327,10 @@ public: | |||
| 327 | return sets_per_pool; | 327 | return sets_per_pool; |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | bool SupportsD24DepthBuffer() const { | ||
| 331 | return supports_d24_depth; | ||
| 332 | } | ||
| 333 | |||
| 330 | private: | 334 | private: |
| 331 | /// Checks if the physical device is suitable. | 335 | /// Checks if the physical device is suitable. |
| 332 | void CheckSuitability(bool requires_swapchain) const; | 336 | void CheckSuitability(bool requires_swapchain) const; |
| @@ -419,6 +423,7 @@ private: | |||
| 419 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. | 423 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. |
| 420 | bool has_renderdoc{}; ///< Has RenderDoc attached | 424 | bool has_renderdoc{}; ///< Has RenderDoc attached |
| 421 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached | 425 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached |
| 426 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. | ||
| 422 | 427 | ||
| 423 | // Telemetry parameters | 428 | // Telemetry parameters |
| 424 | std::string vendor_name; ///< Device's driver name. | 429 | std::string vendor_name; ///< Device's driver name. |