aux/vk: Refactor out optional extension handling

This commit is contained in:
Jakob Bornecrantz 2021-06-07 12:39:35 +01:00 committed by Jakob Bornecrantz
parent 57d24ecdbb
commit bf27691280

View file

@ -1129,6 +1129,22 @@ vk_check_extension(struct vk_bundle *vk, VkExtensionProperties *props, uint32_t
{
for (uint32_t i = 0; i < num_props; i++) {
if (strcmp(props[i].extensionName, ext) == 0) {
return true;
}
}
return false;
}
static void
fill_in_has_extensions(struct vk_bundle *vk, const char **device_extensions, uint32_t num_device_extensions)
{
// Reset before filling out.
vk->has_GOOGLE_display_timing = false;
vk->has_EXT_global_priority = false;
for (uint32_t i = 0; i < num_device_extensions; i++) {
const char *ext = device_extensions[i];
if (strcmp(ext, VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME) == 0) {
vk->has_GOOGLE_display_timing = true;
@ -1136,14 +1152,9 @@ vk_check_extension(struct vk_bundle *vk, VkExtensionProperties *props, uint32_t
if (strcmp(ext, VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME) == 0) {
vk->has_EXT_global_priority = true;
}
return true;
}
}
return false;
}
static VkResult
vk_get_device_ext_props(struct vk_bundle *vk,
VkPhysicalDevice physical_device,
@ -1207,6 +1218,9 @@ vk_build_device_extensions(struct vk_bundle *vk,
}
}
// Fill this out here.
fill_in_has_extensions(vk, device_extensions, num_device_extensions);
free(props);
*out_device_extensions = device_extensions;