Skip to main content

av_denoise/
accelerate.rs

1use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr};
2
3#[derive(Debug, Copy, Clone, Eq, PartialEq, IntoStaticStr, EnumString, EnumIter, Display)]
4#[strum(serialize_all = "snake_case")]
5/// A hardware accelerator that can be used to compute any target metrics.
6pub enum Accelerator {
7    #[cfg(any(feature = "cuda", docsrs))]
8    #[cfg_attr(docsrs, doc(cfg(feature = "cuda")))]
9    /// Run kernels using the Nvidia CUDA backend.
10    ///
11    /// Nvidia GPUs only (duh.)
12    Cuda,
13    #[cfg(any(feature = "rocm", docsrs))]
14    #[cfg_attr(docsrs, doc(cfg(feature = "rocm")))]
15    /// Run kernels using the AMD ROCm backend.
16    ///
17    /// AMD GPUs only (duh.)
18    Rocm,
19    #[cfg(any(feature = "vulkan", docsrs))]
20    #[cfg_attr(docsrs, doc(cfg(feature = "vulkan")))]
21    /// Run kernels using the WGPU Vulkan backend.
22    ///
23    /// This is the most lightweight and portable accelerator
24    /// because it supports all platforms and GPUs that support basic
25    /// compute shaders.
26    Vulkan,
27    #[cfg(any(feature = "metal", docsrs))]
28    #[cfg_attr(docsrs, doc(cfg(feature = "metal")))]
29    /// Run kernels using the WGPU Metal backend.
30    ///
31    /// This is the only accelerator available for Apple Silicon.
32    Metal,
33    #[cfg(any(feature = "cpu", docsrs))]
34    #[cfg_attr(docsrs, doc(cfg(feature = "cpu")))]
35    /// Run kernels using the CPU JIT compiler.
36    Cpu,
37}
38
39/// Returns the enabled, default accelerators, in order of what to attempt.
40pub fn get_default_accelerators() -> Vec<Accelerator> {
41    use strum::IntoEnumIterator;
42
43    let mut accelerator = Vec::new();
44    for enabled in Accelerator::iter() {
45        accelerator.push(enabled);
46    }
47
48    accelerator
49}