librashader/librashader-runtime-vk/tests/hello_triangle/syncobjects.rs
chyyran 0adf3505ec rt: mark frame and create APIs unsafe
This doesn't cause an API break in the C API but we don't actually make an attempt to verify that it's safe to access any of the device contexts.
2023-02-16 17:33:47 -05:00

36 lines
1.1 KiB
Rust

use ash::prelude::VkResult;
use ash::vk;
pub struct SyncObjects {
pub image_available: Vec<vk::Semaphore>,
pub render_finished: Vec<vk::Semaphore>,
pub in_flight: Vec<vk::Fence>,
}
impl SyncObjects {
pub fn new(device: &ash::Device, frames_in_flight: usize) -> VkResult<SyncObjects> {
unsafe {
let mut image_available = Vec::new();
let mut render_finished = Vec::new();
let mut in_flight = Vec::new();
for _ in 0..frames_in_flight {
image_available
.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
render_finished
.push(device.create_semaphore(&vk::SemaphoreCreateInfo::default(), None)?);
in_flight.push(device.create_fence(
&vk::FenceCreateInfo::builder().flags(vk::FenceCreateFlags::SIGNALED),
None,
)?)
}
Ok(SyncObjects {
image_available,
render_finished,
in_flight,
})
}
}
}