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
diff --git a/vulkan/libvulkan/loader.cpp b/vulkan/libvulkan/loader.cpp
index bc1c3b8..939f3b9 100644
--- a/vulkan/libvulkan/loader.cpp
+++ b/vulkan/libvulkan/loader.cpp
@@ -600,13 +600,6 @@
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 @@
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);