From e844e0c90d5fc89a848dc74993c990988c521595 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 19 May 2025 14:43:55 +0200 Subject: [PATCH] Vulkan: Enable robustness2 null descriptors This change will enable VK_EXT_robustness2.nullDescriptors feature. It will be able to guarantee that shaders run even when some resources are not attached. There should not be any difference with before as this feature is often the default behavior of GPUs. However it makes the intent more explicit that failing allocations can still run similar to OpenGL. It is expected that some tweaks are needed in Vulkan backend. Pull Request: https://projects.blender.org/blender/blender/pulls/139090 --- intern/ghost/intern/GHOST_ContextVK.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/intern/ghost/intern/GHOST_ContextVK.cc b/intern/ghost/intern/GHOST_ContextVK.cc index 61e8f3bcdd7..34e227cd93f 100644 --- a/intern/ghost/intern/GHOST_ContextVK.cc +++ b/intern/ghost/intern/GHOST_ContextVK.cc @@ -137,6 +137,8 @@ class GHOST_DeviceVK { VkPhysicalDeviceFeatures2 features = {}; VkPhysicalDeviceVulkan11Features features_11 = {}; VkPhysicalDeviceVulkan12Features features_12 = {}; + VkPhysicalDeviceRobustness2FeaturesEXT features_robustness2 = { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; int users = 0; @@ -156,6 +158,7 @@ class GHOST_DeviceVK { features_12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; features.pNext = &features_11; features_11.pNext = &features_12; + features_12.pNext = &features_robustness2; vkGetPhysicalDeviceFeatures2(physical_device, &features); } @@ -308,6 +311,15 @@ class GHOST_DeviceVK { device_create_info_p_next = &dynamic_rendering_local_read; } + /* VK_EXT_robustness2 */ + VkPhysicalDeviceRobustness2FeaturesEXT robustness_2_features = { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; + if (has_extensions({VK_EXT_ROBUSTNESS_2_EXTENSION_NAME})) { + robustness_2_features.nullDescriptor = features_robustness2.nullDescriptor; + robustness_2_features.pNext = device_create_info_p_next; + device_create_info_p_next = &robustness_2_features; + } + /* Query for Mainenance4 (core in Vulkan 1.3). */ VkPhysicalDeviceMaintenance4FeaturesKHR maintenance_4 = {}; maintenance_4.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR; @@ -1131,6 +1143,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() optional_device_extensions.push_back(VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME); optional_device_extensions.push_back(VK_KHR_MAINTENANCE_4_EXTENSION_NAME); optional_device_extensions.push_back(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); + optional_device_extensions.push_back(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME); VkInstance instance = VK_NULL_HANDLE; if (!vulkan_device.has_value()) {