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;