rust_vulkan_test/src/vulkan/vk_semaphore.rs
Florian RICHER c0367144a6
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
First render !!!
2024-11-22 17:06:39 +01:00

29 lines
No EOL
761 B
Rust

use crate::vulkan::VkDevice;
use ash::vk;
use std::sync::Arc;
pub struct VkSemaphore {
device: Arc<VkDevice>,
pub(super) handle: vk::Semaphore,
}
impl VkSemaphore {
pub fn new(device: &Arc<VkDevice>) -> anyhow::Result<Self> {
let semaphore_info = vk::SemaphoreCreateInfo::default();
let semaphore = unsafe { device.handle.create_semaphore(&semaphore_info, None)? };
log::debug!("Semaphore created ({semaphore:?})");
Ok(Self {
device: device.clone(),
handle: semaphore,
})
}
}
impl Drop for VkSemaphore {
fn drop(&mut self) {
unsafe { self.device.handle.destroy_semaphore(self.handle, None) };
log::debug!("Semaphore destroyed ({:?})", self.handle);
}
}