From 1b246ab5f8438a98bf6d55106fd999021e9b49de Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 10 Aug 2024 22:48:12 +0200 Subject: [PATCH] extensions/khr: Add VK_KHR_get_display_properties2 extension --- Changelog.md | 1 + ash/src/extensions/ext/metal_objects.rs | 1 + .../extensions/khr/get_display_properties2.rs | 143 ++++++++++++++++++ ash/src/extensions/khr/mod.rs | 1 + 4 files changed, 146 insertions(+) create mode 100644 ash/src/extensions/khr/get_display_properties2.rs diff --git a/Changelog.md b/Changelog.md index 25c0beb62..e3f4c3e70 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Update Vulkan-Headers to 1.3.296 (#910) +- Added `VK_KHR_get_display_properties2` instance extension (#932) - Added `VK_EXT_metal_objects` device extension (#942) ## [0.38.0] - 2024-04-01 diff --git a/ash/src/extensions/ext/metal_objects.rs b/ash/src/extensions/ext/metal_objects.rs index f5e615734..a7891a7d5 100644 --- a/ash/src/extensions/ext/metal_objects.rs +++ b/ash/src/extensions/ext/metal_objects.rs @@ -5,6 +5,7 @@ use crate::vk; impl crate::ext::metal_objects::Device { /// #[inline] + #[doc(alias = "vkExportMetalObjectsEXT")] pub unsafe fn export_metal_objects( &self, metal_objects_info: &mut vk::ExportMetalObjectsInfoEXT<'_>, diff --git a/ash/src/extensions/khr/get_display_properties2.rs b/ash/src/extensions/khr/get_display_properties2.rs new file mode 100644 index 000000000..061269f8d --- /dev/null +++ b/ash/src/extensions/khr/get_display_properties2.rs @@ -0,0 +1,143 @@ +//! + +use crate::prelude::*; +use crate::vk; +use core::mem; +use core::ptr; + +impl crate::khr::get_display_properties2::Instance { + /// Retrieve the number of elements to pass to [`get_physical_device_display_properties2()`][Self::get_physical_device_display_properties2()] + #[inline] + pub unsafe fn get_physical_device_display_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult { + let mut count = mem::MaybeUninit::uninit(); + (self.fp.get_physical_device_display_properties2_khr)( + physical_device, + count.as_mut_ptr(), + ptr::null_mut(), + ) + .assume_init_on_success(count) + .map(|c| c as usize) + } + + /// + /// + /// Call [`get_physical_device_display_properties2_len()`][Self::get_physical_device_display_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + #[doc(alias = "vkGetPhysicalDeviceDisplayProperties2KHR")] + pub unsafe fn get_physical_device_display_properties2( + &self, + physical_device: vk::PhysicalDevice, + out: &mut [vk::DisplayProperties2KHR<'_>], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self.fp.get_physical_device_display_properties2_khr)( + physical_device, + &mut count, + out.as_mut_ptr(), + ) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + /// Retrieve the number of elements to pass to [`get_physical_device_display_plane_properties2()`][Self::get_physical_device_display_plane_properties2()] + #[inline] + pub unsafe fn get_physical_device_display_plane_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult { + let mut count = mem::MaybeUninit::uninit(); + (self.fp.get_physical_device_display_plane_properties2_khr)( + physical_device, + count.as_mut_ptr(), + ptr::null_mut(), + ) + .assume_init_on_success(count) + .map(|c| c as usize) + } + + /// + /// + /// Call [`get_physical_device_display_plane_properties2_len()`][Self::get_physical_device_display_plane_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + #[doc(alias = "vkGetPhysicalDeviceDisplayPlaneProperties2KHR")] + pub unsafe fn get_physical_device_display_plane_properties2( + &self, + physical_device: vk::PhysicalDevice, + out: &mut [vk::DisplayPlaneProperties2KHR<'_>], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self.fp.get_physical_device_display_plane_properties2_khr)( + physical_device, + &mut count, + out.as_mut_ptr(), + ) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + /// Retrieve the number of elements to pass to [`get_display_mode_properties2()`][Self::get_display_mode_properties2()] + #[inline] + pub unsafe fn get_display_mode_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + ) -> VkResult { + let mut count = mem::MaybeUninit::uninit(); + (self.fp.get_display_mode_properties2_khr)( + physical_device, + display, + count.as_mut_ptr(), + ptr::null_mut(), + ) + .assume_init_on_success(count) + .map(|c| c as usize) + } + + /// + /// + /// Call [`get_display_mode_properties2_len()`][Self::get_display_mode_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + #[doc(alias = "vkGetDisplayModeProperties2KHR")] + pub unsafe fn get_display_mode_properties2( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + out: &mut [vk::DisplayModeProperties2KHR<'_>], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self.fp.get_display_mode_properties2_khr)( + physical_device, + display, + &mut count, + out.as_mut_ptr(), + ) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + /// + #[inline] + #[doc(alias = "vkGetDisplayPlaneCapabilities2KHR")] + pub unsafe fn get_display_plane_capabilities2( + &self, + physical_device: vk::PhysicalDevice, + display_plane_info: &vk::DisplayPlaneInfo2KHR<'_>, + capabilities: &mut vk::DisplayPlaneCapabilities2KHR<'_>, + ) -> VkResult<()> { + (self.fp.get_display_plane_capabilities2_khr)( + physical_device, + display_plane_info, + capabilities, + ) + .result() + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index 5552598be..cd15e02ec 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -19,6 +19,7 @@ pub mod external_memory_fd; pub mod external_memory_win32; pub mod external_semaphore_fd; pub mod external_semaphore_win32; +pub mod get_display_properties2; pub mod get_memory_requirements2; pub mod get_physical_device_properties2; pub mod get_surface_capabilities2;