Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa6c8727 authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

loader: Test for valid ICD before init dispatch

Test that the Instance object returned by the ICD
is valid before initializing the loader's instance
dispatch table. Not a huge deal since that test
should never fail in production, but flows better.

Change-Id: I7063fb797038e05ea2d0cf9b0794f668b3510cde
parent 9ec497c4
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -600,13 +600,6 @@ VkResult CreateInstance_Bottom(const VkInstanceCreateInfo* create_info,
        return result;
    }

    if (!LoadDriverDispatchTable(instance.drv.instance,
                                 g_hwdevice->GetInstanceProcAddr,
                                 enabled_extensions, instance.drv.dispatch)) {
        DestroyInstance_Bottom(instance.handle, allocator);
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    hwvulkan_dispatch_t* drv_dispatch =
        reinterpret_cast<hwvulkan_dispatch_t*>(instance.drv.instance);
    if (drv_dispatch->magic == HWVULKAN_DISPATCH_MAGIC) {
@@ -619,6 +612,13 @@ VkResult CreateInstance_Bottom(const VkInstanceCreateInfo* create_info,
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    if (!LoadDriverDispatchTable(instance.drv.instance,
                                 g_hwdevice->GetInstanceProcAddr,
                                 enabled_extensions, instance.drv.dispatch)) {
        DestroyInstance_Bottom(instance.handle, allocator);
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    uint32_t num_physical_devices = 0;
    result = instance.drv.dispatch.EnumeratePhysicalDevices(
        instance.drv.instance, &num_physical_devices, nullptr);