Skip to main content

sable_gpu/
error.rs

1//! Error types for the GPU crate.
2
3use thiserror::Error;
4
5/// GPU-specific errors.
6#[derive(Debug, Error)]
7pub enum GpuError {
8    /// Failed to request a GPU adapter.
9    #[error("failed to request GPU adapter: {0}")]
10    AdapterRequest(#[from] wgpu::RequestAdapterError),
11
12    /// Failed to request a GPU device.
13    #[error("failed to request GPU device: {0}")]
14    DeviceRequest(#[from] wgpu::RequestDeviceError),
15
16    /// Failed to create a surface.
17    #[error("failed to create surface: {0}")]
18    SurfaceCreation(#[from] wgpu::CreateSurfaceError),
19
20    /// Surface is incompatible with the adapter.
21    #[error("surface is incompatible with adapter")]
22    IncompatibleSurface,
23
24    /// Failed to acquire the next swap chain texture.
25    #[error("failed to acquire swap chain texture: {0}")]
26    SwapChainAcquire(#[from] wgpu::SurfaceError),
27
28    /// Shader compilation error.
29    #[error("shader compilation error: {0}")]
30    ShaderCompilation(String),
31
32    /// Buffer creation error.
33    #[error("buffer creation error: {0}")]
34    BufferCreation(String),
35
36    /// Pipeline creation error.
37    #[error("pipeline creation error: {0}")]
38    PipelineCreation(String),
39
40    /// Platform error from window handling.
41    #[error("platform error: {0}")]
42    Platform(#[from] sable_platform::PlatformError),
43
44    /// Raw window handle error.
45    #[error("window handle error: {0}")]
46    HandleError(#[from] raw_window_handle::HandleError),
47}
48
49/// Result type alias for GPU operations.
50pub type Result<T> = std::result::Result<T, GpuError>;