From 7cbe1fb694e37f98b4271471a34dcd9b88a9253c Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Tue, 7 Apr 2026 02:59:11 -0400 Subject: [PATCH] [vulkan] Refined handling for Maintenance features --- .../renderer_vulkan/vk_texture_cache.cpp | 14 +++++++++++ src/video_core/vulkan_common/vulkan.h | 5 +--- .../vulkan_common/vulkan_device.cpp | 25 ++++--------------- src/video_core/vulkan_common/vulkan_device.h | 6 ----- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index d51564dcb3..48aa5ec476 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -275,6 +275,19 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { return VK_COMPONENT_SWIZZLE_ZERO; } +void SanitizeDepthStencilSwizzle(std::array& swizzle, + bool supports_depth_stencil_swizzle_one) { + if (supports_depth_stencil_swizzle_one) { + return; + } + std::replace_if(swizzle.begin(), swizzle.end(), + [](SwizzleSource value) { + return value == SwizzleSource::OneFloat || + value == SwizzleSource::OneInt; + }, + SwizzleSource::Zero); +} + [[nodiscard]] VkImageViewType ImageViewType(Shader::TextureType type) { switch (type) { case Shader::TextureType::Color1D: @@ -2109,6 +2122,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI !device->IsExt4444FormatsSupported()); if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) { std::ranges::transform(swizzle, swizzle.begin(), ConvertGreenRed); + SanitizeDepthStencilSwizzle(swizzle, device->SupportsDepthStencilSwizzleOne()); } } const auto format_info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format); diff --git a/src/video_core/vulkan_common/vulkan.h b/src/video_core/vulkan_common/vulkan.h index 2cc0f0d7f0..2609e8dc0f 100644 --- a/src/video_core/vulkan_common/vulkan.h +++ b/src/video_core/vulkan_common/vulkan.h @@ -22,16 +22,13 @@ #include -// Define maintenance 7-9 extension names (not yet in official Vulkan headers) +// Define maintenance 7-8 extension names (not yet in official Vulkan headers) #ifndef VK_KHR_MAINTENANCE_7_EXTENSION_NAME #define VK_KHR_MAINTENANCE_7_EXTENSION_NAME "VK_KHR_maintenance7" #endif #ifndef VK_KHR_MAINTENANCE_8_EXTENSION_NAME #define VK_KHR_MAINTENANCE_8_EXTENSION_NAME "VK_KHR_maintenance8" #endif -#ifndef VK_KHR_MAINTENANCE_9_EXTENSION_NAME -#define VK_KHR_MAINTENANCE_9_EXTENSION_NAME "VK_KHR_maintenance9" -#endif // Sanitize macros #undef CreateEvent diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 9a291a0440..2fa652406b 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -1352,15 +1352,15 @@ void Device::RemoveUnsuitableExtensions() { features.workgroup_memory_explicit_layout, VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME); - // VK_KHR_maintenance1 (core in Vulkan 1.1, no features) + // VK_KHR_maintenance1 extensions.maintenance1 = loaded_extensions.contains(VK_KHR_MAINTENANCE_1_EXTENSION_NAME); RemoveExtensionIfUnsuitable(extensions.maintenance1, VK_KHR_MAINTENANCE_1_EXTENSION_NAME); - // VK_KHR_maintenance2 (core in Vulkan 1.1, no features) + // VK_KHR_maintenance2 extensions.maintenance2 = loaded_extensions.contains(VK_KHR_MAINTENANCE_2_EXTENSION_NAME); RemoveExtensionIfUnsuitable(extensions.maintenance2, VK_KHR_MAINTENANCE_2_EXTENSION_NAME); - // VK_KHR_maintenance3 (core in Vulkan 1.1, no features) + // VK_KHR_maintenance3 extensions.maintenance3 = loaded_extensions.contains(VK_KHR_MAINTENANCE_3_EXTENSION_NAME); RemoveExtensionIfUnsuitable(extensions.maintenance3, VK_KHR_MAINTENANCE_3_EXTENSION_NAME); @@ -1371,17 +1371,6 @@ void Device::RemoveUnsuitableExtensions() { // VK_KHR_maintenance5 extensions.maintenance5 = features.maintenance5.maintenance5; - - if (extensions.maintenance5) { - LOG_INFO(Render_Vulkan, "VK_KHR_maintenance5 properties: polygonModePointSize={} " - "depthStencilSwizzleOne={} earlyFragmentTests={} nonStrictWideLines={}", - properties.maintenance5.polygonModePointSize, - properties.maintenance5.depthStencilSwizzleOneSupport, - properties.maintenance5.earlyFragmentMultisampleCoverageAfterSampleCounting && - properties.maintenance5.earlyFragmentSampleMaskTestBeforeSampleCounting, - properties.maintenance5.nonStrictWideLinesUseParallelogram); - } - RemoveExtensionFeatureIfUnsuitable(extensions.maintenance5, features.maintenance5, VK_KHR_MAINTENANCE_5_EXTENSION_NAME); @@ -1390,17 +1379,13 @@ void Device::RemoveUnsuitableExtensions() { RemoveExtensionFeatureIfUnsuitable(extensions.maintenance6, features.maintenance6, VK_KHR_MAINTENANCE_6_EXTENSION_NAME); - // VK_KHR_maintenance7 (proposed for Vulkan 1.4, no features) + // VK_KHR_maintenance7 extensions.maintenance7 = loaded_extensions.contains(VK_KHR_MAINTENANCE_7_EXTENSION_NAME); RemoveExtensionIfUnsuitable(extensions.maintenance7, VK_KHR_MAINTENANCE_7_EXTENSION_NAME); - // VK_KHR_maintenance8 (proposed for Vulkan 1.4, no features) + // VK_KHR_maintenance8 extensions.maintenance8 = loaded_extensions.contains(VK_KHR_MAINTENANCE_8_EXTENSION_NAME); RemoveExtensionIfUnsuitable(extensions.maintenance8, VK_KHR_MAINTENANCE_8_EXTENSION_NAME); - - // VK_KHR_maintenance9 (proposed for Vulkan 1.4, no features) - extensions.maintenance9 = loaded_extensions.contains(VK_KHR_MAINTENANCE_9_EXTENSION_NAME); - RemoveExtensionIfUnsuitable(extensions.maintenance9, VK_KHR_MAINTENANCE_9_EXTENSION_NAME); } void Device::SetupFamilies(VkSurfaceKHR surface) { diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index be106d6962..f01a01198e 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -99,7 +99,6 @@ VK_DEFINE_HANDLE(VmaAllocator) EXTENSION(KHR, MAINTENANCE_3, maintenance3) \ EXTENSION(KHR, MAINTENANCE_7, maintenance7) \ EXTENSION(KHR, MAINTENANCE_8, maintenance8) \ - EXTENSION(KHR, MAINTENANCE_9, maintenance9) \ EXTENSION(NV, DEVICE_DIAGNOSTICS_CONFIG, device_diagnostics_config) \ EXTENSION(NV, GEOMETRY_SHADER_PASSTHROUGH, geometry_shader_passthrough) \ EXTENSION(NV, VIEWPORT_ARRAY2, viewport_array2) \ @@ -903,11 +902,6 @@ public: return extensions.maintenance8; } - /// Returns true if the device supports VK_KHR_maintenance9. - bool IsKhrMaintenance9Supported() const { - return extensions.maintenance9; - } - /// Returns true if the device supports UINT8 index buffer conversion via compute shader. bool SupportsUint8Indices() const { return features.bit8_storage.storageBuffer8BitAccess &&