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/screenshot.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'layers/screenshot.cpp') diff --git a/layers/screenshot.cpp b/layers/screenshot.cpp index d46205b3..f7927df3 100644 --- a/layers/screenshot.cpp +++ b/layers/screenshot.cpp @@ -311,8 +311,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( const VkDeviceCreateInfo *pCreateInfo, VkDevice *pDevice) { - VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(screenshot_instance_table_map, gpu); - VkResult result = pInstanceTable->CreateDevice(gpu, pCreateInfo, pDevice); + VkLayerDispatchTable *pDisp = get_dispatch_table(screenshot_device_table_map, *pDevice); + VkResult result = pDisp->CreateDevice(gpu, pCreateInfo, pDevice); if (result == VK_SUCCESS) { createDeviceRegisterExtensions(pCreateInfo, *pDevice); @@ -321,6 +321,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice( return result; } +/* TODO: Probably need a DestroyDevice as well */ + #define SCREENSHOT_LAYER_EXT_ARRAY_SIZE 2 static const VkExtensionProperties ssExts[SCREENSHOT_LAYER_EXT_ARRAY_SIZE] = { { @@ -561,6 +563,9 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr( initDeviceTable(screenshot_device_table_map, (const VkBaseLayerObject *) dev); return (void *) vkGetDeviceProcAddr; } + if (!strcmp(funcName, "vkCreateDevice")) + return (void*) vkCreateDevice; + if (!strcmp(funcName, "vkGetDeviceQueue")) return (void*) vkGetDeviceQueue; @@ -610,8 +615,6 @@ VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr( return (void *) vkDestroyInstance; if (!strcmp(funcName, "vkCreateInstance")) return (void*) vkCreateInstance; - if (!strcmp(funcName, "vkCreateDevice")) - return (void*) vkCreateDevice; if (get_dispatch_table(screenshot_instance_table_map, instance)->GetInstanceProcAddr == NULL) return NULL; -- cgit v1.2.3