diff --git a/vulkan-sys/src/structs/khr/presentinfokhr.rs b/vulkan-sys/src/structs/khr/presentinfokhr.rs index 5fd1345..1a5bc19 100644 --- a/vulkan-sys/src/structs/khr/presentinfokhr.rs +++ b/vulkan-sys/src/structs/khr/presentinfokhr.rs @@ -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 { + 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) + } + } }