VulkanDevice: Enable VK_KHR_maintenance4 and 5

This commit is contained in:
Stenzek 2024-08-10 12:33:01 +10:00
parent 010c7dea33
commit 34df233a95
No known key found for this signature in database
3 changed files with 47 additions and 23 deletions

View file

@ -507,6 +507,14 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
#endif #endif
} }
// Don't bother checking for maintenance 4/5 if we don't have 1-3, i.e. Vulkan 1.1.
if (m_device_properties.apiVersion >= VK_API_VERSION_1_1)
{
m_optional_extensions.vk_khr_maintenance4 = SupportsExtension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME, false);
m_optional_extensions.vk_khr_maintenance5 =
m_optional_extensions.vk_khr_maintenance4 && SupportsExtension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME, false);
}
return true; return true;
} }
@ -708,6 +716,8 @@ void VulkanDevice::ProcessDeviceExtensions()
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT, nullptr, VK_FALSE}; VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT, nullptr, VK_FALSE};
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragment_shader_interlock_feature = { VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragment_shader_interlock_feature = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT, nullptr, VK_FALSE, VK_FALSE, VK_FALSE}; VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT, nullptr, VK_FALSE, VK_FALSE, VK_FALSE};
VkPhysicalDeviceMaintenance4Features maintenance4_features = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, nullptr, VK_FALSE};
// add in optional feature structs // add in optional feature structs
if (m_optional_extensions.vk_ext_rasterization_order_attachment_access) if (m_optional_extensions.vk_ext_rasterization_order_attachment_access)
@ -722,6 +732,8 @@ void VulkanDevice::ProcessDeviceExtensions()
if (m_optional_extensions.vk_ext_fragment_shader_interlock) if (m_optional_extensions.vk_ext_fragment_shader_interlock)
Vulkan::AddPointerToChain(&features2, &fragment_shader_interlock_feature); Vulkan::AddPointerToChain(&features2, &fragment_shader_interlock_feature);
} }
if (m_optional_extensions.vk_khr_maintenance5)
Vulkan::AddPointerToChain(&features2, &maintenance4_features);
// we might not have VK_KHR_get_physical_device_properties2... // we might not have VK_KHR_get_physical_device_properties2...
if (!vkGetPhysicalDeviceFeatures2 || !vkGetPhysicalDeviceProperties2 || !vkGetPhysicalDeviceMemoryProperties2) if (!vkGetPhysicalDeviceFeatures2 || !vkGetPhysicalDeviceProperties2 || !vkGetPhysicalDeviceMemoryProperties2)
@ -758,6 +770,8 @@ void VulkanDevice::ProcessDeviceExtensions()
m_optional_extensions.vk_ext_fragment_shader_interlock &= m_optional_extensions.vk_ext_fragment_shader_interlock &=
(m_optional_extensions.vk_khr_dynamic_rendering && (m_optional_extensions.vk_khr_dynamic_rendering &&
fragment_shader_interlock_feature.fragmentShaderPixelInterlock == VK_TRUE); fragment_shader_interlock_feature.fragmentShaderPixelInterlock == VK_TRUE);
m_optional_extensions.vk_khr_maintenance4 &= (maintenance4_features.maintenance4 == VK_TRUE);
m_optional_extensions.vk_khr_maintenance5 &= m_optional_extensions.vk_khr_maintenance4;
VkPhysicalDeviceProperties2 properties2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, nullptr, {}}; VkPhysicalDeviceProperties2 properties2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, nullptr, {}};
VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_properties = { VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_properties = {
@ -786,28 +800,24 @@ void VulkanDevice::ProcessDeviceExtensions()
m_optional_extensions.vk_ext_external_memory_host &= m_optional_extensions.vk_ext_external_memory_host &=
(external_memory_host_properties.minImportedHostPointerAlignment == HOST_PAGE_SIZE); (external_memory_host_properties.minImportedHostPointerAlignment == HOST_PAGE_SIZE);
INFO_LOG("VK_EXT_external_memory_host is {}", #define LOG_EXT(name, field) INFO_LOG(name " is {}", m_optional_extensions.field ? "supported" : "NOT supported")
m_optional_extensions.vk_ext_external_memory_host ? "supported" : "NOT supported");
INFO_LOG("VK_EXT_memory_budget is {}", m_optional_extensions.vk_ext_memory_budget ? "supported" : "NOT supported"); LOG_EXT("VK_EXT_external_memory_host", vk_ext_external_memory_host);
INFO_LOG("VK_EXT_fragment_shader_interlock is {}", LOG_EXT("VK_EXT_memory_budget", vk_ext_memory_budget);
m_optional_extensions.vk_ext_fragment_shader_interlock ? "supported" : "NOT supported"); LOG_EXT("VK_EXT_fragment_shader_interlock", vk_ext_fragment_shader_interlock);
INFO_LOG("VK_EXT_rasterization_order_attachment_access is {}", LOG_EXT("VK_EXT_rasterization_order_attachment_access", vk_ext_rasterization_order_attachment_access);
m_optional_extensions.vk_ext_rasterization_order_attachment_access ? "supported" : "NOT supported"); LOG_EXT("VK_EXT_swapchain_maintenance1", vk_ext_swapchain_maintenance1);
INFO_LOG("VK_EXT_swapchain_maintenance1 is {}", LOG_EXT("VK_KHR_get_memory_requirements2", vk_khr_get_memory_requirements2);
m_optional_extensions.vk_ext_swapchain_maintenance1 ? "supported" : "NOT supported"); LOG_EXT("VK_KHR_bind_memory2", vk_khr_bind_memory2);
INFO_LOG("VK_KHR_get_memory_requirements2 is {}", LOG_EXT("VK_KHR_get_physical_device_properties2", vk_khr_get_physical_device_properties2);
m_optional_extensions.vk_khr_get_memory_requirements2 ? "supported" : "NOT supported"); LOG_EXT("VK_KHR_dedicated_allocation", vk_khr_dedicated_allocation);
INFO_LOG("VK_KHR_bind_memory2 is {}", m_optional_extensions.vk_khr_bind_memory2 ? "supported" : "NOT supported"); LOG_EXT("VK_KHR_dynamic_rendering", vk_khr_dynamic_rendering);
INFO_LOG("VK_KHR_get_physical_device_properties2 is {}", LOG_EXT("VK_KHR_dynamic_rendering_local_read", vk_khr_dynamic_rendering_local_read);
m_optional_extensions.vk_khr_get_physical_device_properties2 ? "supported" : "NOT supported"); LOG_EXT("VK_KHR_maintenance4", vk_khr_maintenance4);
INFO_LOG("VK_KHR_dedicated_allocation is {}", LOG_EXT("VK_KHR_maintenance4", vk_khr_maintenance5);
m_optional_extensions.vk_khr_dedicated_allocation ? "supported" : "NOT supported"); LOG_EXT("VK_KHR_push_descriptor", vk_khr_push_descriptor);
INFO_LOG("VK_KHR_dynamic_rendering is {}",
m_optional_extensions.vk_khr_dynamic_rendering ? "supported" : "NOT supported"); #undef LOG_EXT
INFO_LOG("VK_KHR_dynamic_rendering_local_read is {}",
m_optional_extensions.vk_khr_dynamic_rendering_local_read ? "supported" : "NOT supported");
INFO_LOG("VK_KHR_push_descriptor is {}",
m_optional_extensions.vk_khr_push_descriptor ? "supported" : "NOT supported");
} }
bool VulkanDevice::CreateAllocator() bool VulkanDevice::CreateAllocator()
@ -845,6 +855,18 @@ bool VulkanDevice::CreateAllocator()
ci.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT; ci.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
} }
if (m_optional_extensions.vk_khr_maintenance4)
{
DEV_LOG("Enabling VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT");
ci.flags |= VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT;
}
if (m_optional_extensions.vk_khr_maintenance5)
{
DEV_LOG("Enabling VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT");
ci.flags |= VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT;
}
// Limit usage of the DEVICE_LOCAL upload heap when we're using a debug device. // Limit usage of the DEVICE_LOCAL upload heap when we're using a debug device.
// On NVIDIA drivers, it results in frequently running out of device memory when trying to // On NVIDIA drivers, it results in frequently running out of device memory when trying to
// play back captures in RenderDoc, making life very painful. Re-BAR GPUs should be fine. // play back captures in RenderDoc, making life very painful. Re-BAR GPUs should be fine.

View file

@ -57,6 +57,8 @@ public:
bool vk_khr_driver_properties : 1; bool vk_khr_driver_properties : 1;
bool vk_khr_dynamic_rendering : 1; bool vk_khr_dynamic_rendering : 1;
bool vk_khr_dynamic_rendering_local_read : 1; bool vk_khr_dynamic_rendering_local_read : 1;
bool vk_khr_maintenance4 : 1;
bool vk_khr_maintenance5 : 1;
bool vk_khr_push_descriptor : 1; bool vk_khr_push_descriptor : 1;
bool vk_khr_shader_non_semantic_info : 1; bool vk_khr_shader_non_semantic_info : 1;
}; };

View file

@ -84,7 +84,7 @@ class Error;
#endif #endif
#define VMA_STATIC_VULKAN_FUNCTIONS 1 #define VMA_STATIC_VULKAN_FUNCTIONS 1
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
#define VMA_STATS_STRING_ENABLED 0 #define VMA_STATS_STRING_ENABLED 0
#include "vulkan/vk_mem_alloc.h" #include "vulkan/vk_mem_alloc.h"