You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
858 B

use crate::render::Device;
use ash::{version::DeviceV1_0, vk};
use std::rc::Rc;
pub struct Fence {
handle: vk::Fence,
pub device: Rc<Device>,
}
impl Fence {
pub fn create(device: Rc<Device>) -> Result<Rc<Self>, vk::Result> {
let create_info = vk::FenceCreateInfo {
flags: vk::FenceCreateFlags::SIGNALED,
..Default::default()
};
let handle = unsafe { device.create_fence(&create_info, None)? };
Ok(Rc::new(Self { handle, device }))
}
pub fn create_all(
device: Rc<Device>,
num: usize,
) -> Result<Vec<Rc<Self>>, vk::Result> {
(0..num).map(|_| Self::create(device.clone())).collect()
}
}
impl Drop for Fence {
fn drop(&mut self) {
unsafe {
self.device.destroy_fence(self.handle, None);
}
}
}
impl std::ops::Deref for Fence {
type Target = vk::Fence;
fn deref(&self) -> &Self::Target {
&self.handle
}
}
// EOF