gpu_handle_types/backend.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3/// Identity of a compute backend. Used as a discriminant on error
4/// variants, budget accounting, `GpuContext`, `SyncPoint`, etc.
5///
6/// `#[non_exhaustive]` — future backend variants can land additively.
7#[non_exhaustive]
8#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
9pub enum BackendKind {
10 Cpu,
11
12 /// `wgpu::Device`-backed work submitted via `wgpu::Queue::submit`.
13 /// Emitted when the sync primitive is a `wgpu::SubmissionIndex` and
14 /// the producer does not expose a lower-level (Vulkan / D3D12 / Metal)
15 /// handle.
16 #[cfg(feature = "wgpu")]
17 Wgpu,
18
19 /// Native Vulkan submit — the producer holds a `VkDevice` and minted
20 /// a `VkSemaphore` directly (typically a timeline semaphore).
21 Vulkan,
22 /// Native D3D12 submit — `ID3D12CommandQueue::Signal` on an
23 /// `ID3D12Fence`.
24 D3D12,
25 /// Native D3D11 submit — `IDXGIKeyedMutex::AcquireSync` /
26 /// `ReleaseSync` on a shared texture.
27 D3D11,
28 /// Native Metal submit — `MTLCommandQueue::commandBuffer` followed by
29 /// `encodeSignalEvent` on an `MTLSharedEvent`.
30 Metal,
31 /// Native OpenGL — `glFenceSync` for a GL-only fence, or a GL
32 /// semaphore (`glGenSemaphoresEXT`) imported from a cross-API handle.
33 OpenGL,
34
35 #[cfg(feature = "opencl")]
36 OpenCl,
37 #[cfg(feature = "cuda")]
38 Cuda,
39
40 /// WebCodecs encode/decode target (browser). The caller consumes /
41 /// produces a `web_sys::VideoFrame` through a `VideoEncoder` /
42 /// `VideoDecoder`; as a shared-allocation target it selects the
43 /// OffscreenCanvas swapchain path. Gated on the `web-codecs` feature.
44 #[cfg(feature = "web-codecs")]
45 WebCodecs,
46
47 /// Android AHardwareBuffer export target. The
48 /// caller will consume an `AHardwareBuffer*` — NNAPI, foreign
49 /// Vulkan, cross-process IPC, etc.
50 #[cfg(target_os = "android")]
51 AHardwareBuffer,
52 /// App-window or MediaProjection VirtualDisplay presentation
53 /// surface.
54 #[cfg(target_os = "android")]
55 AndroidPresentation,
56 /// `ASurfaceControl` overlay layer.
57 #[cfg(target_os = "android")]
58 AndroidSurfaceControl,
59 /// `AImageWriter` feeding a foreign `ImageReader`.
60 #[cfg(target_os = "android")]
61 AImageWriter,
62 /// MediaCodec encoder input surface.
63 #[cfg(target_os = "android")]
64 MediaCodec,
65 /// Foreign GL ES context handoff.
66 #[cfg(target_os = "android")]
67 ForeignGl,
68 /// Foreign Vulkan device handoff.
69 #[cfg(target_os = "android")]
70 ForeignVulkan,
71}