use std::path::Path;
use nuvec_gpu::Device;
pub use nuvec_gpu::{DeviceInfo, NaxReason, NaxStatus};
use crate::{Error, Result};
pub fn is_available() -> bool {
Device::shared().is_some()
}
pub fn device_info() -> Option<&'static DeviceInfo> {
Device::shared().map(Device::info)
}
pub fn nax() -> NaxStatus {
Device::shared().map_or(NaxStatus::Off(NaxReason::NoDevice), Device::nax)
}
pub fn start_capture(path: impl AsRef<Path>) -> Result<()> {
let d = Device::shared()
.ok_or_else(|| Error::Backend("GPU capture: there is no Metal device".into()))?;
d.start_capture(path)
.map_err(|e| Error::Backend(e.to_string()))
}
pub fn stop_capture() {
if let Some(d) = Device::shared() {
d.stop_capture();
}
}
pub mod profile {
pub fn enabled() -> bool {
nuvec_gpu::profile::enabled()
}
pub fn report() -> Vec<(String, u64, f64)> {
nuvec_gpu::profile::report()
}
pub fn reset() {
nuvec_gpu::profile::reset();
}
}