-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions/ext: Add VK_EXT_acquire_drm_display (#668)
Co-authored-by: Aidan Prangnell <[email protected]>
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::prelude::*; | ||
use crate::vk; | ||
use crate::{Entry, Instance}; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
|
||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_acquire_drm_display.html> | ||
#[derive(Clone)] | ||
pub struct AcquireDrmDisplay { | ||
fp: vk::ExtAcquireDrmDisplayFn, | ||
} | ||
|
||
impl AcquireDrmDisplay { | ||
pub fn new(entry: &Entry, instance: &Instance) -> Self { | ||
let handle = instance.handle(); | ||
let fp = vk::ExtAcquireDrmDisplayFn::load(|name| unsafe { | ||
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) | ||
}); | ||
Self { fp } | ||
} | ||
|
||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireDrmDisplayEXT.html> | ||
#[inline] | ||
pub unsafe fn acquire_drm_display( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
drm_fd: i32, | ||
display: vk::DisplayKHR, | ||
) -> VkResult<()> { | ||
(self.fp.acquire_drm_display_ext)(physical_device, drm_fd, display).result() | ||
} | ||
|
||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDrmDisplayEXT.html> | ||
#[inline] | ||
pub unsafe fn get_drm_display( | ||
&self, | ||
physical_device: vk::PhysicalDevice, | ||
drm_fd: i32, | ||
connector_id: u32, | ||
) -> VkResult<vk::DisplayKHR> { | ||
let mut display = mem::MaybeUninit::uninit(); | ||
(self.fp.get_drm_display_ext)(physical_device, drm_fd, connector_id, display.as_mut_ptr()) | ||
.result_with_success(display.assume_init()) | ||
} | ||
|
||
#[inline] | ||
pub const fn name() -> &'static CStr { | ||
vk::ExtAcquireDrmDisplayFn::name() | ||
} | ||
|
||
#[inline] | ||
pub fn fp(&self) -> &vk::ExtAcquireDrmDisplayFn { | ||
&self.fp | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters