1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum GpuError {
8 #[error("GPU not available: no compatible device found")]
10 NotAvailable,
11
12 #[error("GPU out of memory: required {required} bytes, available {available} bytes")]
14 OutOfMemory { required: u64, available: u64 },
15
16 #[error("shader compilation failed: {0}")]
18 ShaderCompilation(String),
19
20 #[error("GPU device lost")]
22 DeviceLost,
23
24 #[error("GPU execution failed: {0}")]
26 Execution(String),
27
28 #[error("buffer mapping failed: {0}")]
30 BufferMapping(String),
31
32 #[error("grid too large for GPU: {dims:?} voxels ({total} total), max supported: {max}")]
34 GridTooLarge {
35 dims: [usize; 3],
36 total: usize,
37 max: usize,
38 },
39
40 #[error("mesh too large for GPU: {triangles} triangles, max supported: {max}")]
42 MeshTooLarge { triangles: usize, max: usize },
43}
44
45pub type GpuResult<T> = Result<T, GpuError>;