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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
use std::error::Error;
use erupt::vk;
#[derive(Debug)]
pub enum AscheError {
IoError(std::io::Error),
NulError(std::ffi::NulError),
Utf8Error(std::str::Utf8Error),
TryFromIntError(std::num::TryFromIntError),
EntryLoaderError(erupt::utils::loading::EntryLoaderError),
LoaderError(erupt::LoaderError),
VkAllocError(vk_alloc::AllocatorError),
VkResult(vk::Result),
DebugUtilsMissing,
RequestDeviceError,
QueueFamilyNotFound(String),
SwapchainFormatIncompatible,
DeviceFeatureMissing,
PresentationModeUnsupported,
SwapchainNotInitialized,
BufferZeroSize,
NoQueueConfigured,
QueueCountTooHigh(usize),
MissingWaitSemaphore,
MissingSignalSemaphore,
}
impl std::fmt::Display for AscheError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
AscheError::IoError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::NulError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::Utf8Error(err) => {
write!(f, "{:?}", err.source())
}
AscheError::EntryLoaderError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::LoaderError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::VkAllocError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::TryFromIntError(err) => {
write!(f, "{:?}", err.source())
}
AscheError::VkResult(err) => {
write!(f, "vk::Result({})", err)
}
AscheError::DebugUtilsMissing => {
write!(f, "can't load the debug utils extension")
}
AscheError::RequestDeviceError => {
write!(f, "can't find device with requested capabilities")
}
AscheError::QueueFamilyNotFound(family) => {
write!(f, "can't find queue family: {}", family)
}
AscheError::SwapchainFormatIncompatible => {
write!(f, "selected format / color space for the swapchain is not supported by the device")
}
AscheError::SwapchainNotInitialized => {
write!(f, "swapchain is not initialized")
}
AscheError::PresentationModeUnsupported => {
write!(f, "the selected presentation mode is unsupported")
}
AscheError::DeviceFeatureMissing => {
write!(f, "the requested device feature couldn't be found")
}
AscheError::BufferZeroSize => {
write!(f, "the requested buffer has a size of zero")
}
AscheError::NoQueueConfigured => {
write!(f, "no queue was configured")
}
AscheError::QueueCountTooHigh(count) => {
write!(f, "queue count too high. Only support the creation of up to 64 queues. Requests queue count: {}", count)
}
AscheError::MissingWaitSemaphore => {
write!(f, "command buffer is missing a wait semaphore")
}
AscheError::MissingSignalSemaphore => {
write!(f, "command buffer is missing a signal semaphore")
}
}
}
}
impl std::error::Error for AscheError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self {
AscheError::IoError(ref e) => Some(e),
AscheError::NulError(ref e) => Some(e),
AscheError::Utf8Error(ref e) => Some(e),
AscheError::TryFromIntError(ref e) => Some(e),
AscheError::EntryLoaderError(ref e) => Some(e),
AscheError::LoaderError(ref e) => Some(e),
AscheError::VkAllocError(ref e) => Some(e),
AscheError::VkResult(ref e) => Some(e),
_ => None,
}
}
}
impl From<std::io::Error> for AscheError {
fn from(err: std::io::Error) -> AscheError {
AscheError::IoError(err)
}
}
impl From<std::ffi::NulError> for AscheError {
fn from(err: std::ffi::NulError) -> AscheError {
AscheError::NulError(err)
}
}
impl From<std::str::Utf8Error> for AscheError {
fn from(err: std::str::Utf8Error) -> AscheError {
AscheError::Utf8Error(err)
}
}
impl From<erupt::LoaderError> for AscheError {
fn from(err: erupt::LoaderError) -> AscheError {
AscheError::LoaderError(err)
}
}
impl From<vk::Result> for AscheError {
fn from(err: vk::Result) -> AscheError {
AscheError::VkResult(err)
}
}
impl From<erupt::utils::loading::EntryLoaderError> for AscheError {
fn from(err: erupt::utils::loading::EntryLoaderError) -> AscheError {
AscheError::EntryLoaderError(err)
}
}
impl From<vk_alloc::AllocatorError> for AscheError {
fn from(err: vk_alloc::AllocatorError) -> AscheError {
AscheError::VkAllocError(err)
}
}
impl From<std::num::TryFromIntError> for AscheError {
fn from(err: std::num::TryFromIntError) -> AscheError {
AscheError::TryFromIntError(err)
}
}