diff --git a/ash/src/extensions/khr/external_fence_fd.rs b/ash/src/extensions/khr/external_fence_fd.rs new file mode 100644 index 0000000..501f876 --- /dev/null +++ b/ash/src/extensions/khr/external_fence_fd.rs @@ -0,0 +1,51 @@ +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalFenceFd { + handle: vk::Device, + external_fence_fd_fn: vk::KhrExternalFenceFdFn, +} + +impl ExternalFenceFd { + pub fn new(instance: &I, device: &D) -> Self { + let external_fence_fd_fn = vk::KhrExternalFenceFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + handle: device.handle(), + external_fence_fd_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrExternalFenceFdFn::name() + } + + #[doc = ""] + pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> { + self.external_fence_fd_fn + .import_fence_fd_khr(self.handle, import_info) + .result() + } + + #[doc = ""] + pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult { + let mut fd = -1; + + self.external_fence_fd_fn + .get_fence_fd_khr(self.handle, get_info, &mut fd) + .result_with_success(fd) + } + + pub fn fp(&self) -> &vk::KhrExternalFenceFdFn { + &self.external_fence_fd_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index 382e041..22cafa9 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -6,6 +6,7 @@ pub use self::deferred_host_operations::DeferredHostOperations; pub use self::display::Display; pub use self::display_swapchain::DisplaySwapchain; pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::external_fence_fd::ExternalFenceFd; pub use self::external_memory_fd::ExternalMemoryFd; pub use self::external_semaphore_fd::ExternalSemaphoreFd; pub use self::get_memory_requirements2::GetMemoryRequirements2; @@ -30,6 +31,7 @@ mod deferred_host_operations; mod display; mod display_swapchain; mod draw_indirect_count; +mod external_fence_fd; mod external_memory_fd; mod external_semaphore_fd; mod get_memory_requirements2;