ailloli_ui_render_vulkan/error.rs
1//! Typed validation, allocation, command-recording, and submission failures.
2
3use ash::vk;
4use thiserror::Error;
5
6/// Failure while configuring or using the Vulkan renderer.
7///
8/// Every Vulkan-call variant retains the exact [`vk::Result`] returned by the
9/// driver. Host integration failures use [`Self::Host`] for an opaque message.
10///
11/// # Examples
12///
13/// ```
14/// use ailloli_ui_render_vulkan::VulkanRendererError;
15/// let error = VulkanRendererError::InvalidTargetExtent { width: 0, height: 720 };
16/// assert_eq!(error.to_string(), "vulkan target has invalid extent 0x720");
17/// ```
18#[derive(Debug, Error)]
19pub enum VulkanRendererError {
20 /// The host supplied [`vk::Image::null()`].
21 #[error("vulkan target image is null")]
22 InvalidTargetImage,
23 /// The host supplied [`vk::ImageView::null()`].
24 #[error("vulkan target image view is null")]
25 InvalidTargetView,
26 /// At least one target dimension in physical pixels was zero.
27 #[error("vulkan target has invalid extent {width}x{height}")]
28 InvalidTargetExtent {
29 /// Target width in physical pixels.
30 width: u32,
31 /// Target height in physical pixels.
32 height: u32,
33 },
34 /// Resource allocation was requested from a context built without memory properties.
35 #[error("vulkan memory properties are required for this render path")]
36 MissingMemoryProperties,
37 /// No physical-device memory type satisfies both the type mask and required flags.
38 #[error("no compatible Vulkan memory type for bits {type_bits:#x} and flags {flags:#x}")]
39 NoCompatibleMemoryType {
40 /// Bit mask of memory types accepted by the resource requirements.
41 type_bits: u32,
42 /// Raw [`vk::MemoryPropertyFlags`] bits requested by the allocation.
43 flags: u32,
44 },
45 /// `vkCreateBuffer` failed.
46 #[error("failed to create Vulkan buffer: {result:?}")]
47 CreateBuffer {
48 /// Driver result.
49 result: vk::Result,
50 },
51 /// `vkAllocateMemory` failed.
52 #[error("failed to allocate Vulkan memory: {result:?}")]
53 AllocateMemory {
54 /// Driver result.
55 result: vk::Result,
56 },
57 /// `vkBindBufferMemory` failed.
58 #[error("failed to bind Vulkan buffer memory: {result:?}")]
59 BindBufferMemory {
60 /// Driver result.
61 result: vk::Result,
62 },
63 /// `vkMapMemory` failed.
64 #[error("failed to map Vulkan memory: {result:?}")]
65 MapMemory {
66 /// Driver result.
67 result: vk::Result,
68 },
69 /// `vkCreateImage` failed.
70 #[error("failed to create Vulkan image: {result:?}")]
71 CreateImage {
72 /// Driver result.
73 result: vk::Result,
74 },
75 /// `vkBindImageMemory` failed.
76 #[error("failed to bind Vulkan image memory: {result:?}")]
77 BindImageMemory {
78 /// Driver result.
79 result: vk::Result,
80 },
81 /// `vkCreateImageView` failed.
82 #[error("failed to create Vulkan image view: {result:?}")]
83 CreateImageView {
84 /// Driver result.
85 result: vk::Result,
86 },
87 /// `vkCreateSampler` failed.
88 #[error("failed to create Vulkan sampler: {result:?}")]
89 CreateSampler {
90 /// Driver result.
91 result: vk::Result,
92 },
93 /// `vkCreateDescriptorSetLayout` failed.
94 #[error("failed to create Vulkan descriptor set layout: {result:?}")]
95 CreateDescriptorSetLayout {
96 /// Driver result.
97 result: vk::Result,
98 },
99 /// `vkCreateDescriptorPool` failed.
100 #[error("failed to create Vulkan descriptor pool: {result:?}")]
101 CreateDescriptorPool {
102 /// Driver result.
103 result: vk::Result,
104 },
105 /// `vkAllocateDescriptorSets` failed.
106 #[error("failed to allocate Vulkan descriptor set: {result:?}")]
107 AllocateDescriptorSet {
108 /// Driver result.
109 result: vk::Result,
110 },
111 /// `vkCreateShaderModule` failed.
112 #[error("failed to create Vulkan shader module: {result:?}")]
113 CreateShaderModule {
114 /// Driver result.
115 result: vk::Result,
116 },
117 /// `vkCreateRenderPass` failed.
118 #[error("failed to create Vulkan render pass: {result:?}")]
119 CreateRenderPass {
120 /// Driver result.
121 result: vk::Result,
122 },
123 /// `vkCreatePipelineLayout` failed.
124 #[error("failed to create Vulkan pipeline layout: {result:?}")]
125 CreatePipelineLayout {
126 /// Driver result.
127 result: vk::Result,
128 },
129 /// `vkCreateGraphicsPipelines` failed.
130 #[error("failed to create Vulkan graphics pipeline: {result:?}")]
131 CreateGraphicsPipeline {
132 /// Driver result.
133 result: vk::Result,
134 },
135 /// `vkCreateFramebuffer` failed.
136 #[error("failed to create Vulkan framebuffer: {result:?}")]
137 CreateFramebuffer {
138 /// Driver result.
139 result: vk::Result,
140 },
141 /// `vkAllocateCommandBuffers` failed.
142 #[error("failed to allocate Vulkan command buffer: {result:?}")]
143 AllocateCommandBuffer {
144 /// Driver result.
145 result: vk::Result,
146 },
147 /// `vkBeginCommandBuffer` failed.
148 #[error("failed to begin Vulkan command buffer: {result:?}")]
149 BeginCommandBuffer {
150 /// Driver result.
151 result: vk::Result,
152 },
153 /// `vkEndCommandBuffer` failed.
154 #[error("failed to end Vulkan command buffer: {result:?}")]
155 EndCommandBuffer {
156 /// Driver result.
157 result: vk::Result,
158 },
159 /// `vkQueueSubmit` failed.
160 #[error("failed to submit Vulkan queue: {result:?}")]
161 QueueSubmit {
162 /// Driver result.
163 result: vk::Result,
164 },
165 /// `vkQueueWaitIdle` failed.
166 #[error("failed to wait Vulkan queue idle: {result:?}")]
167 QueueWaitIdle {
168 /// Driver result.
169 result: vk::Result,
170 },
171 /// The single fixed-size glyph atlas has no room for another rasterized glyph.
172 #[error("text atlas page limit reached")]
173 TextAtlasFull,
174 /// Opaque integration error supplied by the host.
175 #[error("vulkan host error: {0}")]
176 Host(String),
177}