| 321 | } |
| 322 | |
| 323 | std::string DebugReport::CreateMessageJson(VkFlags msg_flags, const Location& loc, |
| 324 | const std::vector<VkDebugUtilsObjectNameInfoEXT>& object_name_infos, |
| 325 | const uint32_t vuid_hash, std::string_view vuid_text, const std::string& main_message, |
| 326 | bool at_message_limit) { |
| 327 | std::ostringstream oss; |
| 328 | // For now we just list each JSON field as a new line as it is "pretty-print enough". |
| 329 | // For Android, things get logged in logcat and having the JSON as a single line is easier to grab from the terminal. |
| 330 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 331 | char new_line = ' '; |
| 332 | char line_start = ' '; |
| 333 | #else |
| 334 | char new_line = '\n'; |
| 335 | char line_start = '\t'; |
| 336 | #endif |
| 337 | |
| 338 | oss << "{" << new_line; |
| 339 | |
| 340 | if (message_format_settings.display_application_name && !message_format_settings.application_name.empty()) { |
| 341 | oss << line_start << "\"AppName\" : \"" << message_format_settings.application_name << "\"," << new_line; |
| 342 | } |
| 343 | |
| 344 | { |
| 345 | oss << line_start << "\"Severity\" : \""; |
| 346 | if (msg_flags & kErrorBit) { |
| 347 | oss << "Error"; |
| 348 | } else if (msg_flags & kWarningBit) { |
| 349 | oss << "Warning"; |
| 350 | } else if (msg_flags & kPerformanceWarningBit) { |
| 351 | oss << "Performance Warning"; |
| 352 | } else if (msg_flags & kInformationBit) { |
| 353 | oss << "Information"; |
| 354 | } else if (msg_flags & kVerboseBit) { |
| 355 | oss << "Verbose"; |
| 356 | } |
| 357 | oss << "\"," << new_line; |
| 358 | } |
| 359 | |
| 360 | { |
| 361 | oss << line_start << "\"VUID\" : \"" << vuid_text << "\"," << new_line; |
| 362 | } |
| 363 | |
| 364 | { |
| 365 | oss << line_start << "\"Objects\" : [" << new_line; |
| 366 | for (uint32_t i = 0; i < object_name_infos.size(); i++) { |
| 367 | const VkDebugUtilsObjectNameInfoEXT& src_object = object_name_infos[i]; |
| 368 | |
| 369 | oss << line_start << line_start; |
| 370 | oss << "{\"type\" : \"" << string_VkObjectTypeHandleName(src_object.objectType) << "\", \"handle\" : \""; |
| 371 | if (0 != src_object.objectHandle) { |
| 372 | oss << "0x" << std::hex << src_object.objectHandle; |
| 373 | oss << "\", \"name\" : \""; |
| 374 | if (src_object.pObjectName) { |
| 375 | oss << src_object.pObjectName; |
| 376 | } |
| 377 | oss << "\"}"; |
| 378 | } else { |
| 379 | oss << "VK_NULL_HANDLE\", \"name\" : \"\"}"; |
| 380 | } |
nothing calls this directly
no test coverage detected