use crate::Result;
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct GpuDeviceInfo {
pub index: u32,
pub name: Option<String>,
pub total_bytes: u64,
pub free_bytes: u64,
pub used_bytes: u64,
}
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct ProcessGpuInfo {
pub used_bytes: u64,
pub is_per_process: bool,
pub source: GpuQuerySource,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpuQuerySource {
Dxgi,
Nvml,
NvidiaSmi,
}
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct Snapshot {
pub ram_bytes: u64,
pub gpu: Option<ProcessGpuInfo>,
pub gpu_device: Option<GpuDeviceInfo>,
}
impl Snapshot {
pub fn now(device_index: u32) -> Result<Self> {
let ram_bytes = crate::ram::process_rss()?;
let gpu = crate::gpu::process_gpu_info(device_index).ok();
let gpu_device = crate::gpu::device_info(device_index).ok();
Ok(Self {
ram_bytes,
gpu,
gpu_device,
})
}
}