sable-gpu 0.1.0

GPU abstraction layer for Sable Engine - wgpu-based rendering primitives
Documentation
//! Error types for the GPU crate.

use thiserror::Error;

/// GPU-specific errors.
#[derive(Debug, Error)]
pub enum GpuError {
    /// Failed to request a GPU adapter.
    #[error("failed to request GPU adapter: {0}")]
    AdapterRequest(#[from] wgpu::RequestAdapterError),

    /// Failed to request a GPU device.
    #[error("failed to request GPU device: {0}")]
    DeviceRequest(#[from] wgpu::RequestDeviceError),

    /// Failed to create a surface.
    #[error("failed to create surface: {0}")]
    SurfaceCreation(#[from] wgpu::CreateSurfaceError),

    /// Surface is incompatible with the adapter.
    #[error("surface is incompatible with adapter")]
    IncompatibleSurface,

    /// Failed to acquire the next swap chain texture.
    #[error("failed to acquire swap chain texture: {0}")]
    SwapChainAcquire(#[from] wgpu::SurfaceError),

    /// Shader compilation error.
    #[error("shader compilation error: {0}")]
    ShaderCompilation(String),

    /// Buffer creation error.
    #[error("buffer creation error: {0}")]
    BufferCreation(String),

    /// Pipeline creation error.
    #[error("pipeline creation error: {0}")]
    PipelineCreation(String),

    /// Platform error from window handling.
    #[error("platform error: {0}")]
    Platform(#[from] sable_platform::PlatformError),

    /// Raw window handle error.
    #[error("window handle error: {0}")]
    HandleError(#[from] raw_window_handle::HandleError),
}

/// Result type alias for GPU operations.
pub type Result<T> = std::result::Result<T, GpuError>;