extensions/khr: Add VK_KHR_external_fence_fd wrapper (#413)
This extension wrapper is identical to the one for VK_KHR_external_semaphore_fd introduced in #395 with 'semaphore' substitued for 'fence'.
This commit is contained in:
parent
14136e5e96
commit
8d60a7eec2
51
ash/src/extensions/khr/external_fence_fd.rs
Normal file
51
ash/src/extensions/khr/external_fence_fd.rs
Normal file
|
@ -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<I: InstanceV1_0, D: DeviceV1_0>(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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkImportFenceFdKHR.html>"]
|
||||
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetFenceFdKHR.html>"]
|
||||
pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult<i32> {
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue