-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VK_KHR_get_physical_device_properties2 extension (#400)
* Add VK_KHR_get_physical_device_properties2 extension * Use &mut for output instead, per PR comment
- Loading branch information
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
ash/src/extensions/khr/get_physical_device_properties2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#![allow(dead_code)] | ||
use crate::prelude::*; | ||
use crate::version::{EntryV1_0, InstanceV1_0}; | ||
use crate::vk; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
use std::ptr; | ||
|
||
#[derive(Clone)] | ||
pub struct GetPhysicalDeviceProperties2 { | ||
handle: vk::Instance, | ||
get_physical_device_properties2_fn: vk::KhrGetPhysicalDeviceProperties2Fn, | ||
} | ||
|
||
impl GetPhysicalDeviceProperties2 { | ||
pub fn new<E: EntryV1_0, I: InstanceV1_0>( | ||
entry: &E, | ||
instance: &I, | ||
) -> GetPhysicalDeviceProperties2 { | ||
let get_physical_device_properties2_fn = | ||
vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { | ||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) | ||
}); | ||
GetPhysicalDeviceProperties2 { | ||
handle: instance.handle(), | ||
get_physical_device_properties2_fn, | ||
} | ||
} | ||
|
||
pub fn name() -> &'static CStr { | ||
vk::KhrGetPhysicalDeviceProperties2Fn::name() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html>"] | ||
unsafe fn get_physical_device_features2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
features: &mut vk::PhysicalDeviceFeatures2KHR, | ||
) { | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_features2_khr(physical_device, features); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFormatProperties2KHR.html>"] | ||
unsafe fn get_physical_device_format_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
format: vk::Format, | ||
format_properties: &mut vk::FormatProperties2KHR, | ||
) { | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_format_properties2_khr(physical_device, format, format_properties); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html>"] | ||
unsafe fn get_physical_device_image_format_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR, | ||
image_format_properties: &mut vk::ImageFormatProperties2KHR, | ||
) -> VkResult<()> { | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_image_format_properties2_khr( | ||
physical_device, | ||
image_format_info, | ||
image_format_properties, | ||
) | ||
.result() | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2KHR.html>"] | ||
unsafe fn get_physical_device_memory_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR, | ||
) { | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_memory_properties2_khr(physical_device, memory_properties); | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceProperties2KHR.html>"] | ||
unsafe fn get_physical_device_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
properties: &mut vk::PhysicalDeviceProperties2KHR, | ||
) { | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_properties2_khr(physical_device, properties); | ||
} | ||
|
||
unsafe fn get_physical_device_queue_family_properties2_len( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
) -> usize { | ||
let mut count = mem::zeroed(); | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_queue_family_properties2_khr( | ||
physical_device, | ||
&mut count, | ||
ptr::null_mut(), | ||
); | ||
count as usize | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2KHR.html>"] | ||
unsafe fn get_physical_device_queue_family_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
queue_family_properties: &mut [vk::QueueFamilyProperties2KHR], | ||
) { | ||
let mut count = queue_family_properties.len() as u32; | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_queue_family_properties2_khr( | ||
physical_device, | ||
&mut count, | ||
queue_family_properties.as_mut_ptr(), | ||
); | ||
} | ||
|
||
unsafe fn get_physical_device_sparse_image_format_properties2_len( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, | ||
) -> usize { | ||
let mut count = mem::zeroed(); | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_sparse_image_format_properties2_khr( | ||
physical_device, | ||
format_info, | ||
&mut count, | ||
ptr::null_mut(), | ||
); | ||
count as usize | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2KHR.html>"] | ||
unsafe fn get_physical_device_sparse_image_format_properties2( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, | ||
properties: &mut [vk::SparseImageFormatProperties2KHR], | ||
) { | ||
let mut count = properties.len() as u32; | ||
self.get_physical_device_properties2_fn | ||
.get_physical_device_sparse_image_format_properties2_khr( | ||
physical_device, | ||
format_info, | ||
&mut count, | ||
properties.as_mut_ptr(), | ||
); | ||
} | ||
|
||
pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { | ||
&self.get_physical_device_properties2_fn | ||
} | ||
|
||
pub fn instance(&self) -> vk::Instance { | ||
self.handle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters