Skip to main content

wgpu_native_texture_interop/
error.rs

1use thiserror::Error;
2
3use crate::sync::SyncMechanism;
4
5/// Why a particular interop path is not available.
6#[derive(Clone, Debug, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum UnsupportedReason {
9    /// The platform code path exists but has not been implemented yet.
10    PlatformNotImplemented,
11    /// No wgpu backend could be detected on the host device.
12    HostBackendUnavailable,
13    /// The frame type requires a different wgpu backend than the host is using
14    /// (e.g. `VulkanExternalImage` on a Metal device).
15    HostBackendMismatch,
16    /// A native frame variant (e.g. `VulkanExternalImage`) is defined in the
17    /// API but the corresponding import logic is not yet implemented.
18    NativeImportNotYetImplemented,
19}
20
21/// Errors that can occur during frame import or synchronization.
22#[derive(Debug, Error)]
23#[non_exhaustive]
24pub enum InteropError {
25    /// The requested interop path is not supported for the given reason.
26    #[error("unsupported interop path: {0:?}")]
27    Unsupported(UnsupportedReason),
28
29    /// The wgpu backend on the host device does not match what the frame
30    /// source requires.
31    #[error("backend mismatch: expected {expected}, found {actual}")]
32    BackendMismatch {
33        expected: &'static str,
34        actual: &'static str,
35    },
36
37    /// The frame data is invalid (e.g. a zero-valued FBO id).
38    #[error("invalid frame: {0}")]
39    InvalidFrame(&'static str),
40
41    /// The synchronizer received a [`SyncMechanism`] it does not handle.
42    #[error("unsupported synchronization mechanism: {0:?}")]
43    UnsupportedSynchronization(SyncMechanism),
44
45    /// A surfman-level error occurred while preparing the frame.
46    #[error("surfman interop failed: {0}")]
47    Surfman(String),
48
49    /// A Vulkan API call failed during import.
50    #[error("vulkan interop failed: {0}")]
51    Vulkan(String),
52
53    /// A Metal API call failed during import.
54    #[error("metal interop failed: {0}")]
55    Metal(String),
56
57    /// A GL API call failed during import.
58    #[error("OpenGL interop failed: {0}")]
59    OpenGl(String),
60
61    /// A D3D12 or DXGI API call failed during import.
62    #[error("D3D12 interop failed: {0}")]
63    Dx12(String),
64
65    /// An ANGLE EGL API call failed during D3D11 share-handle import.
66    #[error("ANGLE EGL interop failed: {0}")]
67    Angle(String),
68}