vks/
khr_external_semaphore_fd.rs

1// Copyright (c) 2017, Dennis Hamester <dennis.hamester@startmail.com>
2//
3// Permission to use, copy, modify, and/or distribute this software for any
4// purpose with or without fee is hereby granted, provided that the above
5// copyright notice and this permission notice appear in all copies.
6//
7// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9// FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13// PERFORMANCE OF THIS SOFTWARE.
14
15//! [`VK_KHR_external_semaphore_fd`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VK_KHR_external_semaphore_fd)
16
17use core::ptr;
18use khr_external_semaphore;
19use khr_external_semaphore_capabilities;
20use libc::{c_int, c_void};
21use vk;
22
23pub const VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION: u32 = 1;
24pub const VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME: &'static [u8; 29] = b"VK_KHR_external_semaphore_fd\x00";
25pub const VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME_STR: &'static str = "VK_KHR_external_semaphore_fd";
26
27/// See [`VkImportSemaphoreFdInfoKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VkImportSemaphoreFdInfoKHR)
28#[repr(C)]
29#[derive(Debug, Copy, Clone)]
30pub struct VkImportSemaphoreFdInfoKHR {
31    pub sType: vk::VkStructureType,
32    pub pNext: *const c_void,
33    pub semaphore: vk::VkSemaphore,
34    pub flags: khr_external_semaphore::VkSemaphoreImportFlagsKHR,
35    pub handleType: khr_external_semaphore_capabilities::VkExternalSemaphoreHandleTypeFlagBitsKHR,
36    pub fd: c_int,
37}
38
39impl Default for VkImportSemaphoreFdInfoKHR {
40    fn default() -> Self {
41        VkImportSemaphoreFdInfoKHR {
42            sType: vk::VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
43            pNext: ptr::null(),
44            semaphore: Default::default(),
45            flags: Default::default(),
46            handleType: Default::default(),
47            fd: Default::default(),
48        }
49    }
50}
51
52/// See [`VkSemaphoreGetFdInfoKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VkSemaphoreGetFdInfoKHR)
53#[repr(C)]
54#[derive(Debug, Copy, Clone)]
55pub struct VkSemaphoreGetFdInfoKHR {
56    pub sType: vk::VkStructureType,
57    pub pNext: *const c_void,
58    pub semaphore: vk::VkSemaphore,
59    pub handleType: khr_external_semaphore_capabilities::VkExternalSemaphoreHandleTypeFlagBitsKHR,
60}
61
62impl Default for VkSemaphoreGetFdInfoKHR {
63    fn default() -> Self {
64        VkSemaphoreGetFdInfoKHR {
65            sType: vk::VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
66            pNext: ptr::null(),
67            semaphore: Default::default(),
68            handleType: Default::default(),
69        }
70    }
71}
72
73/// See [`VkImportSemaphoreFdInfoKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VkImportSemaphoreFdInfoKHR)
74pub type PFN_vkImportSemaphoreFdKHR = Option<unsafe extern "system" fn(device: vk::VkDevice, pImportSemaphoreFdInfo: *const VkImportSemaphoreFdInfoKHR) -> vk::VkResult>;
75
76/// See [`vkGetSemaphoreFdKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#vkGetSemaphoreFdKHR)
77pub type PFN_vkGetSemaphoreFdKHR = Option<unsafe extern "system" fn(device: vk::VkDevice, pGetFdInfo: *const VkSemaphoreGetFdInfoKHR, pFd: *mut c_int) -> vk::VkResult>;
78
79#[cfg(feature = "function_prototypes")]
80extern "system" {
81    /// See [`VkImportSemaphoreFdInfoKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VkImportSemaphoreFdInfoKHR)
82    pub fn vkImportSemaphoreFdKHR(device: vk::VkDevice, pImportSemaphoreFdInfo: *const VkImportSemaphoreFdInfoKHR) -> vk::VkResult;
83
84    /// See [`vkGetSemaphoreFdKHR`](https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#vkGetSemaphoreFdKHR)
85    pub fn vkGetSemaphoreFdKHR(device: vk::VkDevice, pGetFdInfo: *const VkSemaphoreGetFdInfoKHR, pFd: *mut c_int) -> vk::VkResult;
86}