#[cfg(feature = "opencl")]
use crate::ClQueueRef;
#[cfg(feature = "cuda")]
use crate::CudaStreamRef;
use crate::{BackendKind, MtlCommandBufferRef};
#[non_exhaustive]
pub enum ExternalQueue<'a> {
#[cfg(feature = "wgpu")]
WgpuEncoder(&'a mut wgpu::CommandEncoder),
#[cfg(feature = "opencl")]
OpenClQueue(&'a ClQueueRef),
#[cfg(feature = "cuda")]
CudaStream(&'a CudaStreamRef),
MetalCommandBuffer(&'a MtlCommandBufferRef),
Cpu,
_Phantom(std::marker::PhantomData<&'a ()>),
}
impl ExternalQueue<'_> {
pub fn backend(&self) -> BackendKind {
match self {
Self::Cpu => BackendKind::Cpu,
#[cfg(feature = "wgpu")]
Self::WgpuEncoder(_) => BackendKind::Wgpu,
#[cfg(feature = "opencl")]
Self::OpenClQueue(_) => BackendKind::OpenCl,
#[cfg(feature = "cuda")]
Self::CudaStream(_) => BackendKind::Cuda,
#[cfg(feature = "wgpu")]
Self::MetalCommandBuffer(_) => BackendKind::Wgpu,
#[cfg(not(feature = "wgpu"))]
Self::MetalCommandBuffer(_) => BackendKind::Cpu,
Self::_Phantom(_) => BackendKind::Cpu,
}
}
}
impl core::fmt::Debug for ExternalQueue<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str("ExternalQueue")
}
}