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
This commit is contained in:
Rua 2021-04-18 21:34:28 +02:00 committed by GitHub
parent 9dcfbd2bf1
commit 5eb39fed85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 162 additions and 0 deletions

View file

@ -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
}
}

View file

@ -10,6 +10,7 @@ pub use self::external_fence_fd::ExternalFenceFd;
pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::external_semaphore_fd::ExternalSemaphoreFd;
pub use self::get_memory_requirements2::GetMemoryRequirements2;
pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2;
pub use self::maintenance1::Maintenance1;
pub use self::maintenance3::Maintenance3;
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
@ -35,6 +36,7 @@ mod external_fence_fd;
mod external_memory_fd;
mod external_semaphore_fd;
mod get_memory_requirements2;
mod get_physical_device_properties2;
mod maintenance1;
mod maintenance3;
mod pipeline_executable_properties;