diff options
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/vulkan13_features.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/runtime/src/vulkan13_features.h b/runtime/src/vulkan13_features.h index e86ec02a2..ea65caa2d 100644 --- a/runtime/src/vulkan13_features.h +++ b/runtime/src/vulkan13_features.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | bool core = false; // a Vulkan 1.3 device: the features are core | 34 | bool core = false; // a Vulkan 1.3 device: the features are core |
| 35 | bool dynamic_rendering = false; // supported, as a core feature or through VK_KHR_dynamic_rendering | 35 | bool dynamic_rendering = false; // supported, as a core feature or through VK_KHR_dynamic_rendering |
| 36 | bool synchronization2 = false; // supported, as a core feature or through VK_KHR_synchronization2 | 36 | bool synchronization2 = false; // supported, as a core feature or through VK_KHR_synchronization2 |
| 37 | // Optional 1.3 core features, enabled where supported; on a 1.2 device they stay off (no required subgroup size). | 37 | // Optional 1.3 core features, available through VK_EXT_subgroup_size_control on a 1.2 device. |
| 38 | bool subgroup_size_control = false; | 38 | bool subgroup_size_control = false; |
| 39 | bool compute_full_subgroups = false; | 39 | bool compute_full_subgroups = false; |
| 40 | bool extended_dynamic_state = false; // core on 1.3; on 1.2 both VK_EXT_extended_dynamic_state(2) extensions | 40 | bool extended_dynamic_state = false; // core on 1.3; on 1.2 both VK_EXT_extended_dynamic_state(2) extensions |
| @@ -65,11 +65,13 @@ public: | |||
| 65 | std::vector<VkExtensionProperties> extensions(count); | 65 | std::vector<VkExtensionProperties> extensions(count); |
| 66 | enumerate_extensions(physical, nullptr, &count, extensions.data()); | 66 | enumerate_extensions(physical, nullptr, &count, extensions.data()); |
| 67 | bool has_dynamic_rendering = false, has_synchronization2 = false, has_eds = false, has_eds2 = false; | 67 | bool has_dynamic_rendering = false, has_synchronization2 = false, has_eds = false, has_eds2 = false; |
| 68 | bool has_subgroup_control = false; | ||
| 68 | for (const auto& e : extensions) { | 69 | for (const auto& e : extensions) { |
| 69 | has_dynamic_rendering |= std::strcmp(e.extensionName, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME) == 0; | 70 | has_dynamic_rendering |= std::strcmp(e.extensionName, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME) == 0; |
| 70 | has_synchronization2 |= std::strcmp(e.extensionName, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME) == 0; | 71 | has_synchronization2 |= std::strcmp(e.extensionName, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME) == 0; |
| 71 | has_eds |= std::strcmp(e.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) == 0; | 72 | has_eds |= std::strcmp(e.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) == 0; |
| 72 | has_eds2 |= std::strcmp(e.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) == 0; | 73 | has_eds2 |= std::strcmp(e.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) == 0; |
| 74 | has_subgroup_control |= std::strcmp(e.extensionName, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME) == 0; | ||
| 73 | } | 75 | } |
| 74 | if (!has_dynamic_rendering || !has_synchronization2) return; | 76 | if (!has_dynamic_rendering || !has_synchronization2) return; |
| 75 | VkPhysicalDeviceExtendedDynamicState2FeaturesEXT eds2{ | 77 | VkPhysicalDeviceExtendedDynamicState2FeaturesEXT eds2{ |
| @@ -78,12 +80,17 @@ public: | |||
| 78 | has_eds2 ? &eds2 : nullptr}; | 80 | has_eds2 ? &eds2 : nullptr}; |
| 79 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR, | 81 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR, |
| 80 | has_eds ? &eds : nullptr}; | 82 | has_eds ? &eds : nullptr}; |
| 83 | VkPhysicalDeviceSubgroupSizeControlFeaturesEXT sg{ | ||
| 84 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT, &sync2}; | ||
| 81 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering{ | 85 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering{ |
| 82 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR, &sync2}; | 86 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR, &sync2}; |
| 87 | if (has_subgroup_control) rendering.pNext = &sg; | ||
| 83 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &rendering}; | 88 | VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &rendering}; |
| 84 | features2(physical, &query); | 89 | features2(physical, &query); |
| 85 | dynamic_rendering = rendering.dynamicRendering == VK_TRUE; | 90 | dynamic_rendering = rendering.dynamicRendering == VK_TRUE; |
| 86 | synchronization2 = sync2.synchronization2 == VK_TRUE; | 91 | synchronization2 = sync2.synchronization2 == VK_TRUE; |
| 92 | subgroup_size_control = has_subgroup_control && sg.subgroupSizeControl == VK_TRUE; | ||
| 93 | compute_full_subgroups = subgroup_size_control && sg.computeFullSubgroups == VK_TRUE; | ||
| 87 | extended_dynamic_state = has_eds && has_eds2 && eds.extendedDynamicState == VK_TRUE && | 94 | extended_dynamic_state = has_eds && has_eds2 && eds.extendedDynamicState == VK_TRUE && |
| 88 | eds2.extendedDynamicState2 == VK_TRUE; | 95 | eds2.extendedDynamicState2 == VK_TRUE; |
| 89 | } | 96 | } |
| @@ -109,6 +116,12 @@ public: | |||
| 109 | enable13_.computeFullSubgroups = compute_full_subgroups ? VK_TRUE : VK_FALSE; | 116 | enable13_.computeFullSubgroups = compute_full_subgroups ? VK_TRUE : VK_FALSE; |
| 110 | return &enable13_; | 117 | return &enable13_; |
| 111 | } | 118 | } |
| 119 | if (subgroup_size_control) { | ||
| 120 | sg_.pNext = chain; | ||
| 121 | sg_.subgroupSizeControl = VK_TRUE; | ||
| 122 | sg_.computeFullSubgroups = compute_full_subgroups ? VK_TRUE : VK_FALSE; | ||
| 123 | chain = &sg_; | ||
| 124 | } | ||
| 112 | sync2_.pNext = chain; | 125 | sync2_.pNext = chain; |
| 113 | sync2_.synchronization2 = VK_TRUE; | 126 | sync2_.synchronization2 = VK_TRUE; |
| 114 | if (extended_dynamic_state) { | 127 | if (extended_dynamic_state) { |
| @@ -124,13 +137,18 @@ public: | |||
| 124 | } | 137 | } |
| 125 | 138 | ||
| 126 | // Where a feature struct goes to follow these: insert with `s.pNext = *next(); *next() = &s;`. | 139 | // Where a feature struct goes to follow these: insert with `s.pNext = *next(); *next() = &s;`. |
| 127 | void** next() { return core ? &enable13_.pNext : extended_dynamic_state ? &eds2_.pNext : &sync2_.pNext; } | 140 | void** next() { |
| 141 | if (core) return &enable13_.pNext; | ||
| 142 | if (subgroup_size_control) return &sg_.pNext; | ||
| 143 | return extended_dynamic_state ? &eds2_.pNext : &sync2_.pNext; | ||
| 144 | } | ||
| 128 | 145 | ||
| 129 | // The device extensions a 1.2 device needs for both features; none on 1.3. | 146 | // The device extensions a 1.2 device needs for both features; none on 1.3. |
| 130 | void add_extensions(std::vector<const char*>& extensions) const { | 147 | void add_extensions(std::vector<const char*>& extensions) const { |
| 131 | if (core) return; | 148 | if (core) return; |
| 132 | extensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); | 149 | extensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); |
| 133 | extensions.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); | 150 | extensions.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); |
| 151 | if (subgroup_size_control) extensions.push_back(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME); | ||
| 134 | if (!extended_dynamic_state) return; | 152 | if (!extended_dynamic_state) return; |
| 135 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | 153 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); |
| 136 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); | 154 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); |
| @@ -141,6 +159,8 @@ private: | |||
| 141 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR}; | 159 | VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR}; |
| 142 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR}; | 160 | VkPhysicalDeviceSynchronization2FeaturesKHR sync2_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR}; |
| 143 | VkPhysicalDeviceExtendedDynamicStateFeaturesEXT eds_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT}; | 161 | VkPhysicalDeviceExtendedDynamicStateFeaturesEXT eds_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT}; |
| 162 | VkPhysicalDeviceSubgroupSizeControlFeaturesEXT sg_{ | ||
| 163 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT}; | ||
| 144 | VkPhysicalDeviceExtendedDynamicState2FeaturesEXT eds2_{ | 164 | VkPhysicalDeviceExtendedDynamicState2FeaturesEXT eds2_{ |
| 145 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT}; | 165 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT}; |
| 146 | }; | 166 | }; |