25 if (buffer_initialized_ && buffer_memory_export_ == memory_export) {
29 if (buffer_.is_allocated()) {
34 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
35 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
36 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
37 VmaAllocationCreateFlags(0),
42 buffer_initialized_ =
true;
43 buffer_memory_export_ = memory_export;
73 size_t memory_size = 0;
74 VkDeviceMemory memory = buffer_.export_memory_get(memory_size);
75 if (memory ==
nullptr) {
76 CLOG_ERROR(&
LOG,
"Failed to get device memory for Vulkan pixel buffer");
82 VkMemoryGetWin32HandleInfoKHR info = {};
83 info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR;
86 info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT;
89 if (device.
functions.vkGetMemoryWin32Handle(device.
vk_handle(), &info, &handle) != VK_SUCCESS) {
90 CLOG_ERROR(&
LOG,
"Failed to get Windows handle for Vulkan pixel buffer");
95 native_handle.
size = memory_size;
98 VkMemoryGetFdInfoKHR info = {};
99 info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR;
100 info.pNext =
nullptr;
101 info.memory = memory;
102 info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
106 CLOG_ERROR(&
LOG,
"Failed to get file descriptor for Vulkan pixel buffer");
107 return native_handle;
111 native_handle.
size = memory_size;
114 return native_handle;