misc: Loader and Layers move device chain activation to CreateDevice
diff --git a/layers/basic.cpp b/layers/basic.cpp
index 9f43c6d..ed35fe0 100644
--- a/layers/basic.cpp
+++ b/layers/basic.cpp
@@ -133,17 +133,37 @@
     return VK_SUCCESS;
 }
 
+VK_LAYER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices(
+                                            VkInstance instance,
+                                            uint32_t* pPhysicalDeviceCount,
+                                            VkPhysicalDevice* pPhysicalDevices)
+{
+    /* Need to intercept this entrypoint to add the physDev objects to instance map */
+    VkLayerInstanceDispatchTable* pInstTable = tableInstanceMap[instance];
+    printf("At start of wrapped vkEnumeratePhysicalDevices() call w/ inst: %p\n", (void*)instance);
+    VkResult result = pInstTable->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
+    if (pPhysicalDevices)
+    {
+        // create a mapping for the objects into the dispatch table
+        for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++)
+        {
+            tableInstanceMap.emplace(*(pPhysicalDevices + i), pInstTable);
+        }
+    }
+    printf("Completed wrapped vkEnumeratePhysicalDevices() call w/ count %u\n", *pPhysicalDeviceCount);
+    return result;
+}
+
 VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
 {
-    VkLayerDispatchTable* pTable = tableMap[gpu];
+    VkLayerInstanceDispatchTable* pInstTable = tableInstanceMap[gpu];
 
     printf("At start of wrapped vkCreateDevice() call w/ gpu: %p\n", (void*)gpu);
-    VkResult result = pTable->CreateDevice(gpu, pCreateInfo, pDevice);
-    // create a mapping for the device object into the dispatch table
-    tableMap.emplace(*pDevice, pTable);
+    VkResult result = pInstTable->CreateDevice(gpu, pCreateInfo, pDevice);
     printf("Completed wrapped vkCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice);
     return result;
 }
+
 VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData)
 {
     VkLayerDispatchTable* pTable = tableMap[device];
@@ -158,7 +178,7 @@
 {
     if (gpu != NULL)
     {
-        VkLayerDispatchTable* pTable = initLayerTable((const VkBaseLayerObject *) gpu);
+        VkLayerInstanceDispatchTable* pTable = initLayerInstanceTable((const VkBaseLayerObject *) gpu);
 
         printf("At start of wrapped vkEnumerateLayers() call w/ gpu: %p\n", gpu);
         VkResult result = pTable->EnumerateLayers(gpu, maxStringSize, pLayerCount, pOutLayers, pReserved);
@@ -198,7 +218,9 @@
         return (void *) vkGetProcAddr;
     if (!strcmp("vkCreateDevice", pName))
         return (void *) vkCreateDevice;
-    if (!strcmp("GetGlobalExtensionInfo", pName))
+    if (!strcmp("vkEnumeratePhysicalDevices", pName))
+        return (void*) vkEnumeratePhysicalDevices;
+    if (!strcmp("vkGetGlobalExtensionInfo", pName))
         return (void*) vkGetGlobalExtensionInfo;
     if (!strcmp("vkEnumerateLayers", pName))
         return (void *) vkEnumerateLayers;
@@ -225,7 +247,9 @@
         return (void *) vkGetInstanceProcAddr;
     if (!strcmp("vkGetProcAddr", pName))
         return (void *) vkGetProcAddr;
-    if (!strcmp("GetGlobalExtensionInfo", pName))
+    if (!strcmp("vkEnumeratePhysicalDevices", pName))
+        return (void*) vkEnumeratePhysicalDevices;
+    if (!strcmp("vkGetGlobalExtensionInfo", pName))
         return (void*) vkGetGlobalExtensionInfo;
     if (!strcmp("vkCreateDevice", pName))
         return (void *) vkCreateDevice;