use crate::{
errors::{Error, ErrorKind},
monitor::telemetry::GpuSample,
};
use std::time::Duration;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(any(target_os = "windows", target_os = "linux"))]
mod vulkan;
pub trait GpuTelemetry: Sized {
fn new(adapter: usize) -> Result<Self, Error>;
fn wait_at_most(&self, interval: Duration) -> Result<(), Error>;
fn query(&self) -> Result<GpuSample, Error>;
}
#[cfg(target_os = "windows")]
pub use windows::DxGpuQuery;
#[cfg(any(target_os = "windows", target_os = "linux"))]
pub use vulkan::VulkanGpuQuery;
pub struct NopQuery {}
impl GpuTelemetry for NopQuery {
fn new(_adapter: usize) -> Result<Self, Error> {
Ok(Self {})
}
fn query(&self) -> Result<GpuSample, Error> {
Err(Error {
msg: "using nop backend",
kind: ErrorKind::UnsupportedFeature,
})
}
fn wait_at_most(&self, _interval: Duration) -> Result<(), Error> {
Err(Error {
msg: "using nop backend",
kind: ErrorKind::UnsupportedFeature,
})
}
}