use std::sync::Arc;
pub struct WgpuErrorScope {
open: bool,
device: Arc<wgpu::Device>,
}
impl WgpuErrorScope {
pub fn start(device: &Arc<wgpu::Device>) -> Self {
device.push_error_scope(wgpu::ErrorFilter::Validation);
device.push_error_scope(wgpu::ErrorFilter::OutOfMemory);
Self {
device: device.clone(),
open: true,
}
}
pub fn end(
mut self,
) -> [impl std::future::Future<Output = Option<wgpu::Error>> + Send + 'static; 2] {
self.open = false;
[self.device.pop_error_scope(), self.device.pop_error_scope()]
}
}
impl Drop for WgpuErrorScope {
fn drop(&mut self) {
if self.open {
drop(self.device.pop_error_scope());
drop(self.device.pop_error_scope());
}
}
}