MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / DebugCallback

Function DebugCallback

tests/framework/error_monitor.cpp:57–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
58 VkDebugUtilsMessageTypeFlagsEXT message_type,
59 const VkDebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data) {
60 const auto message_flags = DebugAnnotFlagsToMsgTypeFlags(message_severity, message_type);
61 const char* vuid = callback_data->pMessageIdName;
62 auto* error_monitor = reinterpret_cast<ErrorMonitor*>(user_data);
63
64 // mimic CreateDefaultCallbackMessage we do for default callback so
65 // (while this is a bad 'copy-and-paste' the format of the default callback *should* not be changing often)
66 std::ostringstream oss;
67 // The callback is in JSON (this is the only way the first char is '{')
68 if (callback_data->pMessage[0] == '{') {
69 oss << callback_data->pMessage << '\n';
70 } else {
71 if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
72 oss << "Validation Error: ";
73 } else if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
74 if (message_type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) {
75 oss << "Validation Performance Warning: ";
76 } else {
77 oss << "Validation Warning: ";
78 }
79 } else if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
80 oss << "Validation Information: ";
81 } else if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
82 oss << "Verbose Information: ";
83 }
84
85 oss << "[ " << callback_data->pMessageIdName << " ] | MessageID = 0x" << std::hex << callback_data->messageIdNumber << '\n';
86 oss << callback_data->pMessage << '\n';
87
88 if (callback_data->objectCount > 0) {
89 oss << "Objects: " << callback_data->objectCount << '\n';
90 for (uint32_t i = 0; i < callback_data->objectCount; i++) {
91 const auto& debug_object = callback_data->pObjects[i];
92 oss << " [" << i << "] " << string_VkObjectTypeHandleName(debug_object.objectType);
93 if (debug_object.objectHandle) {
94 oss << " 0x" << std::hex << debug_object.objectHandle;
95 } else {
96 oss << " VK_NULL_HANDLE";
97 }
98 if (debug_object.pObjectName) {
99 oss << "[" << debug_object.pObjectName << "]";
100 }
101 oss << '\n';
102 }
103 }
104#ifndef VK_USE_PLATFORM_ANDROID_KHR
105 oss << '\n'; // provide space between consecutive errors
106#endif
107 }
108 std::string error_message = oss.str();
109
110 if (message_flags & error_monitor->GetMessageFlags()) {
111 return error_monitor->CheckForDesiredMsg(vuid, error_message.c_str());
112 }
113
114 // GPU-DUMP

Callers

nothing calls this directly

Calls 5

GetMessageFlagsMethod · 0.80
CheckForDesiredMsgMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected