Mark some more functions as unsafe

This commit is contained in:
Tim 2018-08-03 12:51:03 +02:00
parent 59d49b2159
commit cda39148e9
2 changed files with 67 additions and 79 deletions

View file

@ -34,23 +34,21 @@ pub trait DeviceV1_1: DeviceV1_0 {
} }
} }
fn get_device_group_peer_memory_features( unsafe fn get_device_group_peer_memory_features(
&self, &self,
heap_index: vk::uint32_t, heap_index: vk::uint32_t,
local_device_index: vk::uint32_t, local_device_index: vk::uint32_t,
remote_device_index: vk::uint32_t, remote_device_index: vk::uint32_t,
) -> vk::PeerMemoryFeatureFlags { ) -> vk::PeerMemoryFeatureFlags {
unsafe { let mut peer_memory_features = mem::uninitialized();
let mut peer_memory_features = mem::uninitialized(); self.fp_v1_1().get_device_group_peer_memory_features(
self.fp_v1_1().get_device_group_peer_memory_features( self.handle(),
self.handle(), heap_index,
heap_index, local_device_index,
local_device_index, remote_device_index,
remote_device_index, &mut peer_memory_features,
&mut peer_memory_features, );
); peer_memory_features
peer_memory_features
}
} }
unsafe fn cmd_set_device_mask( unsafe fn cmd_set_device_mask(

View file

@ -145,23 +145,21 @@ pub trait InstanceV1_1: InstanceV1_0 {
} }
} }
fn get_physical_device_image_format_properties2( unsafe fn get_physical_device_image_format_properties2(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceImageFormatInfo2, format_info: &vk::PhysicalDeviceImageFormatInfo2,
) -> VkResult<vk::ImageFormatProperties2> { ) -> VkResult<vk::ImageFormatProperties2> {
unsafe { let mut image_format_prop = mem::uninitialized();
let mut image_format_prop = mem::uninitialized(); let err_code = self.fp_v1_1().get_physical_device_image_format_properties2(
let err_code = self.fp_v1_1().get_physical_device_image_format_properties2( physical_device,
physical_device, format_info,
format_info, &mut image_format_prop,
&mut image_format_prop, );
); if err_code == vk::Result::SUCCESS {
if err_code == vk::Result::SUCCESS { Ok(image_format_prop)
Ok(image_format_prop) } else {
} else { Err(err_code)
Err(err_code)
}
} }
} }
@ -199,82 +197,74 @@ pub trait InstanceV1_1: InstanceV1_0 {
} }
} }
fn get_physical_device_sparse_image_format_properties2( unsafe fn get_physical_device_sparse_image_format_properties2(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2, format_info: &vk::PhysicalDeviceSparseImageFormatInfo2,
) -> Vec<vk::SparseImageFormatProperties2> { ) -> Vec<vk::SparseImageFormatProperties2> {
unsafe { let mut format_count = 0;
let mut format_count = 0; self.fp_v1_1()
self.fp_v1_1() .get_physical_device_sparse_image_format_properties2(
.get_physical_device_sparse_image_format_properties2( physical_device,
physical_device, format_info,
format_info, &mut format_count,
&mut format_count, ptr::null_mut(),
ptr::null_mut(), );
); let mut format_prop = Vec::with_capacity(format_count as usize);
let mut format_prop = Vec::with_capacity(format_count as usize); self.fp_v1_1()
self.fp_v1_1() .get_physical_device_sparse_image_format_properties2(
.get_physical_device_sparse_image_format_properties2( physical_device,
physical_device, format_info,
format_info, &mut format_count,
&mut format_count, format_prop.as_mut_ptr(),
format_prop.as_mut_ptr(), );
); format_prop.set_len(format_count as usize);
format_prop.set_len(format_count as usize); format_prop
format_prop
}
} }
fn get_physical_device_external_buffer_properties( unsafe fn get_physical_device_external_buffer_properties(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
external_buffer_info: &vk::PhysicalDeviceExternalBufferInfo, external_buffer_info: &vk::PhysicalDeviceExternalBufferInfo,
) -> vk::ExternalBufferProperties { ) -> vk::ExternalBufferProperties {
unsafe { let mut image_format_prop = mem::uninitialized();
let mut image_format_prop = mem::uninitialized(); self.fp_v1_1()
self.fp_v1_1() .get_physical_device_external_buffer_properties(
.get_physical_device_external_buffer_properties( physical_device,
physical_device, external_buffer_info,
external_buffer_info, &mut image_format_prop,
&mut image_format_prop, );
); image_format_prop
image_format_prop
}
} }
fn get_physical_device_external_fence_properties( unsafe fn get_physical_device_external_fence_properties(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
external_fence_info: &vk::PhysicalDeviceExternalFenceInfo, external_fence_info: &vk::PhysicalDeviceExternalFenceInfo,
) -> vk::ExternalFenceProperties { ) -> vk::ExternalFenceProperties {
unsafe { let mut fence_prop = mem::uninitialized();
let mut fence_prop = mem::uninitialized(); self.fp_v1_1()
self.fp_v1_1() .get_physical_device_external_fence_properties(
.get_physical_device_external_fence_properties( physical_device,
physical_device, external_fence_info,
external_fence_info, &mut fence_prop,
&mut fence_prop, );
); fence_prop
fence_prop
}
} }
fn get_physical_device_external_semaphore_properties( unsafe fn get_physical_device_external_semaphore_properties(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
external_semaphore_info: &vk::PhysicalDeviceExternalSemaphoreInfo, external_semaphore_info: &vk::PhysicalDeviceExternalSemaphoreInfo,
) -> vk::ExternalSemaphoreProperties { ) -> vk::ExternalSemaphoreProperties {
unsafe { let mut semaphore_prop = mem::uninitialized();
let mut semaphore_prop = mem::uninitialized(); self.fp_v1_1()
self.fp_v1_1() .get_physical_device_external_semaphore_properties(
.get_physical_device_external_semaphore_properties( physical_device,
physical_device, external_semaphore_info,
external_semaphore_info, &mut semaphore_prop,
&mut semaphore_prop, );
); semaphore_prop
semaphore_prop
}
} }
} }