device_select: reorder CreateInstance to have shorter failure paths

no functional changes

Fixes: 991cc686a5f (egl: really fix kopper fd passing)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30647>
This commit is contained in:
Mike Blumenkrantz 2024-08-13 11:49:50 -04:00 committed by Marge Bot
parent 3b2de16fa5
commit 39ae6a891d

View file

@ -123,13 +123,10 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate
break;
assert(chain_info->u.pLayerInfo);
struct instance_info *info = (struct instance_info *)calloc(1, sizeof(struct instance_info));
info->GetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
PFN_vkCreateInstance fpCreateInstance =
(PFN_vkCreateInstance)info->GetInstanceProcAddr(NULL, "vkCreateInstance");
PFN_vkGetInstanceProcAddr GetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)GetInstanceProcAddr(NULL, "vkCreateInstance");
if (fpCreateInstance == NULL) {
free(info);
return VK_ERROR_INITIALIZATION_FAILED;
}
@ -137,10 +134,12 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate
VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
if (result != VK_SUCCESS) {
free(info);
return result;
}
struct instance_info *info = (struct instance_info *)calloc(1, sizeof(struct instance_info));
info->GetInstanceProcAddr = GetInstanceProcAddr;
for (unsigned i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME))