oxigdal_gpu_advanced/
error.rs1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, GpuAdvancedError>;
7
8#[derive(Debug, Error)]
10pub enum GpuAdvancedError {
11 #[error("GPU device error: {0}")]
13 DeviceError(String),
14
15 #[error("Multi-GPU error: {0}")]
17 MultiGpuError(String),
18
19 #[error("Memory pool error: {0}")]
21 MemoryPoolError(String),
22
23 #[error("Memory allocation failed: size={size}, available={available}")]
25 AllocationFailed {
26 size: u64,
28 available: u64,
30 },
31
32 #[error("Memory out of bounds: offset={offset}, size={size}, pool_size={pool_size}")]
34 OutOfBounds {
35 offset: u64,
37 size: u64,
39 pool_size: u64,
41 },
42
43 #[error("Shader compiler error: {0}")]
45 ShaderCompilerError(String),
46
47 #[error("Shader optimization error: {0}")]
49 ShaderOptimizationError(String),
50
51 #[error("Shader validation error: {0}")]
53 ShaderValidationError(String),
54
55 #[error("Shader cache error: {0}")]
57 ShaderCacheError(String),
58
59 #[error("GPU computation error: {0}")]
61 ComputationError(String),
62
63 #[error("Buffer error: {0}")]
65 BufferError(String),
66
67 #[error("Synchronization error: {0}")]
69 SyncError(String),
70
71 #[error("Work stealing error: {0}")]
73 WorkStealingError(String),
74
75 #[error("Load balancing error: {0}")]
77 LoadBalancingError(String),
78
79 #[error("No GPU found matching criteria: {0}")]
81 GpuNotFound(String),
82
83 #[error("Invalid GPU index: {index}, total GPUs: {total}")]
85 InvalidGpuIndex {
86 index: usize,
88 total: usize,
90 },
91
92 #[error("Shader not found: {0}")]
94 ShaderNotFound(String),
95
96 #[error("ML inference error: {0}")]
98 MlInferenceError(String),
99
100 #[error("Terrain analysis error: {0}")]
102 TerrainAnalysisError(String),
103
104 #[error("Configuration error: {0}")]
106 ConfigError(String),
107
108 #[error("Invalid configuration: {0}")]
110 InvalidConfiguration(String),
111
112 #[error("IO error: {0}")]
114 IoError(#[from] std::io::Error),
115
116 #[error("Serialization error: {0}")]
118 SerializationError(#[from] serde_json::Error),
119
120 #[error("Base GPU error: {0}")]
122 GpuError(#[from] oxigdal_gpu::error::GpuError),
123
124 #[error("WGPU request device error: {0}")]
126 RequestDeviceError(#[from] wgpu::RequestDeviceError),
127
128 #[error("WGPU buffer async error: {0}")]
130 BufferAsyncError(#[from] wgpu::BufferAsyncError),
131
132 #[error("Invalid parameter: {0}")]
134 InvalidParameter(String),
135
136 #[error("Feature not implemented: {0}")]
138 NotImplemented(String),
139}
140
141impl GpuAdvancedError {
142 pub fn device_error(msg: impl Into<String>) -> Self {
144 Self::DeviceError(msg.into())
145 }
146
147 pub fn multi_gpu_error(msg: impl Into<String>) -> Self {
149 Self::MultiGpuError(msg.into())
150 }
151
152 pub fn memory_pool_error(msg: impl Into<String>) -> Self {
154 Self::MemoryPoolError(msg.into())
155 }
156
157 pub fn shader_compiler_error(msg: impl Into<String>) -> Self {
159 Self::ShaderCompilerError(msg.into())
160 }
161
162 pub fn computation_error(msg: impl Into<String>) -> Self {
164 Self::ComputationError(msg.into())
165 }
166
167 pub fn invalid_parameter(msg: impl Into<String>) -> Self {
169 Self::InvalidParameter(msg.into())
170 }
171}