diff options
| author | Ian Elliott <ianelliott@google.com> | 2016-03-25 08:43:01 -0600 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-03-25 10:26:19 -0600 |
| commit | c56bc94aa92158dbdd5301348dccbfe84218b11e (patch) | |
| tree | 88d7efc3979c3950877fe7fbb9319caa990cbee1 /loader | |
| parent | 2f7e6c5bf2a7409cf4f29be1f4df8dade12e0a0b (diff) | |
| download | usermoji-c56bc94aa92158dbdd5301348dccbfe84218b11e.tar.xz | |
loader: Setup temporary callback for vkDestroyInstance
Diffstat (limited to 'loader')
| -rw-r--r-- | loader/loader.h | 1 | ||||
| -rw-r--r-- | loader/trampoline.c | 25 |
2 files changed, 24 insertions, 2 deletions
diff --git a/loader/loader.h b/loader/loader.h index cae78cc9..9efcb704 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -293,6 +293,7 @@ struct loader_instance { bool debug_report_enabled; VkLayerDbgFunctionNode *DbgFunctionHead; + VkDebugReportCallbackCreateInfoEXT *pDebugReportCreateInfo; VkAllocationCallbacks alloc_callbacks; diff --git a/loader/trampoline.c b/loader/trampoline.c index 41119e95..bfd2b8ca 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -279,6 +279,12 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, while (pNext) { if (((VkInstanceCreateInfo *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) { + // Use this pNext so that vkCreateInstance has a callback that can + // be used to log messages. Make a copy for use by + // vkDestroyInstance as well. + ptr_instance->pDebugReportCreateInfo = + ((VkDebugReportCallbackCreateInfoEXT *) + malloc(sizeof(VkDebugReportCallbackCreateInfoEXT))); instance_callback = (VkDebugReportCallbackEXT)ptr_instance; if (util_CreateDebugReportCallback(ptr_instance, pNext, NULL, instance_callback)) { @@ -442,18 +448,33 @@ vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { const VkLayerInstanceDispatchTable *disp; struct loader_instance *ptr_instance = NULL; + VkDebugReportCallbackEXT instance_callback = VK_NULL_HANDLE; + bool callback_setup = false; + disp = loader_get_instance_dispatch(instance); loader_platform_thread_lock_mutex(&loader_lock); - /* TODO: Do we need a temporary callback here to catch cleanup issues? */ - ptr_instance = loader_get_instance(instance); + + if (ptr_instance->pDebugReportCreateInfo) { + // Setup a temporary callback here to catch cleanup issues: + instance_callback = (VkDebugReportCallbackEXT)ptr_instance; + if (!util_CreateDebugReportCallback(ptr_instance, + ptr_instance->pDebugReportCreateInfo, + NULL, instance_callback)) { + callback_setup = true; + } + } + disp->DestroyInstance(instance, pAllocator); loader_deactivate_instance_layers(ptr_instance); if (ptr_instance->phys_devs) loader_heap_free(ptr_instance, ptr_instance->phys_devs); + if (callback_setup) { + util_DestroyDebugReportCallback(ptr_instance, instance_callback, NULL); + } loader_heap_free(ptr_instance, ptr_instance->disp); loader_heap_free(ptr_instance, ptr_instance); loader_platform_thread_unlock_mutex(&loader_lock); |
