Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VK_KHR_get_physical_device_properties2 extension #400

Merged
merged 4 commits into from
Apr 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -7,6 +7,7 @@ pub use self::display_swapchain::DisplaySwapchain;
pub use self::draw_indirect_count::DrawIndirectCount;
pub use self::external_memory_fd::ExternalMemoryFd;
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 @@ -29,6 +30,7 @@ mod display_swapchain;
mod draw_indirect_count;
mod external_memory_fd;
mod get_memory_requirements2;
mod get_physical_device_properties2;
mod maintenance1;
mod maintenance3;
mod pipeline_executable_properties;
Expand Down