gpu_handle_types/
external_queue.rs1#[cfg(feature = "opencl")]
4use crate::ClQueueRef;
5#[cfg(feature = "cuda")]
6use crate::CudaStreamRef;
7use crate::{BackendKind, MtlCommandBufferRef};
8
9#[non_exhaustive]
23pub enum ExternalQueue<'a> {
24 #[cfg(feature = "wgpu")]
25 WgpuEncoder(&'a mut wgpu::CommandEncoder),
26 #[cfg(feature = "opencl")]
27 OpenClQueue(&'a ClQueueRef),
28 #[cfg(feature = "cuda")]
29 CudaStream(&'a CudaStreamRef),
30 MetalCommandBuffer(&'a MtlCommandBufferRef),
31 Cpu,
32 _Phantom(std::marker::PhantomData<&'a ()>),
33}
34
35impl ExternalQueue<'_> {
36 pub fn backend(&self) -> BackendKind {
37 match self {
38 Self::Cpu => BackendKind::Cpu,
39 #[cfg(feature = "wgpu")]
40 Self::WgpuEncoder(_) => BackendKind::Wgpu,
41 #[cfg(feature = "opencl")]
42 Self::OpenClQueue(_) => BackendKind::OpenCl,
43 #[cfg(feature = "cuda")]
44 Self::CudaStream(_) => BackendKind::Cuda,
45 #[cfg(feature = "wgpu")]
46 Self::MetalCommandBuffer(_) => BackendKind::Wgpu,
47 #[cfg(not(feature = "wgpu"))]
48 Self::MetalCommandBuffer(_) => BackendKind::Cpu,
49 Self::_Phantom(_) => BackendKind::Cpu,
50 }
51 }
52}
53
54impl core::fmt::Debug for ExternalQueue<'_> {
55 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56 f.write_str("ExternalQueue")
57 }
58}