79 lines
3.4 KiB
Rust
79 lines
3.4 KiB
Rust
//! # Error Module
|
|
//!
|
|
//! Defines `WsgError`, the application-level error type for all WGPU operations.
|
|
//! Every variant maps a specific failure mode to a user-friendly message via `thiserror`.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// Application-level errors for the WSG library.
|
|
/// Every variant maps a specific failure mode during GPU initialization or rendering
|
|
/// to a user-friendly message via `thiserror`.
|
|
#[derive(Error, Debug)]
|
|
pub enum WsgError {
|
|
/// The windowing system (winit) failed to create the surface — e.g. no display available.
|
|
/// Caller: `Context::new()` after `Instance::create_surface()`.
|
|
#[error("Window system error (winit)")]
|
|
WindowSystem,
|
|
|
|
/// No compatible graphics adapter was found for the given surface.
|
|
/// This can happen if no Vulkan/Metal/DX12 backend is installed or if the integrated GPU
|
|
/// is not exposed to the process.
|
|
/// Caller: `Context::new()` after `Instance::request_adapter()`.
|
|
#[error("No graphics adapter found")]
|
|
NoAdapter,
|
|
|
|
/// The requested device could not be obtained from the adapter — typically a driver bug
|
|
/// or insufficient capabilities.
|
|
/// Caller: `Context::new()` after `Adapter::request_device()`.
|
|
#[error("Failed to create WGPU device")]
|
|
DeviceCreation,
|
|
|
|
/// A shader module failed to compile or link. The inner string holds the compiler output.
|
|
/// Caller: renderer code that creates shaders via `Device::create_shader_module()`.
|
|
#[error("Shader compilation or creation error: {0}")]
|
|
ShaderError(String),
|
|
|
|
/// An internal WGPU error propagated from a device request failure.
|
|
/// Automatically converted via `thiserror`'s `#[from]`.
|
|
/// Caller: `Context::new()` — maps `wgpu::RequestDeviceError` into this variant.
|
|
#[error("Internal WGPU error: {0}")]
|
|
InternalWgpu(#[from] wgpu::RequestDeviceError),
|
|
|
|
/// The OS-level surface could not be created for the given window.
|
|
/// Common causes: unsupported display server, window closed before surface creation,
|
|
/// or platform-specific limitation.
|
|
/// Caller: `Context::new()` after `Instance::create_surface()`.
|
|
#[error("Failed to create rendering surface")]
|
|
SurfaceCreation(wgpu::CreateSurfaceError),
|
|
|
|
/// The surface is incompatible — no SRGB texture format and alpha mode are available on the device.
|
|
/// Caller: `Context::configure()` when selecting a render format/alpha mode from surface capabilities.
|
|
#[error("No compatible render format or alpha mode found for the surface")]
|
|
SurfaceIncompatible,
|
|
|
|
/// A timeout was encountered while acquiring a surface texture. Skip this frame and retry.
|
|
#[error("Frame acquisition timed out")]
|
|
FrameTimeout,
|
|
|
|
/// The window is occluded (minimized or behind another window). Skip until visible.
|
|
#[error("Window is occluded")]
|
|
Occluded,
|
|
|
|
/// The underlying surface changed — call configure() before retrying.
|
|
#[error("Surface configuration outdated; reconfigure required")]
|
|
Outdated,
|
|
|
|
/// The surface has been lost and needs to be recreated.
|
|
#[error("Surface lost")]
|
|
Lost,
|
|
|
|
/// A validation error inside get_current_texture() was raised.
|
|
#[error("Validation error during frame acquisition")]
|
|
Validation,
|
|
|
|
/// Successfully acquired the surface texture but it no longer matches the surface properties.
|
|
/// Reconfigure recommended for optimal performance.
|
|
#[error("Acquired suboptimal surface texture; reconfigure recommended")]
|
|
SuboptimalTexture,
|
|
}
|