diff --git a/Changelog.md b/Changelog.md index 1ee65cd..6a716b5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `VK_KHR_external_fence_win32` device extension (#582) - Added `VK_KHR_external_semaphore_win32` device extension (#581) - Added `VK_KHR_external_memory_win32` device extension (#579) - Added `VK_EXT_extended_dynamic_state2` device extension (#572) diff --git a/ash/src/extensions/khr/external_fence_win32.rs b/ash/src/extensions/khr/external_fence_win32.rs new file mode 100644 index 0000000..fa14192 --- /dev/null +++ b/ash/src/extensions/khr/external_fence_win32.rs @@ -0,0 +1,56 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// +#[derive(Clone)] +pub struct ExternalFenceWin32 { + handle: vk::Device, + fp: vk::KhrExternalFenceWin32Fn, +} + +impl ExternalFenceWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalFenceWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + pub unsafe fn import_fence_win32_handle( + &self, + import_info: &vk::ImportFenceWin32HandleInfoKHR, + ) -> VkResult<()> { + self.fp + .import_fence_win32_handle_khr(self.handle, import_info) + .result() + } + + /// + pub unsafe fn get_fence_win32_handle( + &self, + get_info: &vk::FenceGetWin32HandleInfoKHR, + ) -> VkResult { + let mut handle = ptr::null_mut(); + self.fp + .get_fence_win32_handle_khr(self.handle, get_info, &mut handle) + .result_with_success(handle) + } + + pub fn name() -> &'static CStr { + vk::KhrExternalFenceWin32Fn::name() + } + + pub fn fp(&self) -> &vk::KhrExternalFenceWin32Fn { + &self.fp + } + + 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 64963ec..55f6e8e 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -9,6 +9,7 @@ pub use self::display_swapchain::DisplaySwapchain; pub use self::draw_indirect_count::DrawIndirectCount; pub use self::dynamic_rendering::DynamicRendering; pub use self::external_fence_fd::ExternalFenceFd; +pub use self::external_fence_win32::ExternalFenceWin32; pub use self::external_memory_fd::ExternalMemoryFd; pub use self::external_memory_win32::ExternalMemoryWin32; pub use self::external_semaphore_fd::ExternalSemaphoreFd; @@ -43,6 +44,7 @@ mod display_swapchain; mod draw_indirect_count; mod dynamic_rendering; mod external_fence_fd; +mod external_fence_win32; mod external_memory_fd; mod external_memory_win32; mod external_semaphore_fd;