From c54b4c1c24239dee00d85a53344fa44ec3efb671 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Mon, 4 Dec 2023 13:59:05 +0100 Subject: [PATCH] Fix result access --- vulkan-sys/src/structs/khr/presentinfokhr.rs | 10 +++++----- vulkan-sys/src/structs/mod.rs | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vulkan-sys/src/structs/khr/presentinfokhr.rs b/vulkan-sys/src/structs/khr/presentinfokhr.rs index 1a5bc19..0b1f7f1 100644 --- a/vulkan-sys/src/structs/khr/presentinfokhr.rs +++ b/vulkan-sys/src/structs/khr/presentinfokhr.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use crate::structs::raw_to_slice; +use crate::structs::{raw_to_slice, raw_to_slice_mut}; use std::os::raw::c_void; use std::ptr; @@ -74,11 +74,11 @@ impl VkPresentInfoKHR { swapchain_infos } - pub fn results(&self) -> &[VkResult] { - if self.waitSemaphoreCount == 0 || self.pResults != ptr::null_mut() { - &[] + pub fn results(&mut self) -> &mut [VkResult] { + if self.swapchainCount == 0 || self.pResults != ptr::null_mut() { + &mut [] } else { - raw_to_slice(self.pResults, self.waitSemaphoreCount) + raw_to_slice_mut(self.pResults, self.swapchainCount) } } } diff --git a/vulkan-sys/src/structs/mod.rs b/vulkan-sys/src/structs/mod.rs index 2891649..1d96b9e 100644 --- a/vulkan-sys/src/structs/mod.rs +++ b/vulkan-sys/src/structs/mod.rs @@ -21,3 +21,7 @@ use std::slice; fn raw_to_slice<'a, T: Clone>(pointer: *const T, size: u32) -> &'a [T] { unsafe { slice::from_raw_parts(pointer, size as usize) } } + +fn raw_to_slice_mut<'a, T: Clone>(pointer: *mut T, size: u32) -> &'a mut [T] { + unsafe { slice::from_raw_parts_mut(pointer, size as usize) } +}