Skip to content

Commit 5916329

Browse files
authored
extensions/khr: Add VK_KHR_get_display_properties2 extension (#932)
1 parent 38e9df8 commit 5916329

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Update Vulkan-Headers to 1.3.296 (#910)
13+
- Added `VK_KHR_get_display_properties2` instance extension (#932)
1314
- Added `VK_EXT_metal_objects` device extension (#942)
1415

1516
## [0.38.0] - 2024-04-01

ash/src/extensions/ext/metal_objects.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::vk;
55
impl crate::ext::metal_objects::Device {
66
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkExportMetalObjectsEXT.html>
77
#[inline]
8+
#[doc(alias = "vkExportMetalObjectsEXT")]
89
pub unsafe fn export_metal_objects(
910
&self,
1011
metal_objects_info: &mut vk::ExportMetalObjectsInfoEXT<'_>,
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_get_display_properties2.html>
2+
3+
use crate::prelude::*;
4+
use crate::vk;
5+
use core::mem;
6+
use core::ptr;
7+
8+
impl crate::khr::get_display_properties2::Instance {
9+
/// Retrieve the number of elements to pass to [`get_physical_device_display_properties2()`][Self::get_physical_device_display_properties2()]
10+
#[inline]
11+
pub unsafe fn get_physical_device_display_properties2_len(
12+
&self,
13+
physical_device: vk::PhysicalDevice,
14+
) -> VkResult<usize> {
15+
let mut count = mem::MaybeUninit::uninit();
16+
(self.fp.get_physical_device_display_properties2_khr)(
17+
physical_device,
18+
count.as_mut_ptr(),
19+
ptr::null_mut(),
20+
)
21+
.assume_init_on_success(count)
22+
.map(|c| c as usize)
23+
}
24+
25+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayProperties2KHR.html>
26+
///
27+
/// Call [`get_physical_device_display_properties2_len()`][Self::get_physical_device_display_properties2_len()] to query the number of elements to pass to `out`.
28+
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
29+
#[inline]
30+
#[doc(alias = "vkGetPhysicalDeviceDisplayProperties2KHR")]
31+
pub unsafe fn get_physical_device_display_properties2(
32+
&self,
33+
physical_device: vk::PhysicalDevice,
34+
out: &mut [vk::DisplayProperties2KHR<'_>],
35+
) -> VkResult<()> {
36+
let mut count = out.len() as u32;
37+
(self.fp.get_physical_device_display_properties2_khr)(
38+
physical_device,
39+
&mut count,
40+
out.as_mut_ptr(),
41+
)
42+
.result()?;
43+
assert_eq!(count as usize, out.len());
44+
Ok(())
45+
}
46+
47+
/// Retrieve the number of elements to pass to [`get_physical_device_display_plane_properties2()`][Self::get_physical_device_display_plane_properties2()]
48+
#[inline]
49+
pub unsafe fn get_physical_device_display_plane_properties2_len(
50+
&self,
51+
physical_device: vk::PhysicalDevice,
52+
) -> VkResult<usize> {
53+
let mut count = mem::MaybeUninit::uninit();
54+
(self.fp.get_physical_device_display_plane_properties2_khr)(
55+
physical_device,
56+
count.as_mut_ptr(),
57+
ptr::null_mut(),
58+
)
59+
.assume_init_on_success(count)
60+
.map(|c| c as usize)
61+
}
62+
63+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPlaneProperties2KHR.html>
64+
///
65+
/// 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`.
66+
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
67+
#[inline]
68+
#[doc(alias = "vkGetPhysicalDeviceDisplayPlaneProperties2KHR")]
69+
pub unsafe fn get_physical_device_display_plane_properties2(
70+
&self,
71+
physical_device: vk::PhysicalDevice,
72+
out: &mut [vk::DisplayPlaneProperties2KHR<'_>],
73+
) -> VkResult<()> {
74+
let mut count = out.len() as u32;
75+
(self.fp.get_physical_device_display_plane_properties2_khr)(
76+
physical_device,
77+
&mut count,
78+
out.as_mut_ptr(),
79+
)
80+
.result()?;
81+
assert_eq!(count as usize, out.len());
82+
Ok(())
83+
}
84+
85+
/// Retrieve the number of elements to pass to [`get_display_mode_properties2()`][Self::get_display_mode_properties2()]
86+
#[inline]
87+
pub unsafe fn get_display_mode_properties2_len(
88+
&self,
89+
physical_device: vk::PhysicalDevice,
90+
display: vk::DisplayKHR,
91+
) -> VkResult<usize> {
92+
let mut count = mem::MaybeUninit::uninit();
93+
(self.fp.get_display_mode_properties2_khr)(
94+
physical_device,
95+
display,
96+
count.as_mut_ptr(),
97+
ptr::null_mut(),
98+
)
99+
.assume_init_on_success(count)
100+
.map(|c| c as usize)
101+
}
102+
103+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDisplayModeProperties2KHR.html>
104+
///
105+
/// Call [`get_display_mode_properties2_len()`][Self::get_display_mode_properties2_len()] to query the number of elements to pass to `out`.
106+
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
107+
#[inline]
108+
#[doc(alias = "vkGetDisplayModeProperties2KHR")]
109+
pub unsafe fn get_display_mode_properties2(
110+
&self,
111+
physical_device: vk::PhysicalDevice,
112+
display: vk::DisplayKHR,
113+
out: &mut [vk::DisplayModeProperties2KHR<'_>],
114+
) -> VkResult<()> {
115+
let mut count = out.len() as u32;
116+
(self.fp.get_display_mode_properties2_khr)(
117+
physical_device,
118+
display,
119+
&mut count,
120+
out.as_mut_ptr(),
121+
)
122+
.result()?;
123+
assert_eq!(count as usize, out.len());
124+
Ok(())
125+
}
126+
127+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneCapabilities2KHR.html>
128+
#[inline]
129+
#[doc(alias = "vkGetDisplayPlaneCapabilities2KHR")]
130+
pub unsafe fn get_display_plane_capabilities2(
131+
&self,
132+
physical_device: vk::PhysicalDevice,
133+
display_plane_info: &vk::DisplayPlaneInfo2KHR<'_>,
134+
capabilities: &mut vk::DisplayPlaneCapabilities2KHR<'_>,
135+
) -> VkResult<()> {
136+
(self.fp.get_display_plane_capabilities2_khr)(
137+
physical_device,
138+
display_plane_info,
139+
capabilities,
140+
)
141+
.result()
142+
}
143+
}

ash/src/extensions/khr/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod external_memory_fd;
1919
pub mod external_memory_win32;
2020
pub mod external_semaphore_fd;
2121
pub mod external_semaphore_win32;
22+
pub mod get_display_properties2;
2223
pub mod get_memory_requirements2;
2324
pub mod get_physical_device_properties2;
2425
pub mod get_surface_capabilities2;

0 commit comments

Comments
 (0)