diff options
| author | Ian Elliott <ianelliott@google.com> | 2016-04-28 09:08:13 -0600 |
|---|---|---|
| committer | Ian Elliott <ianelliott@google.com> | 2016-04-28 09:13:02 -0600 |
| commit | c120bf9e85649e55261b6e50839576a30bccf835 (patch) | |
| tree | e164e59b602f00c765162c82cc26d2204be0ab33 /layers/threading.cpp | |
| parent | 1b65a150ec6a75b9fca5d7dc88c274bbfb60bd44 (diff) | |
| download | usermoji-c120bf9e85649e55261b6e50839576a30bccf835.tar.xz | |
layers: Use tmp callback for msgs during vk{Create|Destroy}Instance().
This is implements some relatively-new functionality of the VK_EXT_debug_report
extension. An application can pass VkDebugReportCallbackCreateInfoEXT structs
on the pNext chain given to vkCreateInstance(), in order to setup one or more
callbacks that can be used during vk{Create|Destroy}Instance(). These special,
"temporary callbacks" allow messages (e.g. errors) to be logged during the time
when the debug_report extension is normally not setup.
A set of utilities copy VkDebugReportCallbackCreateInfoEXT structs from the
pNext chain given to vkCreateInstance(). These utilities are used by the
validation layers that may have messages (e.g. errors) during
vk{Create|Destroy}Instance().
Diffstat (limited to 'layers/threading.cpp')
| -rw-r--r-- | layers/threading.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/layers/threading.cpp b/layers/threading.cpp index 79f047c5..4d9fca0d 100644 --- a/layers/threading.cpp +++ b/layers/threading.cpp @@ -69,6 +69,11 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCall my_data->report_data = debug_report_create_instance(my_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); initThreading(my_data, pAllocator); + + // Look for one or more debug report create info structures, and copy the + // callback(s) for each one found (for use by vkDestroyInstance) + layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_data->num_tmp_callbacks, &my_data->tmp_dbg_create_infos, + &my_data->tmp_callbacks); return result; } @@ -76,10 +81,29 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance dispatch_key key = get_dispatch_key(instance); layer_data *my_data = get_my_data_ptr(key, layer_data_map); VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; + + // Enable the temporary callback(s) here to catch cleanup issues: + bool callback_setup = false; + if (my_data->num_tmp_callbacks > 0) { + if (!layer_enable_tmp_callbacks(my_data->report_data, my_data->num_tmp_callbacks, my_data->tmp_dbg_create_infos, + my_data->tmp_callbacks)) { + callback_setup = true; + } + } + startWriteObject(my_data, instance); pTable->DestroyInstance(instance, pAllocator); finishWriteObject(my_data, instance); + // Disable and cleanup the temporary callback(s): + if (callback_setup) { + layer_disable_tmp_callbacks(my_data->report_data, my_data->num_tmp_callbacks, my_data->tmp_callbacks); + } + if (my_data->num_tmp_callbacks > 0) { + layer_free_tmp_callbacks(my_data->tmp_dbg_create_infos, my_data->tmp_callbacks); + my_data->num_tmp_callbacks = 0; + } + // Clean up logging callback, if any while (my_data->logging_callback.size() > 0) { VkDebugReportCallbackEXT callback = my_data->logging_callback.back(); |
