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.
 
 
 

41 lines
833 B

use crate::render::Device;
use ash::{version::DeviceV1_0, vk};
use std::rc::Rc;
pub struct Semaphore {
handle: vk::Semaphore,
pub device: Rc<Device>,
}
impl Semaphore {
pub fn create(device: Rc<Device>) -> Result<Rc<Self>, vk::Result> {
let create_info = vk::SemaphoreCreateInfo::default();
let handle = unsafe { device.create_semaphore(&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 Semaphore {
fn drop(&mut self) {
unsafe {
self.device.destroy_semaphore(self.handle, None);
}
}
}
impl std::ops::Deref for Semaphore {
type Target = vk::Semaphore;
fn deref(&self) -> &Self::Target {
&self.handle
}
}
// EOF