gpu_telemetry 0.2.1

High-level GPU telemetry background logger
Documentation
//! Basic telemetry for GPU monitors and a default logger.

/// A GPU heap that can represent memory on a GPU.
pub struct GpuHeap {
    /// GPU memory heap size.
    ///
    /// Supported on Vulkan.
    pub size: Option<u64>,

    /// GPU memory heap usage (relative to size).
    ///
    /// Supported on Vulkan and DX.
    pub usage: Option<u64>,

    /// GPU memory budget.
    ///
    /// Supported on DX and Vulkan.
    pub budget: Option<u64>,

    /// GPU reserved memory.
    ///
    /// Supported on DX.
    pub reservation: Option<u64>,

    /// GPU available memory for reservation.
    ///
    /// Supported on DX.
    pub available_for_reservation: Option<u64>,

    /// GPU memory heap locality (true for device-local).
    ///
    /// Supported on Vulkan and DX.
    pub dev_local: bool,
}

/// GPU sample of multiple heaps.
pub struct GpuSample {
    /// All the heaps sampled during this query.
    pub heaps: Vec<GpuHeap>,
}

/// Generic logger trait.
pub trait GpuLogger: Sized {
    /// Construct a new logger from no input.
    fn new() -> Self;

    /// Log a sample.
    fn log(&mut self, data: GpuSample);
}

/// Telemetry log of all GPU samples (default logger).
pub struct Telemetry {
    /// All samples queried.
    pub samples: Vec<GpuSample>,
}

impl GpuLogger for Telemetry {
    fn new() -> Self {
        Self {
            samples: Vec::new(),
        }
    }

    fn log(&mut self, data: GpuSample) {
        self.samples.push(data);
    }
}