diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-09-23 03:14:10 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-09-23 03:49:10 +0200 |
commit | 60a39805615fb0480eb57416f5e9ec17e7c91ce4 (patch) | |
tree | 8f49ff1df003f24de667163d70132def81b665cb /src | |
parent | Merge pull request #7003 from ameerj/unlocked-present-mode (diff) | |
download | yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar.gz yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar.bz2 yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar.lz yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar.xz yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.tar.zst yuzu-60a39805615fb0480eb57416f5e9ec17e7c91ce4.zip |
Diffstat (limited to 'src')
-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 { Shaders, + // Special entries + DepthBiasGlobal, + LastCommonEntry, }; 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) { if (!state_tracker.TouchDepthBias()) { return; } - scheduler.Record([constant = regs.polygon_offset_units, clamp = regs.polygon_offset_clamp, + float units = regs.polygon_offset_units / 2.0f; + const bool is_d24 = regs.zeta.format == Tegra::DepthFormat::S8_UINT_Z24_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24X8_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24S8_UNORM || + regs.zeta.format == Tegra::DepthFormat::D24C8_UNORM; + if (is_d24 && !device.SupportsD24DepthBuffer()) { + const double f = static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); + units = static_cast<float>(static_cast<double>(units) * f); + } + + scheduler.Record([constant = units, clamp = regs.polygon_offset_clamp, factor = regs.polygon_offset_factor](vk::CommandBuffer cmdbuf) { - cmdbuf.SetDepthBias(constant, clamp, factor / 2.0f); + cmdbuf.SetDepthBias(constant, clamp, factor); }); } 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: } bool TouchDepthBias() { - return Exchange(Dirty::DepthBias, false); + return Exchange(Dirty::DepthBias, false) || + Exchange(VideoCommon::Dirty::DepthBiasGlobal, false); } 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) { BindRenderTarget(&render_targets.depth_buffer_id, FindDepthBuffer(is_clear)); } const ImageViewId depth_buffer_id = render_targets.depth_buffer_id; + PrepareImageView(depth_buffer_id, true, is_clear && IsFullClear(depth_buffer_id)); for (size_t index = 0; index < NUM_RT; ++index) { @@ -225,6 +226,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) { maxwell3d.regs.render_area.width, maxwell3d.regs.render_area.height, }; + + flags[Dirty::DepthBiasGlobal] = true; } 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 is_float16_supported = false; } + supports_d24_depth = + IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, FormatType::Optimal); + graphics_queue = logical.GetQueue(graphics_family); present_queue = logical.GetQueue(present_family); } 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: return sets_per_pool; } + bool SupportsD24DepthBuffer() const { + return supports_d24_depth; + } + private: /// Checks if the physical device is suitable. void CheckSuitability(bool requires_swapchain) const; @@ -419,6 +423,7 @@ private: bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. bool has_renderdoc{}; ///< Has RenderDoc attached bool has_nsight_graphics{}; ///< Has Nsight Graphics attached + bool supports_d24_depth{}; ///< Supports D24 depth buffers. // Telemetry parameters std::string vendor_name; ///< Device's driver name. |