Implement initial VK_EXT_debug_utils changes
This affects the loader, scripts, and layers and introduces the
changes to support the VK_EXT_debug_utils extension.
Change-Id: Ia5336f63e85b00f1e59416c06aacd4ae331fd692
diff --git a/layers/vk_layer_utils.cpp b/layers/vk_layer_utils.cpp
index d788daf..629b19f 100644
--- a/layers/vk_layer_utils.cpp
+++ b/layers/vk_layer_utils.cpp
@@ -91,8 +91,9 @@
// If a vk_layer_settings.txt file is present and an application defines a debug callback, both callbacks
// will be active. If no vk_layer_settings.txt file is present, creating an application-defined debug
// callback will cause the default callbacks to be unregisterd and removed.
-VK_LAYER_EXPORT void layer_debug_actions(debug_report_data *report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback,
- const VkAllocationCallbacks *pAllocator, const char *layer_identifier) {
+VK_LAYER_EXPORT void layer_debug_report_actions(debug_report_data *report_data,
+ std::vector<VkDebugReportCallbackEXT> &logging_callback,
+ const VkAllocationCallbacks *pAllocator, const char *layer_identifier) {
VkDebugReportCallbackEXT callback = VK_NULL_HANDLE;
std::string report_flags_key = layer_identifier;
@@ -115,9 +116,9 @@
memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
dbgCreateInfo.flags = report_flags;
- dbgCreateInfo.pfnCallback = log_callback;
+ dbgCreateInfo.pfnCallback = report_log_callback;
dbgCreateInfo.pUserData = (void *)log_output;
- layer_create_msg_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
+ layer_create_report_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
logging_callback.push_back(callback);
}
@@ -128,9 +129,9 @@
memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
dbgCreateInfo.flags = report_flags;
- dbgCreateInfo.pfnCallback = win32_debug_output_msg;
+ dbgCreateInfo.pfnCallback = report_win32_debug_output_msg;
dbgCreateInfo.pUserData = NULL;
- layer_create_msg_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
+ layer_create_report_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
logging_callback.push_back(callback);
}
@@ -143,7 +144,64 @@
dbgCreateInfo.flags = report_flags;
dbgCreateInfo.pfnCallback = DebugBreakCallback;
dbgCreateInfo.pUserData = NULL;
- layer_create_msg_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
+ layer_create_report_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &callback);
logging_callback.push_back(callback);
}
}
+
+VK_LAYER_EXPORT void layer_debug_messenger_actions(debug_report_data *report_data,
+ std::vector<VkDebugUtilsMessengerEXT> &logging_messenger,
+ const VkAllocationCallbacks *pAllocator, const char *layer_identifier) {
+ VkDebugUtilsMessengerEXT messenger = VK_NULL_HANDLE;
+
+ std::string report_flags_key = layer_identifier;
+ std::string debug_action_key = layer_identifier;
+ std::string log_filename_key = layer_identifier;
+ report_flags_key.append(".report_flags");
+ debug_action_key.append(".debug_action");
+ log_filename_key.append(".log_filename");
+
+ // Initialize layer options
+ VkDebugReportFlagsEXT report_flags = GetLayerOptionFlags(report_flags_key, report_flags_option_definitions, 0);
+ VkLayerDbgActionFlags debug_action = GetLayerOptionFlags(debug_action_key, debug_actions_option_definitions, 0);
+ // Flag as default if these settings are not from a vk_layer_settings.txt file
+ bool default_layer_callback = (debug_action & VK_DBG_LAYER_ACTION_DEFAULT) ? true : false;
+ VkDebugUtilsMessengerCreateInfoEXT dbgCreateInfo;
+ memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
+ dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
+ dbgCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
+ if (report_flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
+ dbgCreateInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
+ }
+ if (report_flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
+ dbgCreateInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
+ }
+ if (report_flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
+ dbgCreateInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
+ dbgCreateInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
+ }
+ if (report_flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
+ dbgCreateInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
+ }
+ if (report_flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
+ dbgCreateInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
+ }
+
+ if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) {
+ const char *log_filename = getLayerOption(log_filename_key.c_str());
+ FILE *log_output = getLayerLogOutput(log_filename, layer_identifier);
+ dbgCreateInfo.pfnUserCallback = messenger_log_callback;
+ dbgCreateInfo.pUserData = (void *)log_output;
+ layer_create_messenger_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &messenger);
+ logging_messenger.push_back(messenger);
+ }
+
+ messenger = VK_NULL_HANDLE;
+
+ if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) {
+ dbgCreateInfo.pfnUserCallback = messenger_win32_debug_output_msg;
+ dbgCreateInfo.pUserData = NULL;
+ layer_create_messenger_callback(report_data, default_layer_callback, &dbgCreateInfo, pAllocator, &messenger);
+ logging_messenger.push_back(messenger);
+ }
+}