diff options
Diffstat (limited to 'layers/vk_layer_utils.cpp')
| -rw-r--r-- | layers/vk_layer_utils.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/layers/vk_layer_utils.cpp b/layers/vk_layer_utils.cpp index 9fea3899..43ddc8d4 100644 --- a/layers/vk_layer_utils.cpp +++ b/layers/vk_layer_utils.cpp @@ -27,7 +27,9 @@ #include <string.h> #include <string> +#include <vector> #include "vulkan/vulkan.h" +#include "vk_layer_config.h" #include "vk_layer_utils.h" typedef struct _VULKAN_FORMAT_INFO { @@ -608,3 +610,46 @@ VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) { } return result; } + +void layer_debug_actions(debug_report_data *report_data, std::vector<VkDebugReportCallbackEXT> logging_callback, + const VkAllocationCallbacks *pAllocator, const char *layer_identifier) { + + uint32_t report_flags = 0; + uint32_t debug_action = 0; + FILE *log_output = NULL; + const char *option_str; + VkDebugReportCallbackEXT callback; + + std::string option_flags = layer_identifier; + std::string log_filename = layer_identifier; + option_flags.append(".report_flags"); + log_filename.append(".log_filename"); + + // initialize layer options + report_flags = getLayerOptionFlags(option_flags.c_str(), 0); + getLayerOptionEnum(log_filename.c_str(), (uint32_t *)&debug_action); + + if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) { + option_str = getLayerOption(log_filename.c_str()); + log_output = getLayerLogOutput(option_str, layer_identifier); + VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; + memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo)); + dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; + dbgCreateInfo.flags = report_flags; + dbgCreateInfo.pfnCallback = log_callback; + dbgCreateInfo.pUserData = (void *)log_output; + layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback); + logging_callback.push_back(callback); + } + + if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { + VkDebugReportCallbackCreateInfoEXT dbgCreateInfo; + 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.pUserData = NULL; + layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback); + logging_callback.push_back(callback); + } +} |
