From cfa6643201d47ccb6ccc630d60ad4b1f4cdf0102 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Thu, 25 Jun 2015 18:01:43 -0600 Subject: loader: Move CreateDevice to device table Discovered an issue where a layer was doing cleanup in it's DestroyDevice function but the CreateDevice was never called. This happened because the extension was only enabled on the device chain and the device chain doesn't actually call CreateDevice. That happens on the Instance chain. Making it so that we can call down the device chain - which is terminated by the ICD. We need to know the real device object to construct the device chain heiarchy and when calling down the device chain it should end with the ICD doing the actual device object creation. This patch fixes the issue by using the same process as CreateInstance. The loader will call the ICD's CreateDevice and pass that in the *pDevice argument. The layers then ignore the PhysicalDevice parameter and use the *pDevice to access the device chain. To prevent the ICD from being called twice needed to stub in a special loader_GetDeviceChainProcAddr to provide a stub for only CreateDevice as the end of the chain. integrate review feedback. --- layers/multi.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'layers/multi.cpp') diff --git a/layers/multi.cpp b/layers/multi.cpp index 5f86b88a..28dacf95 100644 --- a/layers/multi.cpp +++ b/layers/multi.cpp @@ -306,9 +306,8 @@ VK_LAYER_EXPORT VkResult VKAPI multi2DestroyInstance(VkInstance instance) VK_LAYER_EXPORT VkResult VKAPI multi2CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) { - VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) gpu; printf("At start of multi2 vkCreateDevice()\n"); - VkResult result = instance_dispatch_table2(gpu)->CreateDevice(gpu, pCreateInfo, pDevice); + VkResult result = device_dispatch_table2(*pDevice)->CreateDevice(gpu, pCreateInfo, pDevice); printf("Completed multi2 layer vkCreateDevice()\n"); return result; } @@ -346,6 +345,8 @@ VK_LAYER_EXPORT void * VKAPI multi2GetDeviceProcAddr(VkDevice device, const char getLayer2Table(devw); return (void *) multi2GetDeviceProcAddr; } + if (!strcmp("vkCreateDevice", pName)) + return (void *) multi2CreateDevice; if (!strcmp("vkDestroyDevice", pName)) return (void *) multi2DestroyDevice; if (!strcmp("vkCreateCommandBuffer", pName)) @@ -376,8 +377,6 @@ VK_LAYER_EXPORT void * VKAPI multi2GetInstanceProcAddr(VkInstance inst, const ch return (void *) multi2EnumeratePhysicalDevices; if (!strcmp("vkDestroyInstance", pName)) return (void *) multi2DestroyInstance; - if (!strcmp("vkCreateDevice", pName)) - return (void *) multi2CreateDevice; else if (!strcmp("GetGlobalExtensionProperties", pName)) return (void*) vkGetGlobalExtensionProperties; else if (!strcmp("GetGlobalExtensionCount", pName)) -- cgit v1.2.3