We try to return as early as we can if we know we don't need to spend time logging the message
| 99 | |
| 100 | // We try to return as early as we can if we know we don't need to spend time logging the message |
| 101 | bool DebugReport::LogMessage(VkFlags msg_flags, std::string_view vuid_text, const LogObjectList& objects, const Location& loc, |
| 102 | const std::string& main_message) { |
| 103 | // Convert the info to the VK_EXT_debug_utils format |
| 104 | VkDebugUtilsMessageSeverityFlagsEXT msg_severity; |
| 105 | VkDebugUtilsMessageTypeFlagsEXT msg_type; |
| 106 | DebugReportFlagsToAnnotFlags(msg_flags, &msg_severity, &msg_type); |
| 107 | if (!(active_msg_severities & msg_severity) || !(active_msg_types & msg_type)) { |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | // If message is in filter list, bail out very early |
| 112 | const uint32_t vuid_hash = hash_util::VuidHash(vuid_text); |
| 113 | if (filter_message_ids.find(vuid_hash) != filter_message_ids.end()) { |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | // We have a few speical VUID we never actually want to suppress. |
| 118 | // If a new VUID is added here, make sure to add it in NegativeOther.VuidHashStability test as well. |
| 119 | const bool skip_checking_limit = |
| 120 | // We want to print DebugPrintf message forever, otherwise user will mistake duplicate limit for things not printing |
| 121 | (vuid_hash == 0x4fe1fef9) || |
| 122 | // GPU-DUMP |
| 123 | (vuid_hash == 0xe5c5edc1); |
| 124 | |
| 125 | // This lock needs to be here, duplicate_message_count_map is not safe to update on multiple threads |
| 126 | // see https://issues.angleproject.org/issues/450466850 |
| 127 | std::unique_lock<std::mutex> lock(debug_output_mutex); |
| 128 | |
| 129 | // Count for this particular message is over the limit, ignore it |
| 130 | bool at_message_limit = false; |
| 131 | if (duplicate_message_limit > 0 && !skip_checking_limit) { |
| 132 | auto vuid_count_it = duplicate_message_count_map.find(vuid_hash); |
| 133 | if (vuid_count_it == duplicate_message_count_map.end()) { |
| 134 | duplicate_message_count_map.emplace(vuid_hash, 1); |
| 135 | } else if (vuid_count_it->second >= duplicate_message_limit) { |
| 136 | return false; |
| 137 | } else { |
| 138 | // In theory we have not locked the mutex yet |
| 139 | // 1. Its hard to have 2 exact VUID be called at same time |
| 140 | // 2. This limit is rarely, if ever, used to get an exact amount and really just there to stop spamming the user |
| 141 | vuid_count_it->second++; |
| 142 | if (vuid_count_it->second >= duplicate_message_limit) { |
| 143 | at_message_limit = true; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | std::vector<VkDebugUtilsLabelEXT> queue_labels; |
| 149 | std::vector<VkDebugUtilsLabelEXT> cmd_buf_labels; |
| 150 | |
| 151 | std::vector<std::string> object_labels; |
| 152 | // Ensures that push_back will not reallocate, thereby providing pointer |
| 153 | // stability for pushed strings. |
| 154 | object_labels.reserve(objects.object_list.size()); |
| 155 | |
| 156 | std::vector<VkDebugUtilsObjectNameInfoEXT> object_name_infos; |
| 157 | object_name_infos.reserve(objects.object_list.size()); |
| 158 | for (uint32_t i = 0; i < objects.object_list.size(); i++) { |
no test coverage detected