From 23856e9eb8f93295d7e79dadd1905c4dceb4656a Mon Sep 17 00:00:00 2001 From: AidoP Date: Tue, 11 Oct 2022 23:33:31 +0800 Subject: [PATCH] extensions/ext: Add VK_EXT_acquire_drm_display (#668) Co-authored-by: Aidan Prangnell --- Changelog.md | 1 + ash/src/extensions/ext/acquire_drm_display.rs | 55 +++++++++++++++++++ ash/src/extensions/ext/mod.rs | 2 + 3 files changed, 58 insertions(+) create mode 100644 ash/src/extensions/ext/acquire_drm_display.rs diff --git a/Changelog.md b/Changelog.md index cc8bfd3..061e96b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_KHR_device_group_creation` instance extension (#630) - Added `VK_KHR_device_group` device extension (#631) - Added `VK_EXT_mesh_shader` device extension (#657) +- Added `VK_EXT_acquire_drm_display` instance extension (#668) ### Fixed diff --git a/ash/src/extensions/ext/acquire_drm_display.rs b/ash/src/extensions/ext/acquire_drm_display.rs new file mode 100644 index 0000000..3b456aa --- /dev/null +++ b/ash/src/extensions/ext/acquire_drm_display.rs @@ -0,0 +1,55 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[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 } + } + + /// + #[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() + } + + /// + #[inline] + pub unsafe fn get_drm_display( + &self, + physical_device: vk::PhysicalDevice, + drm_fd: i32, + connector_id: u32, + ) -> VkResult { + 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 + } +} diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 93fca2f..5b2170b 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -1,3 +1,4 @@ +pub use self::acquire_drm_display::AcquireDrmDisplay; pub use self::buffer_device_address::BufferDeviceAddress; pub use self::calibrated_timestamps::CalibratedTimestamps; #[allow(deprecated)] @@ -18,6 +19,7 @@ pub use self::private_data::PrivateData; pub use self::sample_locations::SampleLocations; pub use self::tooling_info::ToolingInfo; +mod acquire_drm_display; mod buffer_device_address; mod calibrated_timestamps; #[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]