extensions/khr: Add VK_KHR_external_fence_win32 (#582)

This commit is contained in:
Marijn Suijten 2022-02-17 00:23:45 +01:00 committed by GitHub
parent 4fcd93016e
commit 9df926ab3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 0 deletions

View file

@ -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)

View file

@ -0,0 +1,56 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;
use std::ptr;
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_fence_win32.html>
#[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 }
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportFenceWin32HandleKHR.html>
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()
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceWin32HandleKHR.html>
pub unsafe fn get_fence_win32_handle(
&self,
get_info: &vk::FenceGetWin32HandleInfoKHR,
) -> VkResult<vk::HANDLE> {
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
}
}

View file

@ -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;