use ash::vk;
use crate::Device;
#[derive(Debug)]
pub struct Semaphore {
device: Device,
handle: vk::Semaphore,
}
impl Semaphore {
pub fn new(device: Device) -> Result<Self, vk::Result> {
let info = vk::SemaphoreCreateInfo {
s_type: vk::StructureType::SEMAPHORE_CREATE_INFO,
p_next: std::ptr::null(),
flags: Default::default(),
};
let handle = unsafe { device.create_semaphore(&info, None)? };
#[cfg(feature = "log-objects")]
trace!("Created new VkSemaphore {handle:p}");
Ok(Semaphore {
handle,
device,
})
}
pub unsafe fn handle(&self) -> vk::Semaphore {
self.handle
}
}
impl Drop for Semaphore {
fn drop(&mut self) {
#[cfg(feature = "log-objects")]
trace!("Destroying VkSemaphore {:p}", self.handle);
unsafe {
self.device.destroy_semaphore(self.handle, None);
}
}
}