Skip to content

Commit

Permalink
Add VK_KHR_get_physical_device_properties2 extension (#400)
Browse files Browse the repository at this point in the history
* Add VK_KHR_get_physical_device_properties2 extension

* Use &mut for output instead, per PR comment
  • Loading branch information
Rua committed Apr 18, 2021
1 parent 9dcfbd2 commit 5eb39fe
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
160 changes: 160 additions & 0 deletions ash/src/extensions/khr/get_physical_device_properties2.rs
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
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 5eb39fe

Please sign in to comment.