Skip to main content

bedrock_vk/
result_str.rs

1use crate::*;
2
3pub const fn result_to_str(r: VkResult) -> &'static str {
4    match r {
5        // Success Codes //
6        x if x == VK_SUCCESS => "Command successfully completed",
7        x if x == VK_NOT_READY => "A fence or query has not yet completed",
8        x if x == VK_TIMEOUT => "A wait operation has not completed in the specified time",
9        x if x == VK_EVENT_SET => "An event is signaled",
10        x if x == VK_EVENT_RESET => "An event is unsignaled",
11        x if x == VK_INCOMPLETE => "A return array was too small for the result",
12        #[cfg(feature = "VK_KHR_swapchain")]
13        x if x == VK_SUBOPTIMAL_KHR => "Sub-optimal swapchain",
14        // Error Codes //
15        x if x == VK_ERROR_OUT_OF_HOST_MEMORY => "A host memory allocation has failed",
16        x if x == VK_ERROR_OUT_OF_DEVICE_MEMORY => "A device memory allocation has failed",
17        x if x == VK_ERROR_INITIALIZATION_FAILED => {
18            "Initialization of an object could not be completed for implementation-specific reasons"
19        }
20        x if x == VK_ERROR_DEVICE_LOST => "The logical or physical device has been lost",
21        x if x == VK_ERROR_MEMORY_MAP_FAILED => "Mapping of a memory object has failed",
22        x if x == VK_ERROR_LAYER_NOT_PRESENT => "A requested layer is not presented or could not be loaded",
23        x if x == VK_ERROR_EXTENSION_NOT_PRESENT => "A requested extension is not supported",
24        x if x == VK_ERROR_FEATURE_NOT_PRESENT => "A requested feature is not supported",
25        x if x == VK_ERROR_INCOMPATIBLE_DRIVER => {
26            "The requested version of Vulkan is not supported by the driver or is otherwise incompatible for implementation-specific reasons"
27        }
28        x if x == VK_ERROR_TOO_MANY_OBJECTS => "Too many objects of the type have already been created",
29        x if x == VK_ERROR_FORMAT_NOT_SUPPORTED => "A requested format is not supported on this device",
30        x if x == VK_ERROR_FRAGMENTED_POOL => "A pool allocation has failed due to fragmentation of the pool's memory",
31        #[cfg(feature = "VK_KHR_surface")]
32        x if x == VK_ERROR_SURFACE_LOST_KHR => "Surface lost",
33        #[cfg(feature = "VK_KHR_surface")]
34        x if x == VK_ERROR_NATIVE_WINDOW_IN_USE_KHR => "Native window is in use",
35        #[cfg(feature = "VK_KHR_swapchain")]
36        x if x == VK_ERROR_OUT_OF_DATE_KHR => "Out of date",
37        #[cfg(feature = "VK_KHR_display_swapchain")]
38        x if x == VK_ERROR_INCOMPATIBLE_DISPLAY_KHR => {
39            "The display used by a swapchain does not use the same presentable image layout"
40        }
41        #[cfg(feature = "VK_EXT_debug_report")]
42        x if x == VK_ERROR_VALIDATION_FAILED_EXT => "Validation failed",
43        #[cfg(feature = "VK_NV_glsl_shader")]
44        x if x == VK_ERROR_INVALID_SHADER_NV => "Invalid GLSL shader",
45        #[cfg(feature = "VK_KHR_maintenance1")]
46        x if x == VK_ERROR_OUT_OF_POOL_MEMORY_KHR => "A pool memory allocation has failed",
47        #[cfg(feature = "VK_KHR_external_memory")]
48        x if x == VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR => {
49            "An external handle is not a valid handle of ths specified type"
50        }
51        #[cfg(feature = "VK_KHR_buffer_device_address")]
52        x if x == VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR => {
53            "A buffer creation or memory allocation failed because the requested address is not available"
54        }
55        #[cfg(feature = "VK_EXT_descriptor_indexing")]
56        x if x == VK_ERROR_FRAGMENTATION_EXT => "A descriptor pool creation has failed due to fragmentation",
57        _ => "Unknown or extension-specific error",
58    }
59}