Vulkan: Make Maintenance4 Extension Optional #113239

Merged
Jeroen Bakker merged 3 commits from Jeroen-Bakker/blender:vulkan/extension-maintenance4 into main 2023-10-05 13:40:36 +02:00
1 changed files with 4 additions and 11 deletions
Showing only changes of commit da676c0127 - Show all commits

View File

@ -179,7 +179,7 @@ class GHOST_DeviceVK {
}
}
bool support_extensions(const vector<const char *> &required_extensions)
bool has_extensions(const vector<const char *> &required_extensions)
{
uint32_t ext_count;
vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, nullptr);
@ -203,13 +203,6 @@ class GHOST_DeviceVK {
return true;
}
bool supports_extension(const char *requested_extension)
{
std::vector<const char *> requested_extensions;
requested_extensions.push_back(requested_extension);
return support_extensions(requested_extensions);
}
void ensure_device(vector<const char *> &layers_enabled, vector<const char *> &extensions_device)
{
if (device != VK_NULL_HANDLE) {
@ -247,7 +240,7 @@ class GHOST_DeviceVK {
maintenance_4.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR;
maintenance_4.maintenance4 = VK_TRUE;
/* Mainenance4 is core in Vulkan 1.3 so we need to query for availability. */
if (supports_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME)) {
if (has_extensions({VK_KHR_MAINTENANCE_4_EXTENSION_NAME})) {
maintenance_4.pNext = device_12_features.pNext;
device_12_features.pNext = &maintenance_4;
}
@ -332,7 +325,7 @@ static GHOST_TSuccess ensure_vulkan_device(VkInstance vk_instance,
for (const auto &physical_device : physical_devices) {
GHOST_DeviceVK device_vk(vk_instance, physical_device);
if (!device_vk.support_extensions(required_extensions)) {
if (!device_vk.has_extensions(required_extensions)) {
continue;
}
@ -1054,7 +1047,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
/* According to the Vulkan specs, when `VK_KHR_portability_subset` is available it should be
* enabled. See
* https://vulkan.lunarg.com/doc/view/1.2.198.1/mac/1.2-extensions/vkspec.html#VUID-VkDeviceCreateInfo-pProperties-04451*/
if (vulkan_device->support_extensions({VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME})) {
if (vulkan_device->has_extensions({VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME})) {
extensions_device.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
}
#endif