Improve present info

This commit is contained in:
hodasemi 2023-12-04 09:46:31 +01:00
parent f08c63b0c2
commit f318ae03fd

View file

@ -1,8 +1,14 @@
use crate::prelude::*;
use crate::structs::raw_to_slice;
use std::os::raw::c_void;
use std::ptr;
pub struct PresentInfoSwapchain {
pub swapchain: VkSwapchainKHR,
pub index: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct VkPresentInfoKHR {
@ -41,4 +47,38 @@ impl VkPresentInfoKHR {
},
}
}
pub fn wait_semaphores(&self) -> &[VkSemaphore] {
if self.waitSemaphoreCount == 0 {
&[]
} else {
raw_to_slice(self.pWaitSemaphores, self.waitSemaphoreCount)
}
}
pub fn swapchain_info(&self) -> Vec<PresentInfoSwapchain> {
let mut swapchain_infos = Vec::with_capacity(self.swapchainCount as usize);
if self.swapchainCount != 0 {
let swapchains = raw_to_slice(self.pSwapchains, self.swapchainCount);
let indices = raw_to_slice(self.pImageIndices, self.swapchainCount);
for i in 0..(self.swapchainCount as usize) {
swapchain_infos.push(PresentInfoSwapchain {
swapchain: swapchains[i],
index: indices[i],
});
}
}
swapchain_infos
}
pub fn results(&self) -> &[VkResult] {
if self.waitSemaphoreCount == 0 || self.pResults != ptr::null_mut() {
&[]
} else {
raw_to_slice(self.pResults, self.waitSemaphoreCount)
}
}
}