diff options
| author | 2023-07-31 19:11:24 -0400 | |
|---|---|---|
| committer | 2023-07-31 19:14:20 -0400 | |
| commit | d31676935e0842680e37a4e5005f0ee8d66021fd (patch) | |
| tree | 8f5673b5b5136b6ff6fa6062cbe9da90edefd876 /src | |
| parent | vulkan_device: Return true if either depth/stencil format supports blit (diff) | |
| download | yuzu-d31676935e0842680e37a4e5005f0ee8d66021fd.tar.gz yuzu-d31676935e0842680e37a4e5005f0ee8d66021fd.tar.xz yuzu-d31676935e0842680e37a4e5005f0ee8d66021fd.zip | |
vulkan_device: Test depth stencil blit support by format
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 52 |
3 files changed, 47 insertions, 29 deletions
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index bf6ad6c79..ed048f7b8 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1043,15 +1043,27 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst | |||
| 1043 | dst_region, src_region, filter, operation); | 1043 | dst_region, src_region, filter, operation); |
| 1044 | return; | 1044 | return; |
| 1045 | } | 1045 | } |
| 1046 | ASSERT(src.format == dst.format); | ||
| 1046 | if (aspect_mask == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { | 1047 | if (aspect_mask == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 1047 | if (!device.IsBlitDepthStencilSupported()) { | 1048 | const auto format = src.format; |
| 1049 | const auto can_blit_depth_stencil = [this, format] { | ||
| 1050 | switch (format) { | ||
| 1051 | case VideoCore::Surface::PixelFormat::D24_UNORM_S8_UINT: | ||
| 1052 | case VideoCore::Surface::PixelFormat::S8_UINT_D24_UNORM: | ||
| 1053 | return device.IsBlitDepth24Stencil8Supported(); | ||
| 1054 | case VideoCore::Surface::PixelFormat::D32_FLOAT_S8_UINT: | ||
| 1055 | return device.IsBlitDepth32Stencil8Supported(); | ||
| 1056 | default: | ||
| 1057 | UNREACHABLE(); | ||
| 1058 | } | ||
| 1059 | }(); | ||
| 1060 | if (!can_blit_depth_stencil) { | ||
| 1048 | UNIMPLEMENTED_IF(is_src_msaa || is_dst_msaa); | 1061 | UNIMPLEMENTED_IF(is_src_msaa || is_dst_msaa); |
| 1049 | blit_image_helper.BlitDepthStencil(dst_framebuffer, src.DepthView(), src.StencilView(), | 1062 | blit_image_helper.BlitDepthStencil(dst_framebuffer, src.DepthView(), src.StencilView(), |
| 1050 | dst_region, src_region, filter, operation); | 1063 | dst_region, src_region, filter, operation); |
| 1051 | return; | 1064 | return; |
| 1052 | } | 1065 | } |
| 1053 | } | 1066 | } |
| 1054 | ASSERT(src.format == dst.format); | ||
| 1055 | ASSERT(!(is_dst_msaa && !is_src_msaa)); | 1067 | ASSERT(!(is_dst_msaa && !is_src_msaa)); |
| 1056 | ASSERT(operation == Fermi2D::Operation::SrcCopy); | 1068 | ASSERT(operation == Fermi2D::Operation::SrcCopy); |
| 1057 | 1069 | ||
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index f84c1e00c..e44c06e55 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -376,7 +376,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 376 | first_next = &diagnostics_nv; | 376 | first_next = &diagnostics_nv; |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | is_blit_depth_stencil_supported = TestDepthStencilBlits(); | 379 | is_blit_depth24_stencil8_supported = TestDepthStencilBlits(VK_FORMAT_D24_UNORM_S8_UINT); |
| 380 | is_blit_depth32_stencil8_supported = TestDepthStencilBlits(VK_FORMAT_D32_SFLOAT_S8_UINT); | ||
| 380 | is_optimal_astc_supported = ComputeIsOptimalAstcSupported(); | 381 | is_optimal_astc_supported = ComputeIsOptimalAstcSupported(); |
| 381 | is_warp_potentially_bigger = !extensions.subgroup_size_control || | 382 | is_warp_potentially_bigger = !extensions.subgroup_size_control || |
| 382 | properties.subgroup_size_control.maxSubgroupSize > GuestWarpSize; | 383 | properties.subgroup_size_control.maxSubgroupSize > GuestWarpSize; |
| @@ -739,14 +740,13 @@ bool Device::ComputeIsOptimalAstcSupported() const { | |||
| 739 | return true; | 740 | return true; |
| 740 | } | 741 | } |
| 741 | 742 | ||
| 742 | bool Device::TestDepthStencilBlits() const { | 743 | bool Device::TestDepthStencilBlits(VkFormat format) const { |
| 743 | static constexpr VkFormatFeatureFlags required_features = | 744 | static constexpr VkFormatFeatureFlags required_features = |
| 744 | VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT; | 745 | VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT; |
| 745 | const auto test_features = [](VkFormatProperties props) { | 746 | const auto test_features = [](VkFormatProperties props) { |
| 746 | return (props.optimalTilingFeatures & required_features) == required_features; | 747 | return (props.optimalTilingFeatures & required_features) == required_features; |
| 747 | }; | 748 | }; |
| 748 | return test_features(format_properties.at(VK_FORMAT_D32_SFLOAT_S8_UINT)) || | 749 | return test_features(format_properties.at(format)); |
| 749 | test_features(format_properties.at(VK_FORMAT_D24_UNORM_S8_UINT)); | ||
| 750 | } | 750 | } |
| 751 | 751 | ||
| 752 | bool Device::IsFormatSupported(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, | 752 | bool Device::IsFormatSupported(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index be3ed45ff..80c38bfad 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -359,9 +359,14 @@ public: | |||
| 359 | return features.features.depthBounds; | 359 | return features.features.depthBounds; |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | /// Returns true when blitting from and to depth stencil images is supported. | 362 | /// Returns true when blitting from and to D24S8 images is supported. |
| 363 | bool IsBlitDepthStencilSupported() const { | 363 | bool IsBlitDepth24Stencil8Supported() const { |
| 364 | return is_blit_depth_stencil_supported; | 364 | return is_blit_depth24_stencil8_supported; |
| 365 | } | ||
| 366 | |||
| 367 | /// Returns true when blitting from and to D32S8 images is supported. | ||
| 368 | bool IsBlitDepth32Stencil8Supported() const { | ||
| 369 | return is_blit_depth32_stencil8_supported; | ||
| 365 | } | 370 | } |
| 366 | 371 | ||
| 367 | /// Returns true if the device supports VK_NV_viewport_swizzle. | 372 | /// Returns true if the device supports VK_NV_viewport_swizzle. |
| @@ -657,7 +662,7 @@ private: | |||
| 657 | bool ComputeIsOptimalAstcSupported() const; | 662 | bool ComputeIsOptimalAstcSupported() const; |
| 658 | 663 | ||
| 659 | /// Returns true if the device natively supports blitting depth stencil images. | 664 | /// Returns true if the device natively supports blitting depth stencil images. |
| 660 | bool TestDepthStencilBlits() const; | 665 | bool TestDepthStencilBlits(VkFormat format) const; |
| 661 | 666 | ||
| 662 | private: | 667 | private: |
| 663 | VkInstance instance; ///< Vulkan instance. | 668 | VkInstance instance; ///< Vulkan instance. |
| @@ -721,25 +726,26 @@ private: | |||
| 721 | VkPhysicalDeviceProperties2 properties2{}; | 726 | VkPhysicalDeviceProperties2 properties2{}; |
| 722 | 727 | ||
| 723 | // Misc features | 728 | // Misc features |
| 724 | bool is_optimal_astc_supported{}; ///< Support for all guest ASTC formats. | 729 | bool is_optimal_astc_supported{}; ///< Support for all guest ASTC formats. |
| 725 | bool is_blit_depth_stencil_supported{}; ///< Support for blitting from and to depth stencil. | 730 | bool is_blit_depth24_stencil8_supported{}; ///< Support for blitting from and to D24S8. |
| 726 | bool is_warp_potentially_bigger{}; ///< Host warp size can be bigger than guest. | 731 | bool is_blit_depth32_stencil8_supported{}; ///< Support for blitting from and to D32S8. |
| 727 | bool is_integrated{}; ///< Is GPU an iGPU. | 732 | bool is_warp_potentially_bigger{}; ///< Host warp size can be bigger than guest. |
| 728 | bool is_virtual{}; ///< Is GPU a virtual GPU. | 733 | bool is_integrated{}; ///< Is GPU an iGPU. |
| 729 | bool is_non_gpu{}; ///< Is SoftwareRasterizer, FPGA, non-GPU device. | 734 | bool is_virtual{}; ///< Is GPU a virtual GPU. |
| 730 | bool has_broken_compute{}; ///< Compute shaders can cause crashes | 735 | bool is_non_gpu{}; ///< Is SoftwareRasterizer, FPGA, non-GPU device. |
| 731 | bool has_broken_cube_compatibility{}; ///< Has broken cube compatibility bit | 736 | bool has_broken_compute{}; ///< Compute shaders can cause crashes |
| 732 | bool has_renderdoc{}; ///< Has RenderDoc attached | 737 | bool has_broken_cube_compatibility{}; ///< Has broken cube compatibility bit |
| 733 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached | 738 | bool has_renderdoc{}; ///< Has RenderDoc attached |
| 734 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. | 739 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached |
| 735 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. | 740 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. |
| 736 | bool must_emulate_scaled_formats{}; ///< Requires scaled vertex format emulation | 741 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. |
| 737 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. | 742 | bool must_emulate_scaled_formats{}; ///< Requires scaled vertex format emulation |
| 738 | bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. | 743 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. |
| 739 | bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. | 744 | bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. |
| 740 | bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. | 745 | bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. |
| 741 | u64 device_access_memory{}; ///< Total size of device local memory in bytes. | 746 | bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. |
| 742 | u32 sets_per_pool{}; ///< Sets per Description Pool | 747 | u64 device_access_memory{}; ///< Total size of device local memory in bytes. |
| 748 | u32 sets_per_pool{}; ///< Sets per Description Pool | ||
| 743 | 749 | ||
| 744 | // Telemetry parameters | 750 | // Telemetry parameters |
| 745 | std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions. | 751 | std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions. |