Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
debug_report_vk.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
9
10namespace impeller {
11
13 const vk::Instance& instance) {
14 if (!caps.AreValidationsEnabled()) {
15 is_valid_ = true;
16 return;
17 }
18
19 vk::DebugUtilsMessengerCreateInfoEXT messenger_info;
20 messenger_info.messageSeverity =
21 vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
22 vk::DebugUtilsMessageSeverityFlagBitsEXT::eError;
23 messenger_info.messageType =
24 vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral |
25 vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance |
26 vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation;
27 messenger_info.pUserData = this;
28 messenger_info.pfnUserCallback = DebugUtilsMessengerCallback;
29
30 auto messenger = instance.createDebugUtilsMessengerEXTUnique(messenger_info);
31
32 if (messenger.result != vk::Result::eSuccess) {
33 FML_LOG(ERROR) << "Could not create debug messenger: "
34 << vk::to_string(messenger.result);
35 return;
36 }
37
38 messenger_ = std::move(messenger.value);
39 is_valid_ = true;
40}
41
43
45 return is_valid_;
46}
47
48static std::string JoinLabels(const VkDebugUtilsLabelEXT* labels,
49 size_t count) {
50 std::stringstream stream;
51 for (size_t i = 0u; i < count; i++) {
52 stream << labels[i].pLabelName;
53 if (i != count - 1u) {
54 stream << ", ";
55 }
56 }
57 return stream.str();
58}
59
62 size_t count) {
63 std::stringstream stream;
64 for (size_t i = 0u; i < count; i++) {
65 stream << vk::to_string(vk::ObjectType(names[i].objectType)) << " ["
66 << names[i].objectHandle << "] [";
67 if (names[i].pObjectName != nullptr) {
68 stream << names[i].pObjectName;
69 } else {
70 stream << "UNNAMED";
71 }
72 stream << "]";
73 if (i != count - 1u) {
74 stream << ", ";
75 }
76 }
77 return stream.str();
78}
79
80VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportVK::DebugUtilsMessengerCallback(
83 const VkDebugUtilsMessengerCallbackDataEXT* callback_data,
84 void* debug_report) {
85 auto result =
86 reinterpret_cast<DebugReportVK*>(debug_report)
87 ->OnDebugCallback(
88 static_cast<vk::DebugUtilsMessageSeverityFlagBitsEXT>(
89 severity), //
90 static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(type), //
91 callback_data //
92 );
93 switch (result) {
94 case Result::kContinue:
95 return VK_FALSE;
96 case Result::kAbort:
97 return VK_TRUE;
98 }
99 return VK_FALSE;
100}
101
102DebugReportVK::Result DebugReportVK::OnDebugCallback(
103 vk::DebugUtilsMessageSeverityFlagBitsEXT severity,
104 vk::DebugUtilsMessageTypeFlagsEXT type,
106 // This is a real issue caused by INPUT_ATTACHMENT_BIT not being a supported
107 // `VkSurfaceCapabilitiesKHR::supportedUsageFlags` on any platform other than
108 // Android. This is necessary for all the framebuffer fetch related tests. We
109 // can get away with suppressing this on macOS but this must be fixed.
110 if (data->messageIdNumber == 0x2c36905d) {
111 return Result::kContinue;
112 }
113 // This is a performance warning when a fragment stage does not consume all
114 // varyings from the vertex stage. We ignore this as we want to use a single
115 // vertex stage for the runtime effect shader without trying to determine if
116 // the fragment consumes it or not.
117 if (data->messageIdNumber == 0x609A13B) {
118 return Result::kContinue;
119 }
120
121 std::vector<std::pair<std::string, std::string>> items;
122
123 items.emplace_back("Severity", vk::to_string(severity));
124
125 items.emplace_back("Type", vk::to_string(type));
126
127 if (data->pMessageIdName) {
128 items.emplace_back("ID Name", data->pMessageIdName);
129 }
130
131 items.emplace_back("ID Number", std::to_string(data->messageIdNumber));
132
133 if (auto queues = JoinLabels(data->pQueueLabels, data->queueLabelCount);
134 !queues.empty()) {
135 items.emplace_back("Queue Breadcrumbs", std::move(queues));
136 } else {
137 items.emplace_back("Queue Breadcrumbs", "[NONE]");
138 }
139
140 if (auto cmd_bufs = JoinLabels(data->pCmdBufLabels, data->cmdBufLabelCount);
141 !cmd_bufs.empty()) {
142 items.emplace_back("CMD Buffer Breadcrumbs", std::move(cmd_bufs));
143 } else {
144 items.emplace_back("CMD Buffer Breadcrumbs", "[NONE]");
145 }
146
147 if (auto related =
148 JoinVKDebugUtilsObjectNameInfoEXT(data->pObjects, data->objectCount);
149 !related.empty()) {
150 items.emplace_back("Related Objects", std::move(related));
151 }
152
153 if (data->pMessage) {
154 items.emplace_back("Trigger", data->pMessage);
155 }
156
157 size_t padding = 0;
158
159 for (const auto& item : items) {
160 padding = std::max(padding, item.first.size());
161 }
162
163 padding += 1;
164
165 std::stringstream stream;
166
167 stream << std::endl;
168
169 stream << "--- Vulkan Debug Report ----------------------------------------";
170
171 stream << std::endl;
172
173 for (const auto& item : items) {
174 stream << "| " << std::setw(static_cast<int>(padding)) << item.first
175 << std::setw(0) << ": " << item.second << std::endl;
176 }
177
178 stream << "-----------------------------------------------------------------";
179
180 if (type == vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance) {
181 FML_LOG(INFO) << stream.str();
182 } else {
183 VALIDATION_LOG << stream.str();
184 }
185
186 return Result::kContinue;
187}
188
189} // namespace impeller
int count
The Vulkan layers and extensions wrangler.
DebugReportVK(const CapabilitiesVK &caps, const vk::Instance &instance)
VkInstance instance
Definition main.cc:48
GAsyncResult * result
#define FML_LOG(severity)
Definition logging.h:82
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
static std::string JoinVKDebugUtilsObjectNameInfoEXT(const VkDebugUtilsObjectNameInfoEXT *names, size_t count)
static std::string JoinLabels(const VkDebugUtilsLabelEXT *labels, size_t count)
const char * pLabelName
#define ERROR(message)
#define VALIDATION_LOG
Definition validation.h:73
#define VKAPI_CALL
Definition vk_platform.h:57
#define VKAPI_ATTR
Definition vk_platform.h:56
#define VK_TRUE
VkFlags VkDebugUtilsMessageTypeFlagsEXT
#define VK_FALSE
uint32_t VkBool32
Definition vulkan_core.h:94
VkDebugUtilsMessageSeverityFlagBitsEXT