gpu-handle-types 0.2.0

Typed, owned native GPU resource handles (Vulkan, D3D11/12, Metal, OpenGL, CUDA, OpenCL, DMA-BUF, IOSurface, AHardwareBuffer, WebGPU, ...), cross-API sync points and video pixel formats, for passing GPU resources between libraries.
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::BackendKind;

/// Stable identity of a physical GPU / CPU / accelerator. Used as cache
/// key in multi-GPU setups and as an equality test for
/// `Error::DeviceMismatch`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DeviceId {
    /// The host CPU pseudo-device — the target of the CPU fallback
    /// backend. A single canonical identity (the host has one logical
    /// CPU compute target from the library's perspective), so it carries
    /// no payload and all CPU devices compare equal.
    Cpu,
    VulkanUuid([u8; 16]),
    CudaUuid([u8; 16]),
    DxgiLuid {
        high: i32,
        low: u32,
    },
    MetalRegistryId(u64),
    OpenCl {
        platform: String,
        device: String,
    },
}

#[derive(Debug, Clone)]
pub struct DeviceInfo {
    pub backend: BackendKind,
    pub name: String,
    pub id: DeviceId,
    pub vendor_id: Option<u32>,
    pub device_pci_id: Option<u32>,
    pub dedicated_memory_bytes: u64,
    pub is_integrated: bool,
}