diff --git a/ash/src/device.rs b/ash/src/device.rs index 7494274..fb2dc14 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -1902,15 +1902,11 @@ pub trait DeviceV1_0 { unsafe fn get_image_subresource_layout( &self, image: vk::Image, - subresource: vk::ImageSubresource, + subresource: &vk::ImageSubresource, ) -> vk::SubresourceLayout { let mut layout = mem::zeroed(); - self.fp_v1_0().get_image_subresource_layout( - self.handle(), - image, - &subresource, - &mut layout, - ); + self.fp_v1_0() + .get_image_subresource_layout(self.handle(), image, subresource, &mut layout); layout } diff --git a/ash/src/extensions/khr/external_semaphore_fd.rs b/ash/src/extensions/khr/external_semaphore_fd.rs new file mode 100644 index 0000000..5ab3a3f --- /dev/null +++ b/ash/src/extensions/khr/external_semaphore_fd.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalSemaphoreFd { + handle: vk::Device, + external_semaphore_fd_fn: vk::KhrExternalSemaphoreFdFn, +} + +impl ExternalSemaphoreFd { + pub fn new(instance: &I, device: &D) -> Self { + let external_semaphore_fd_fn = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + handle: device.handle(), + external_semaphore_fd_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrExternalSemaphoreFdFn::name() + } + + #[doc = ""] + pub unsafe fn import_semaphore_fd( + &self, + import_info: &vk::ImportSemaphoreFdInfoKHR, + ) -> VkResult<()> { + self.external_semaphore_fd_fn + .import_semaphore_fd_khr(self.handle, import_info) + .result() + } + + #[doc = ""] + pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult { + let mut fd = -1; + + self.external_semaphore_fd_fn + .get_semaphore_fd_khr(self.handle, get_info, &mut fd) + .result_with_success(fd) + } + + pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn { + &self.external_semaphore_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 e07dd89..610eef5 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -6,6 +6,7 @@ pub use self::display::Display; pub use self::display_swapchain::DisplaySwapchain; pub use self::draw_indirect_count::DrawIndirectCount; pub use self::external_memory_fd::ExternalMemoryFd; +pub use self::external_semaphore_fd::ExternalSemaphoreFd; pub use self::get_memory_requirements2::GetMemoryRequirements2; pub use self::maintenance1::Maintenance1; pub use self::maintenance3::Maintenance3; @@ -28,6 +29,7 @@ mod display; mod display_swapchain; mod draw_indirect_count; mod external_memory_fd; +mod external_semaphore_fd; mod get_memory_requirements2; mod maintenance1; mod maintenance3;