forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_error_location.cpp
137 lines (130 loc) · 4.63 KB
/
core_error_location.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "core_error_location.h"
#include <map>
#define FUNC_ENTRY(_v) \
{ ErrFunc::_v, #_v }
const std::string& CoreErrorLocation::String(ErrFunc func) {
static const std::map<ErrFunc, std::string> table{
{ErrFunc::Empty, ""},
FUNC_ENTRY(vkQueueSubmit),
FUNC_ENTRY(vkQueueSubmit2KHR),
FUNC_ENTRY(vkCmdSetEvent),
FUNC_ENTRY(vkCmdSetEvent2KHR),
FUNC_ENTRY(vkCmdResetEvent),
FUNC_ENTRY(vkCmdResetEvent2KHR),
FUNC_ENTRY(vkCmdPipelineBarrier),
FUNC_ENTRY(vkCmdPipelineBarrier2KHR),
FUNC_ENTRY(vkCmdWaitEvents),
FUNC_ENTRY(vkCmdWaitEvents2KHR),
FUNC_ENTRY(vkCmdWriteTimestamp2),
FUNC_ENTRY(vkCmdWriteTimestamp2KHR),
FUNC_ENTRY(vkCreateRenderPass),
FUNC_ENTRY(vkCreateRenderPass2),
FUNC_ENTRY(vkQueueBindSparse),
FUNC_ENTRY(vkSignalSemaphore),
};
const auto entry = table.find(func);
assert(entry != table.end());
return entry->second;
}
#define REFPAGE_ENTRY(_v) \
{ RefPage::_v, #_v }
const std::string& CoreErrorLocation::String(RefPage refpage) {
static const std::map<RefPage, std::string> table{
{RefPage::Empty, ""},
REFPAGE_ENTRY(VkMemoryBarrier),
REFPAGE_ENTRY(VkMemoryBarrier2KHR),
REFPAGE_ENTRY(VkBufferMemoryBarrier),
REFPAGE_ENTRY(VkImageMemoryBarrier),
REFPAGE_ENTRY(VkBufferMemoryBarrier2KHR),
REFPAGE_ENTRY(VkImageMemoryBarrier2KHR),
REFPAGE_ENTRY(VkSubmitInfo),
REFPAGE_ENTRY(VkSubmitInfo2KHR),
REFPAGE_ENTRY(VkCommandBufferSubmitInfoKHR),
REFPAGE_ENTRY(vkCmdSetEvent),
REFPAGE_ENTRY(vkCmdSetEvent2KHR),
REFPAGE_ENTRY(vkCmdResetEvent),
REFPAGE_ENTRY(vkCmdResetEvent2KHR),
REFPAGE_ENTRY(vkCmdPipelineBarrier),
REFPAGE_ENTRY(vkCmdPipelineBarrier2KHR),
REFPAGE_ENTRY(vkCmdWaitEvents),
REFPAGE_ENTRY(vkCmdWaitEvents2KHR),
REFPAGE_ENTRY(vkCmdWriteTimestamp2),
REFPAGE_ENTRY(vkCmdWriteTimestamp2KHR),
REFPAGE_ENTRY(VkSubpassDependency),
REFPAGE_ENTRY(VkSubpassDependency2),
REFPAGE_ENTRY(VkBindSparseInfo),
REFPAGE_ENTRY(VkSemaphoreSignalInfo),
};
const auto entry = table.find(refpage);
assert(entry != table.end());
return entry->second;
}
#define FIELD_ENTRY(_v) \
{ Field::_v, #_v }
const std::string& CoreErrorLocation::String(Field field) {
static const std::map<Field, std::string> table{
{Field::Empty, ""},
FIELD_ENTRY(oldLayout),
FIELD_ENTRY(newLayout),
FIELD_ENTRY(image),
FIELD_ENTRY(buffer),
FIELD_ENTRY(pMemoryBarriers),
FIELD_ENTRY(pBufferMemoryBarriers),
FIELD_ENTRY(pImageMemoryBarriers),
FIELD_ENTRY(offset),
FIELD_ENTRY(size),
FIELD_ENTRY(subresourceRange),
FIELD_ENTRY(srcAccessMask),
FIELD_ENTRY(dstAccessMask),
FIELD_ENTRY(srcStageMask),
FIELD_ENTRY(dstStageMask),
FIELD_ENTRY(pNext),
FIELD_ENTRY(pWaitDstStageMask),
FIELD_ENTRY(pWaitSemaphores),
FIELD_ENTRY(pSignalSemaphores),
FIELD_ENTRY(pWaitSemaphoreInfos),
FIELD_ENTRY(pWaitSemaphoreValues),
FIELD_ENTRY(pSignalSemaphoreInfos),
FIELD_ENTRY(pSignalSemaphoreValues),
FIELD_ENTRY(stage),
FIELD_ENTRY(stageMask),
FIELD_ENTRY(value),
FIELD_ENTRY(pCommandBuffers),
FIELD_ENTRY(pSubmits),
FIELD_ENTRY(pCommandBufferInfos),
FIELD_ENTRY(semaphore),
FIELD_ENTRY(commandBuffer),
FIELD_ENTRY(dependencyFlags),
FIELD_ENTRY(pDependencyInfo),
FIELD_ENTRY(pDependencyInfos),
FIELD_ENTRY(srcQueueFamilyIndex),
FIELD_ENTRY(dstQueueFamilyIndex),
FIELD_ENTRY(queryPool),
FIELD_ENTRY(pDependencies),
};
const auto entry = table.find(field);
assert(entry != table.end());
return entry->second;
}
CoreErrorLocationCapture::CoreErrorLocationCapture(const CoreErrorLocation& loc) { Capture(loc, 1); }
const CoreErrorLocation* CoreErrorLocationCapture::Capture(const CoreErrorLocation& loc, CaptureStore::size_type depth) {
const CoreErrorLocation* prev_capture = nullptr;
if (loc.prev) {
prev_capture = Capture(*loc.prev, depth + 1);
} else {
capture.reserve(depth);
}
capture.emplace_back(loc);
capture.back().prev = prev_capture;
return &(capture.back());
}
void CoreErrorLocation::AppendFields(std::stringstream* out) const {
if (prev) {
prev->AppendFields(out);
*out << ".";
}
*out << String(field_name);
if (index != CoreErrorLocation::kNoIndex) {
*out << "[" << index << "]";
}
}