brepkit_render/error.rs
1//! Error type for the offscreen renderer.
2
3/// Errors that can occur while rendering a solid offscreen.
4#[derive(Debug, thiserror::Error)]
5pub enum RenderError {
6 /// No wgpu adapter could be obtained (neither a real GPU nor a software
7 /// fallback). The crate is still usable on machines that do provide one.
8 #[error("no wgpu adapter available (tried real GPU then software fallback): {0}")]
9 NoAdapter(String),
10
11 /// The adapter could not provide a device/queue matching the request.
12 #[error("failed to request wgpu device: {0}")]
13 DeviceRequest(String),
14
15 /// A GPU buffer could not be mapped for readback.
16 #[error("failed to map GPU buffer for readback: {0}")]
17 BufferMap(String),
18
19 /// Polling the device for readback completion failed.
20 #[error("failed to poll wgpu device: {0}")]
21 Poll(String),
22
23 /// The requested render dimensions were invalid (zero width or height).
24 #[error("invalid render size: width and height must be non-zero, got {width}x{height}")]
25 InvalidSize {
26 /// Requested width in pixels.
27 width: u32,
28 /// Requested height in pixels.
29 height: u32,
30 },
31
32 /// The requested render dimensions exceed the adapter's maximum 2D texture
33 /// size, so a render would fail GPU validation.
34 #[error(
35 "render size {width}x{height} exceeds the device limit of {max}x{max} (max 2D texture dimension)"
36 )]
37 SizeTooLarge {
38 /// Requested width in pixels.
39 width: u32,
40 /// Requested height in pixels.
41 height: u32,
42 /// The adapter's `max_texture_dimension_2d`.
43 max: u32,
44 },
45
46 /// The tessellation produced a mesh that violates a renderer invariant
47 /// (e.g. an index buffer length not divisible by 3, an out-of-range vertex
48 /// index, or grouped face offsets that do not cover every triangle).
49 #[error("malformed tessellation mesh: {0}")]
50 MeshData(String),
51
52 /// The windowing event loop could not be created or run (viewer only).
53 #[error("windowing event loop error: {0}")]
54 EventLoop(String),
55
56 /// A window surface could not be created or configured (viewer only).
57 #[error("failed to create or configure window surface: {0}")]
58 SurfaceConfig(String),
59
60 /// Tessellation of the input solid failed.
61 #[error(transparent)]
62 Operations(#[from] brepkit_operations::OperationsError),
63
64 /// Topology traversal of the input solid failed.
65 #[error(transparent)]
66 Topology(#[from] brepkit_topology::TopologyError),
67}