Function Prototype

vkGetSemaphoreFdKHR

Get a POSIX file descriptor handle for a semaphore

To export a POSIX file descriptor representing the payload of a semaphore, call:

VkResult vkGetSemaphoreFdKHR(
    VkDevice device,
    const VkSemaphoreGetFdInfoKHR* pGetFdInfo,
    int* pFd);
  • device is the logical device that created the semaphore being exported.
  • pGetFdInfo is a pointer to a VkSemaphoreGetFdInfoKHR structure containing parameters of the export operation.
  • pFd will return the file descriptor representing the semaphore payload.

Each call to vkGetSemaphoreFdKHR must create a new file descriptor and transfer ownership of it to the application. To avoid leaking resources, the application must release ownership of the file descriptor when it is no longer needed.

Ownership can be released in many ways. For example, the application can call close() on the file descriptor, or transfer ownership back to Vulkan by using the file descriptor to import a semaphore payload.

Where supported by the operating system, the implementation must set the file descriptor to be closed automatically when an execve system call is made.

Exporting a file descriptor from a semaphore may have side effects depending on the transference of the specified handle type, as described in Importing Semaphore State.

Valid Usage (Implicit)

VUID-vkGetSemaphoreFdKHR-pGetFdInfo-parameter

pGetFdInfo must be a valid pointer to a valid VkSemaphoreGetFdInfoKHR structure

VUID-vkGetSemaphoreFdKHR-pFd-parameter

pFd must be a valid pointer to an int value