Skip to content

Commit

Permalink
extensions/khr: Add VK_KHR_get_display_properties2 extension (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 authored Sep 26, 2024
1 parent 38e9df8 commit 5916329
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ash/src/extensions/ext/metal_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::vk;
impl crate::ext::metal_objects::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkExportMetalObjectsEXT.html>
#[inline]
#[doc(alias = "vkExportMetalObjectsEXT")]
pub unsafe fn export_metal_objects(
&self,
metal_objects_info: &mut vk::ExportMetalObjectsInfoEXT<'_>,
Expand Down
143 changes: 143 additions & 0 deletions ash/src/extensions/khr/get_display_properties2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_get_display_properties2.html>

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<usize> {
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)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayProperties2KHR.html>
///
/// 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<usize> {
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)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPlaneProperties2KHR.html>
///
/// 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<usize> {
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)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDisplayModeProperties2KHR.html>
///
/// 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(())
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneCapabilities2KHR.html>
#[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()
}
}
1 change: 1 addition & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5916329

Please sign in to comment.