use thiserror::Error;
#[derive(Debug, Error)]
pub enum VulkanError {
#[error("failed to load Vulkan loader: {0}")]
LoaderLoad(#[source] ash::LoadingError),
#[error("validation layer not available: {0}")]
ValidationUnavailable(String),
#[error("no compute-capable physical device found")]
NoDevice,
#[error("Vulkan error: {context}: {code:?}")]
VkResult {
context: &'static str,
code: ash::vk::Result,
},
#[error("no memory type with required property flags available")]
NoSuitableMemoryType,
#[error("length mismatch: expected {expected} elements, got {got}")]
LengthMismatch {
expected: usize,
got: usize,
},
#[error("VkFFT error {code}")]
VkFft {
code: i32,
},
#[error("not implemented in Vulkan backend: {0}")]
Unsupported(&'static str),
#[error("scalar type not supported by Vulkan backend: {0}")]
UnsupportedScalar(&'static str),
#[error("invalid plan: {0}")]
InvalidPlan(&'static str),
}
impl VulkanError {
pub(crate) fn vk(context: &'static str, code: ash::vk::Result) -> Self {
Self::VkResult { context, code }
}
}