Add missing unsafe qualifiers
This commit is contained in:
parent
c62172bdf8
commit
445c72fa26
|
@ -652,13 +652,11 @@ pub trait DeviceV1_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_wait_idle(&self) -> VkResult<()> {
|
unsafe fn device_wait_idle(&self) -> VkResult<()> {
|
||||||
unsafe {
|
let err_code = self.fp_v1_0().device_wait_idle(self.handle());
|
||||||
let err_code = self.fp_v1_0().device_wait_idle(self.handle());
|
match err_code {
|
||||||
match err_code {
|
vk::Result::SUCCESS => Ok(()),
|
||||||
vk::Result::SUCCESS => Ok(()),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1604,39 +1602,33 @@ pub trait DeviceV1_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_image_subresource_layout(
|
unsafe fn get_image_subresource_layout(
|
||||||
&self,
|
&self,
|
||||||
image: vk::Image,
|
image: vk::Image,
|
||||||
subresource: vk::ImageSubresource,
|
subresource: vk::ImageSubresource,
|
||||||
) -> vk::SubresourceLayout {
|
) -> vk::SubresourceLayout {
|
||||||
unsafe {
|
let mut layout = mem::uninitialized();
|
||||||
let mut layout = mem::uninitialized();
|
self.fp_v1_0().get_image_subresource_layout(
|
||||||
self.fp_v1_0().get_image_subresource_layout(
|
self.handle(),
|
||||||
self.handle(),
|
image,
|
||||||
image,
|
&subresource,
|
||||||
&subresource,
|
&mut layout,
|
||||||
&mut layout,
|
);
|
||||||
);
|
layout
|
||||||
layout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
|
unsafe fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
|
||||||
unsafe {
|
let mut mem_req = mem::uninitialized();
|
||||||
let mut mem_req = mem::uninitialized();
|
self.fp_v1_0()
|
||||||
self.fp_v1_0()
|
.get_image_memory_requirements(self.handle(), image, &mut mem_req);
|
||||||
.get_image_memory_requirements(self.handle(), image, &mut mem_req);
|
mem_req
|
||||||
mem_req
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
|
unsafe fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
|
||||||
unsafe {
|
let mut mem_req = mem::uninitialized();
|
||||||
let mut mem_req = mem::uninitialized();
|
self.fp_v1_0()
|
||||||
self.fp_v1_0()
|
.get_buffer_memory_requirements(self.handle(), buffer, &mut mem_req);
|
||||||
.get_buffer_memory_requirements(self.handle(), buffer, &mut mem_req);
|
mem_req
|
||||||
mem_req
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn allocate_memory(
|
unsafe fn allocate_memory(
|
||||||
|
|
|
@ -31,100 +31,93 @@ impl Surface {
|
||||||
CStr::from_bytes_with_nul(b"VK_KHR_surface\0").expect("Wrong extension string")
|
CStr::from_bytes_with_nul(b"VK_KHR_surface\0").expect("Wrong extension string")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_physical_device_surface_support_khr(
|
pub unsafe fn get_physical_device_surface_support_khr(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
queue_index: u32,
|
queue_index: u32,
|
||||||
surface: vk::SurfaceKHR,
|
surface: vk::SurfaceKHR,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
unsafe {
|
let mut b = mem::uninitialized();
|
||||||
let mut b = mem::uninitialized();
|
self.surface_fn.get_physical_device_surface_support_khr(
|
||||||
self.surface_fn.get_physical_device_surface_support_khr(
|
physical_device,
|
||||||
physical_device,
|
queue_index,
|
||||||
queue_index,
|
surface,
|
||||||
surface,
|
&mut b,
|
||||||
&mut b,
|
);
|
||||||
);
|
b > 0
|
||||||
b > 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn get_physical_device_surface_present_modes_khr(
|
|
||||||
|
pub unsafe fn get_physical_device_surface_present_modes_khr(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
surface: vk::SurfaceKHR,
|
surface: vk::SurfaceKHR,
|
||||||
) -> VkResult<Vec<vk::PresentModeKHR>> {
|
) -> VkResult<Vec<vk::PresentModeKHR>> {
|
||||||
unsafe {
|
let mut count = 0;
|
||||||
let mut count = 0;
|
self.surface_fn
|
||||||
self.surface_fn
|
.get_physical_device_surface_present_modes_khr(
|
||||||
.get_physical_device_surface_present_modes_khr(
|
|
||||||
physical_device,
|
|
||||||
surface,
|
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
|
||||||
let err_code = self
|
|
||||||
.surface_fn
|
|
||||||
.get_physical_device_surface_present_modes_khr(
|
|
||||||
physical_device,
|
|
||||||
surface,
|
|
||||||
&mut count,
|
|
||||||
v.as_mut_ptr(),
|
|
||||||
);
|
|
||||||
v.set_len(count as usize);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_physical_device_surface_capabilities_khr(
|
|
||||||
&self,
|
|
||||||
physical_device: vk::PhysicalDevice,
|
|
||||||
surface: vk::SurfaceKHR,
|
|
||||||
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
|
|
||||||
unsafe {
|
|
||||||
let mut surface_capabilities = mem::uninitialized();
|
|
||||||
let err_code = self
|
|
||||||
.surface_fn
|
|
||||||
.get_physical_device_surface_capabilities_khr(
|
|
||||||
physical_device,
|
|
||||||
surface,
|
|
||||||
&mut surface_capabilities,
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(surface_capabilities),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_physical_device_surface_formats_khr(
|
|
||||||
&self,
|
|
||||||
physical_device: vk::PhysicalDevice,
|
|
||||||
surface: vk::SurfaceKHR,
|
|
||||||
) -> VkResult<Vec<vk::SurfaceFormatKHR>> {
|
|
||||||
unsafe {
|
|
||||||
let mut count = 0;
|
|
||||||
self.surface_fn.get_physical_device_surface_formats_khr(
|
|
||||||
physical_device,
|
physical_device,
|
||||||
surface,
|
surface,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.surface_fn.get_physical_device_surface_formats_khr(
|
let err_code = self
|
||||||
|
.surface_fn
|
||||||
|
.get_physical_device_surface_present_modes_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
surface,
|
surface,
|
||||||
&mut count,
|
&mut count,
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(v),
|
vk::Result::SUCCESS => Ok(v),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn get_physical_device_surface_capabilities_khr(
|
||||||
|
&self,
|
||||||
|
physical_device: vk::PhysicalDevice,
|
||||||
|
surface: vk::SurfaceKHR,
|
||||||
|
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
|
||||||
|
let mut surface_capabilities = mem::uninitialized();
|
||||||
|
let err_code = self
|
||||||
|
.surface_fn
|
||||||
|
.get_physical_device_surface_capabilities_khr(
|
||||||
|
physical_device,
|
||||||
|
surface,
|
||||||
|
&mut surface_capabilities,
|
||||||
|
);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::SUCCESS => Ok(surface_capabilities),
|
||||||
|
_ => Err(err_code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn get_physical_device_surface_formats_khr(
|
||||||
|
&self,
|
||||||
|
physical_device: vk::PhysicalDevice,
|
||||||
|
surface: vk::SurfaceKHR,
|
||||||
|
) -> VkResult<Vec<vk::SurfaceFormatKHR>> {
|
||||||
|
let mut count = 0;
|
||||||
|
self.surface_fn.get_physical_device_surface_formats_khr(
|
||||||
|
physical_device,
|
||||||
|
surface,
|
||||||
|
&mut count,
|
||||||
|
ptr::null_mut(),
|
||||||
|
);
|
||||||
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
|
let err_code = self.surface_fn.get_physical_device_surface_formats_khr(
|
||||||
|
physical_device,
|
||||||
|
surface,
|
||||||
|
&mut count,
|
||||||
|
v.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
v.set_len(count as usize);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::SUCCESS => Ok(v),
|
||||||
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,31 +95,29 @@ impl Swapchain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_swapchain_images_khr(
|
pub unsafe fn get_swapchain_images_khr(
|
||||||
&self,
|
&self,
|
||||||
swapchain: vk::SwapchainKHR,
|
swapchain: vk::SwapchainKHR,
|
||||||
) -> VkResult<Vec<vk::Image>> {
|
) -> VkResult<Vec<vk::Image>> {
|
||||||
unsafe {
|
let mut count = 0;
|
||||||
let mut count = 0;
|
self.swapchain_fn.get_swapchain_images_khr(
|
||||||
self.swapchain_fn.get_swapchain_images_khr(
|
self.handle,
|
||||||
self.handle,
|
swapchain,
|
||||||
swapchain,
|
&mut count,
|
||||||
&mut count,
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.swapchain_fn.get_swapchain_images_khr(
|
let err_code = self.swapchain_fn.get_swapchain_images_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
swapchain,
|
swapchain,
|
||||||
&mut count,
|
&mut count,
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(v),
|
vk::Result::SUCCESS => Ok(v),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,25 +87,23 @@ impl<V: FunctionPointers> Instance<V> {
|
||||||
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;
|
||||||
|
|
||||||
fn enumerate_physical_device_groups(&self) -> VkResult<Vec<vk::PhysicalDeviceGroupProperties>> {
|
unsafe fn enumerate_physical_device_groups(&self) -> VkResult<Vec<vk::PhysicalDeviceGroupProperties>> {
|
||||||
unsafe {
|
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);
|
||||||
let mut physical_device_groups = Vec::with_capacity(group_count as usize);
|
let err_code = self.fp_v1_1().enumerate_physical_device_groups(
|
||||||
let err_code = self.fp_v1_1().enumerate_physical_device_groups(
|
self.handle(),
|
||||||
self.handle(),
|
&mut group_count,
|
||||||
&mut group_count,
|
physical_device_groups.as_mut_ptr(),
|
||||||
physical_device_groups.as_mut_ptr(),
|
);
|
||||||
);
|
physical_device_groups.set_len(group_count as usize);
|
||||||
physical_device_groups.set_len(group_count as usize);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::SUCCESS => Ok(physical_device_groups),
|
||||||
vk::Result::SUCCESS => Ok(physical_device_groups),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,20 +116,18 @@ pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
.get_physical_device_properties2(physical_device, prop);
|
.get_physical_device_properties2(physical_device, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_format_properties2(
|
unsafe fn get_physical_device_format_properties2(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
format: vk::Format,
|
format: vk::Format,
|
||||||
) -> vk::FormatProperties2 {
|
) -> vk::FormatProperties2 {
|
||||||
unsafe {
|
let mut format_prop = mem::uninitialized();
|
||||||
let mut format_prop = mem::uninitialized();
|
self.fp_v1_1().get_physical_device_format_properties2(
|
||||||
self.fp_v1_1().get_physical_device_format_properties2(
|
physical_device,
|
||||||
physical_device,
|
format,
|
||||||
format,
|
&mut format_prop,
|
||||||
&mut format_prop,
|
);
|
||||||
);
|
format_prop
|
||||||
format_prop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_physical_device_image_format_properties2(
|
unsafe fn get_physical_device_image_format_properties2(
|
||||||
|
@ -152,19 +148,17 @@ pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_queue_family_properties2_len(
|
unsafe fn get_physical_device_queue_family_properties2_len(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
unsafe {
|
let mut queue_count = 0;
|
||||||
let mut queue_count = 0;
|
self.fp_v1_1().get_physical_device_queue_family_properties2(
|
||||||
self.fp_v1_1().get_physical_device_queue_family_properties2(
|
physical_device,
|
||||||
physical_device,
|
&mut queue_count,
|
||||||
&mut queue_count,
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
);
|
||||||
);
|
queue_count as usize
|
||||||
queue_count as usize
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_physical_device_queue_family_properties2(
|
unsafe fn get_physical_device_queue_family_properties2(
|
||||||
|
@ -180,16 +174,14 @@ pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
) -> vk::PhysicalDeviceMemoryProperties2 {
|
||||||
unsafe {
|
let mut memory_prop = mem::uninitialized();
|
||||||
let mut memory_prop = mem::uninitialized();
|
self.fp_v1_1()
|
||||||
self.fp_v1_1()
|
.get_physical_device_memory_properties2(physical_device, &mut memory_prop);
|
||||||
.get_physical_device_memory_properties2(physical_device, &mut memory_prop);
|
memory_prop
|
||||||
memory_prop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_physical_device_sparse_image_format_properties2(
|
unsafe fn get_physical_device_sparse_image_format_properties2(
|
||||||
|
@ -291,12 +283,12 @@ pub trait InstanceV1_0 {
|
||||||
Ok(Device::from_raw(device, device_fn))
|
Ok(Device::from_raw(device, device_fn))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_device_proc_addr(
|
unsafe fn get_device_proc_addr(
|
||||||
&self,
|
&self,
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
p_name: *const c_char,
|
p_name: *const c_char,
|
||||||
) -> vk::PFN_vkVoidFunction {
|
) -> vk::PFN_vkVoidFunction {
|
||||||
unsafe { self.fp_v1_0().get_device_proc_addr(device, p_name) }
|
self.fp_v1_0().get_device_proc_addr(device, p_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||||
|
@ -304,23 +296,21 @@ pub trait InstanceV1_0 {
|
||||||
.destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
|
.destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_format_properties(
|
unsafe fn get_physical_device_format_properties(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
format: vk::Format,
|
format: vk::Format,
|
||||||
) -> vk::FormatProperties {
|
) -> vk::FormatProperties {
|
||||||
unsafe {
|
let mut format_prop = mem::uninitialized();
|
||||||
let mut format_prop = mem::uninitialized();
|
self.fp_v1_0().get_physical_device_format_properties(
|
||||||
self.fp_v1_0().get_physical_device_format_properties(
|
physical_device,
|
||||||
physical_device,
|
format,
|
||||||
format,
|
&mut format_prop,
|
||||||
&mut format_prop,
|
);
|
||||||
);
|
format_prop
|
||||||
format_prop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_image_format_properties(
|
unsafe fn get_physical_device_image_format_properties(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
format: vk::Format,
|
format: vk::Format,
|
||||||
|
@ -329,126 +319,112 @@ pub trait InstanceV1_0 {
|
||||||
usage: vk::ImageUsageFlags,
|
usage: vk::ImageUsageFlags,
|
||||||
flags: vk::ImageCreateFlags,
|
flags: vk::ImageCreateFlags,
|
||||||
) -> VkResult<vk::ImageFormatProperties> {
|
) -> VkResult<vk::ImageFormatProperties> {
|
||||||
unsafe {
|
let mut image_format_prop = mem::uninitialized();
|
||||||
let mut image_format_prop = mem::uninitialized();
|
let err_code = self.fp_v1_0().get_physical_device_image_format_properties(
|
||||||
let err_code = self.fp_v1_0().get_physical_device_image_format_properties(
|
physical_device,
|
||||||
physical_device,
|
format,
|
||||||
format,
|
typ,
|
||||||
typ,
|
tiling,
|
||||||
tiling,
|
usage,
|
||||||
usage,
|
flags,
|
||||||
flags,
|
&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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_memory_properties(
|
unsafe fn get_physical_device_memory_properties(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> vk::PhysicalDeviceMemoryProperties {
|
) -> vk::PhysicalDeviceMemoryProperties {
|
||||||
unsafe {
|
let mut memory_prop = mem::uninitialized();
|
||||||
let mut memory_prop = mem::uninitialized();
|
self.fp_v1_0()
|
||||||
self.fp_v1_0()
|
.get_physical_device_memory_properties(physical_device, &mut memory_prop);
|
||||||
.get_physical_device_memory_properties(physical_device, &mut memory_prop);
|
memory_prop
|
||||||
memory_prop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_properties(
|
unsafe fn get_physical_device_properties(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> vk::PhysicalDeviceProperties {
|
) -> vk::PhysicalDeviceProperties {
|
||||||
unsafe {
|
let mut prop = mem::uninitialized();
|
||||||
let mut prop = mem::uninitialized();
|
self.fp_v1_0()
|
||||||
self.fp_v1_0()
|
.get_physical_device_properties(physical_device, &mut prop);
|
||||||
.get_physical_device_properties(physical_device, &mut prop);
|
prop
|
||||||
prop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_queue_family_properties(
|
unsafe fn get_physical_device_queue_family_properties(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> Vec<vk::QueueFamilyProperties> {
|
) -> Vec<vk::QueueFamilyProperties> {
|
||||||
unsafe {
|
let mut queue_count = 0;
|
||||||
let mut queue_count = 0;
|
self.fp_v1_0().get_physical_device_queue_family_properties(
|
||||||
self.fp_v1_0().get_physical_device_queue_family_properties(
|
physical_device,
|
||||||
physical_device,
|
&mut queue_count,
|
||||||
&mut queue_count,
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
);
|
||||||
);
|
let mut queue_families_vec = Vec::with_capacity(queue_count as usize);
|
||||||
let mut queue_families_vec = Vec::with_capacity(queue_count as usize);
|
self.fp_v1_0().get_physical_device_queue_family_properties(
|
||||||
self.fp_v1_0().get_physical_device_queue_family_properties(
|
physical_device,
|
||||||
physical_device,
|
&mut queue_count,
|
||||||
&mut queue_count,
|
queue_families_vec.as_mut_ptr(),
|
||||||
queue_families_vec.as_mut_ptr(),
|
);
|
||||||
);
|
queue_families_vec.set_len(queue_count as usize);
|
||||||
queue_families_vec.set_len(queue_count as usize);
|
queue_families_vec
|
||||||
queue_families_vec
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_physical_device_features(
|
unsafe fn get_physical_device_features(
|
||||||
&self,
|
&self,
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> vk::PhysicalDeviceFeatures {
|
) -> vk::PhysicalDeviceFeatures {
|
||||||
unsafe {
|
let mut prop = mem::uninitialized();
|
||||||
let mut prop = mem::uninitialized();
|
self.fp_v1_0()
|
||||||
self.fp_v1_0()
|
.get_physical_device_features(physical_device, &mut prop);
|
||||||
.get_physical_device_features(physical_device, &mut prop);
|
prop
|
||||||
prop
|
}
|
||||||
|
|
||||||
|
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
||||||
|
let mut num = mem::uninitialized();
|
||||||
|
self.fp_v1_0()
|
||||||
|
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
|
||||||
|
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
||||||
|
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
||||||
|
self.handle(),
|
||||||
|
&mut num,
|
||||||
|
physical_devices.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
physical_devices.set_len(num as usize);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::SUCCESS => Ok(physical_devices),
|
||||||
|
_ => Err(err_code),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
unsafe fn enumerate_device_extension_properties(
|
||||||
unsafe {
|
|
||||||
let mut num = mem::uninitialized();
|
|
||||||
self.fp_v1_0()
|
|
||||||
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
|
|
||||||
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
|
||||||
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
|
||||||
self.handle(),
|
|
||||||
&mut num,
|
|
||||||
physical_devices.as_mut_ptr(),
|
|
||||||
);
|
|
||||||
physical_devices.set_len(num as usize);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(physical_devices),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enumerate_device_extension_properties(
|
|
||||||
&self,
|
&self,
|
||||||
device: vk::PhysicalDevice,
|
device: vk::PhysicalDevice,
|
||||||
) -> Result<Vec<vk::ExtensionProperties>, vk::Result> {
|
) -> Result<Vec<vk::ExtensionProperties>, vk::Result> {
|
||||||
unsafe {
|
let mut num = 0;
|
||||||
let mut num = 0;
|
self.fp_v1_0().enumerate_device_extension_properties(
|
||||||
self.fp_v1_0().enumerate_device_extension_properties(
|
device,
|
||||||
device,
|
ptr::null(),
|
||||||
ptr::null(),
|
&mut num,
|
||||||
&mut num,
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
);
|
||||||
);
|
let mut data = Vec::with_capacity(num as usize);
|
||||||
let mut data = Vec::with_capacity(num as usize);
|
let err_code = self.fp_v1_0().enumerate_device_extension_properties(
|
||||||
let err_code = self.fp_v1_0().enumerate_device_extension_properties(
|
device,
|
||||||
device,
|
ptr::null(),
|
||||||
ptr::null(),
|
&mut num,
|
||||||
&mut num,
|
data.as_mut_ptr(),
|
||||||
data.as_mut_ptr(),
|
);
|
||||||
);
|
data.set_len(num as usize);
|
||||||
data.set_len(num as usize);
|
match err_code {
|
||||||
match err_code {
|
vk::Result::SUCCESS => Ok(data),
|
||||||
vk::Result::SUCCESS => Ok(data),
|
_ => Err(err_code),
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue