synvael/crates/renderer/src/error.rs
Serkyo 19f79080b1 fix(renderer): correct resource teardown ordering in Drop
Replace ptr::read-based field consumption with Option<T> + take() for
sync primitives, GPU allocations, and the allocator itself. The prior
pattern left bitwise-duplicated values in the original fields, so Rust's
automatic field drop after Drop::drop returned freed the same heap
buffers (Vec backings inside SyncPrimitives) and Allocations twice.

The allocator is now explicitly dropped before destroy_device so its
own Drop impl, which releases vk::DeviceMemory blocks, runs while the
logical device is still valid. Swapchain image views are also now
destroyed before the swapchain, as required by the Vulkan spec.
2026-05-16 19:28:47 +02:00

33 lines
1.2 KiB
Rust

//! Error types for the renderer crate.
use thiserror::Error;
#[derive(Debug, Error)]
/// Enumerates all possible errors that can occur during rendering operations.
pub enum RendererError {
/// The Vulkan library could not be loaded from the system.
#[error("Failed to load Vulkan library")]
LoadFailed(#[from] ash::LoadingError),
/// A raw Vulkan result indicated a failure.
#[error("Vulkan error")]
VulkanError(#[from] ash::vk::Result),
/// No GPU was found that meets the engine's requirements.
#[error("No suitable GPU found")]
NoSuitableGpu,
/// An error occurred during GPU memory allocation.
#[error("GPU allocation error")]
AllocationError(#[from] gpu_allocator::AllocationError),
/// An I/O error occurred (e.g. reading a shader).
#[error("I/O error")]
IoError(#[from] std::io::Error),
/// An invalid string was encountered.
#[error("Invalid string")]
InvalidString,
/// The renderer's synchronization primitives were unavailable.
#[error("Synchronization primitives missing")]
SyncPrimitivesMissing,
/// The renderer's GPU memory allocator was unavailable.
#[error("GPU allocator missing")]
AllocatorMissing,
}