2023-01-10 11:17:13 +11:00
|
|
|
use ash::prelude::VkResult;
|
|
|
|
use ash::vk;
|
|
|
|
|
|
|
|
pub struct SyncObjects {
|
|
|
|
pub image_available: vk::Semaphore,
|
|
|
|
pub render_finished: vk::Semaphore,
|
2023-01-10 14:54:54 +11:00
|
|
|
pub in_flight: vk::Fence,
|
2023-01-10 11:17:13 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
impl SyncObjects {
|
|
|
|
pub fn new(device: &ash::Device) -> VkResult<SyncObjects> {
|
|
|
|
unsafe {
|
2023-01-10 14:54:54 +11:00
|
|
|
let image_available =
|
|
|
|
device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?;
|
|
|
|
let render_finished =
|
|
|
|
device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?;
|
|
|
|
let in_flight = device.create_fence(
|
|
|
|
&vk::FenceCreateInfo::builder()
|
|
|
|
.flags(vk::FenceCreateFlags::SIGNALED)
|
|
|
|
.build(),
|
|
|
|
None,
|
|
|
|
)?;
|
2023-01-10 11:17:13 +11:00
|
|
|
|
|
|
|
Ok(SyncObjects {
|
|
|
|
image_available,
|
|
|
|
render_finished,
|
2023-01-10 14:54:54 +11:00
|
|
|
in_flight,
|
2023-01-10 11:17:13 +11:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2023-01-10 14:54:54 +11:00
|
|
|
}
|