C Specification

To export a POSIX file descriptor referencing the payload of a Vulkan device memory object, call:

// Provided by VK_KHR_external_memory_fd
VkResult vkGetMemoryFdKHR(
    VkDevice                                    device,
    const VkMemoryGetFdInfoKHR*                 pGetFdInfo,
    int*                                        pFd);


  • device is the logical device that created the device memory being exported.

  • pGetFdInfo is a pointer to a VkMemoryGetFdInfoKHR structure containing parameters of the export operation.

  • pFd will return a file descriptor referencing the payload of the device memory object.


Each call to vkGetMemoryFdKHR must create a new file descriptor holding a reference to the memory object’s payload and transfer ownership of the file descriptor to the application. To avoid leaking resources, the application must release ownership of the file descriptor using the close system call when it is no longer needed, or by importing a Vulkan memory object from it. Where supported by the operating system, the implementation must set the file descriptor to be closed automatically when an execve system call is made.

If VkPhysicalDeviceVulkanSC10Properties::deviceNoDynamicHostAllocations is VK_TRUE, vkGetMemoryFdKHR must not return VK_ERROR_OUT_OF_HOST_MEMORY.

Valid Usage (Implicit)
  • VUID-vkGetMemoryFdKHR-device-parameter
    device must be a valid VkDevice handle

  • VUID-vkGetMemoryFdKHR-pGetFdInfo-parameter
    pGetFdInfo must be a valid pointer to a valid VkMemoryGetFdInfoKHR structure

  • VUID-vkGetMemoryFdKHR-pFd-parameter
    pFd must be a valid pointer to an int value

Return Codes
On success, this command returns

On failure, this command returns


See Also

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0