extensions/khr: Add VK_KHR_external_semaphore_win32 (#581)

This commit is contained in:
Marijn Suijten 2022-02-16 23:13:19 +01:00 committed by GitHub
parent c5f68eab9d
commit 4fcd93016e
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_semaphore_win32` device extension (#581)
- Added `VK_KHR_external_memory_win32` device extension (#579)
- Added `VK_EXT_extended_dynamic_state2` device extension (#572)
- Added `VK_KHR_copy_commands2` device extension (#571)

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_semaphore_win32.html>
#[derive(Clone)]
pub struct ExternalSemaphoreWin32 {
handle: vk::Device,
fp: vk::KhrExternalSemaphoreWin32Fn,
}
impl ExternalSemaphoreWin32 {
pub fn new(instance: &Instance, device: &Device) -> Self {
let handle = device.handle();
let fp = vk::KhrExternalSemaphoreWin32Fn::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/vkImportSemaphoreWin32HandleKHR.html>
pub unsafe fn import_semaphore_win32_handle(
&self,
import_info: &vk::ImportSemaphoreWin32HandleInfoKHR,
) -> VkResult<()> {
self.fp
.import_semaphore_win32_handle_khr(self.handle, import_info)
.result()
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreWin32HandleKHR.html>
pub unsafe fn get_semaphore_win32_handle(
&self,
get_info: &vk::SemaphoreGetWin32HandleInfoKHR,
) -> VkResult<vk::HANDLE> {
let mut handle = ptr::null_mut();
self.fp
.get_semaphore_win32_handle_khr(self.handle, get_info, &mut handle)
.result_with_success(handle)
}
pub fn name() -> &'static CStr {
vk::KhrExternalSemaphoreWin32Fn::name()
}
pub fn fp(&self) -> &vk::KhrExternalSemaphoreWin32Fn {
&self.fp
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

View file

@ -12,6 +12,7 @@ pub use self::external_fence_fd::ExternalFenceFd;
pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::external_memory_win32::ExternalMemoryWin32;
pub use self::external_semaphore_fd::ExternalSemaphoreFd;
pub use self::external_semaphore_win32::ExternalSemaphoreWin32;
pub use self::get_memory_requirements2::GetMemoryRequirements2;
pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2;
pub use self::get_surface_capabilities2::GetSurfaceCapabilities2;
@ -45,6 +46,7 @@ mod external_fence_fd;
mod external_memory_fd;
mod external_memory_win32;
mod external_semaphore_fd;
mod external_semaphore_win32;
mod get_memory_requirements2;
mod get_physical_device_properties2;
mod get_surface_capabilities2;