Merge branch 'fix-getters' of https://github.com/Ralith/ash into Ralith-fix-getters

This commit is contained in:
Maik Klein 2018-11-12 11:24:33 +01:00
commit 03411ffbe0
2 changed files with 77 additions and 63 deletions

View file

@ -34,7 +34,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
} }
} }
unsafe fn get_device_group_peer_memory_features( unsafe fn get_device_group_peer_memory_features(
&self, &self,
heap_index: u32, heap_index: u32,
local_device_index: u32, local_device_index: u32,
@ -84,33 +84,31 @@ pub trait DeviceV1_1: DeviceV1_0 {
unsafe fn get_image_memory_requirements2( unsafe fn get_image_memory_requirements2(
&self, &self,
info: &vk::ImageMemoryRequirementsInfo2, info: &vk::ImageMemoryRequirementsInfo2,
) -> vk::MemoryRequirements2 { out: &mut vk::MemoryRequirements2,
let mut image_memory_requirements = mem::uninitialized(); ) {
self.fp_v1_1().get_image_memory_requirements2( self.fp_v1_1().get_image_memory_requirements2(
self.handle(), self.handle(),
info, info,
&mut image_memory_requirements, out,
); );
image_memory_requirements
} }
unsafe fn get_buffer_memory_requirements2( unsafe fn get_buffer_memory_requirements2(
&self, &self,
info: &vk::BufferMemoryRequirementsInfo2, info: &vk::BufferMemoryRequirementsInfo2,
) -> vk::MemoryRequirements2 { out: &mut vk::MemoryRequirements2,
let mut image_memory_requirements = mem::uninitialized(); ) {
self.fp_v1_1().get_buffer_memory_requirements2( self.fp_v1_1().get_buffer_memory_requirements2(
self.handle(), self.handle(),
info, info,
&mut image_memory_requirements, out,
); );
image_memory_requirements
} }
unsafe fn get_image_sparse_memory_requirements2( unsafe fn get_image_sparse_memory_requirements2_len(
&self, &self,
info: &vk::ImageSparseMemoryRequirementsInfo2, info: &vk::ImageSparseMemoryRequirementsInfo2,
) -> Vec<vk::SparseImageMemoryRequirements2> { ) -> usize {
let mut count = mem::uninitialized(); let mut count = mem::uninitialized();
self.fp_v1_1().get_image_sparse_memory_requirements2( self.fp_v1_1().get_image_sparse_memory_requirements2(
self.handle(), self.handle(),
@ -118,15 +116,21 @@ pub trait DeviceV1_1: DeviceV1_0 {
&mut count, &mut count,
ptr::null_mut(), ptr::null_mut(),
); );
let mut requirements = Vec::with_capacity(count as usize); count as usize
}
unsafe fn get_image_sparse_memory_requirements2(
&self,
info: &vk::ImageSparseMemoryRequirementsInfo2,
out: &mut [vk::SparseImageMemoryRequirements2],
) {
let mut count = out.len() as u32;
self.fp_v1_1().get_image_sparse_memory_requirements2( self.fp_v1_1().get_image_sparse_memory_requirements2(
self.handle(), self.handle(),
info, info,
&mut count, &mut count,
requirements.as_mut_ptr(), out.as_mut_ptr(),
); );
requirements.set_len(count as usize);
requirements
} }
unsafe fn trim_command_pool( unsafe fn trim_command_pool(
@ -215,14 +219,13 @@ pub trait DeviceV1_1: DeviceV1_0 {
unsafe fn get_descriptor_set_layout_support( unsafe fn get_descriptor_set_layout_support(
&self, &self,
create_info: &vk::DescriptorSetLayoutCreateInfo, create_info: &vk::DescriptorSetLayoutCreateInfo,
) -> vk::DescriptorSetLayoutSupport { out: &mut vk::DescriptorSetLayoutSupport,
let mut descriptor_set_layout_support = mem::uninitialized(); ) {
self.fp_v1_1().get_descriptor_set_layout_support( self.fp_v1_1().get_descriptor_set_layout_support(
self.handle(), self.handle(),
create_info, create_info,
&mut descriptor_set_layout_support, out,
); );
descriptor_set_layout_support
} }
} }

View file

@ -72,25 +72,30 @@ impl InstanceV1_1 for Instance {
pub trait InstanceV1_1: InstanceV1_0 { pub trait InstanceV1_1: InstanceV1_0 {
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1; fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
unsafe fn enumerate_physical_device_groups( unsafe fn enumerate_physical_device_groups_len(&self) -> usize {
&self,
) -> VkResult<Vec<vk::PhysicalDeviceGroupProperties>> {
let mut group_count = mem::uninitialized(); let mut group_count = mem::uninitialized();
self.fp_v1_1().enumerate_physical_device_groups( self.fp_v1_1().enumerate_physical_device_groups(
self.handle(), self.handle(),
&mut group_count, &mut group_count,
ptr::null_mut(), ptr::null_mut(),
); );
let mut physical_device_groups = Vec::with_capacity(group_count as usize); group_count as usize
let err_code = self.fp_v1_1().enumerate_physical_device_groups( }
self.handle(),
&mut group_count, fn enumerate_physical_device_groups(
physical_device_groups.as_mut_ptr(), &self,
); out: &mut [vk::PhysicalDeviceGroupProperties]
physical_device_groups.set_len(group_count as usize); ) -> VkResult<()> {
match err_code { unsafe {
vk::Result::SUCCESS => Ok(physical_device_groups), let mut group_count = out.len() as u32;
_ => Err(err_code), let err_code = self.fp_v1_1().enumerate_physical_device_groups(
self.handle(),
&mut group_count,
out.as_mut_ptr(),
);
if err_code == vk::Result::SUCCESS {
Ok(())
} else { Err(err_code) }
} }
} }
@ -107,14 +112,15 @@ pub trait InstanceV1_1: InstanceV1_0 {
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
format: vk::Format, format: vk::Format,
) -> vk::FormatProperties2 { out: &mut vk::FormatProperties2,
let mut format_prop = mem::uninitialized(); ) {
self.fp_v1_1().get_physical_device_format_properties2( unsafe {
physical_device, self.fp_v1_1().get_physical_device_format_properties2(
format, physical_device,
&mut format_prop, format,
); out,
format_prop );
}
} }
unsafe fn get_physical_device_image_format_properties2( unsafe fn get_physical_device_image_format_properties2(
@ -164,18 +170,19 @@ pub trait InstanceV1_1: InstanceV1_0 {
unsafe fn get_physical_device_memory_properties2( unsafe fn get_physical_device_memory_properties2(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceMemoryProperties2 { out: &mut vk::PhysicalDeviceMemoryProperties2,
let mut memory_prop = mem::uninitialized(); ) {
self.fp_v1_1() unsafe {
.get_physical_device_memory_properties2(physical_device, &mut memory_prop); self.fp_v1_1()
memory_prop .get_physical_device_memory_properties2(physical_device, out);
}
} }
unsafe fn get_physical_device_sparse_image_format_properties2( unsafe fn get_physical_device_sparse_image_format_properties2_len(
&self, &self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2, format_info: &vk::PhysicalDeviceSparseImageFormatInfo2,
) -> Vec<vk::SparseImageFormatProperties2> { ) -> usize {
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(
@ -184,61 +191,65 @@ pub trait InstanceV1_1: InstanceV1_0 {
&mut format_count, &mut format_count,
ptr::null_mut(), ptr::null_mut(),
); );
let mut format_prop = Vec::with_capacity(format_count as usize); format_count as usize
}
unsafe fn get_physical_device_sparse_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2,
out: &mut [vk::SparseImageFormatProperties2],
) {
let mut format_count = out.len() as u32;
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(), out.as_mut_ptr(),
); );
format_prop.set_len(format_count as usize);
format_prop
} }
unsafe 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 { out: &mut vk::ExternalBufferProperties,
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, out,
); );
image_format_prop
} }
unsafe 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 { out: &mut vk::ExternalFenceProperties,
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, out,
); );
fence_prop
} }
unsafe 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 { out: &mut vk::ExternalSemaphoreProperties,
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, out,
); );
semaphore_prop
} }
} }