本文整理汇总了C++中NativeHandle::getFd方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeHandle::getFd方法的具体用法?C++ NativeHandle::getFd怎么用?C++ NativeHandle::getFd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeHandle
的用法示例。
在下文中一共展示了NativeHandle::getFd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importSemaphore
void importSemaphore (const vk::DeviceInterface& vkd,
const vk::VkDevice device,
const vk::VkSemaphore semaphore,
vk::VkExternalSemaphoreHandleTypeFlagBitsKHR externalType,
NativeHandle& handle,
vk::VkSemaphoreImportFlagsKHR flags)
{
if (externalType == vk::VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR
|| externalType == vk::VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR)
{
const vk::VkImportSemaphoreFdInfoKHR importInfo =
{
vk::VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
DE_NULL,
semaphore,
flags,
externalType,
handle.getFd()
};
VK_CHECK(vkd.importSemaphoreFdKHR(device, &importInfo));
handle.disown();
}
else if (externalType == vk::VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR
|| externalType == vk::VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR)
{
const vk::VkImportSemaphoreWin32HandleInfoKHR importInfo =
{
vk::VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
DE_NULL,
semaphore,
flags,
externalType,
handle.getWin32Handle(),
DE_NULL
};
VK_CHECK(vkd.importSemaphoreWin32HandleKHR(device, &importInfo));
// \note File descriptors and win32 handles behave differently, but this call wil make it seem like they would behave in same way
handle.reset();
}
else
DE_FATAL("Unknown semaphore external handle type");
}
示例2: if
static vk::Move<vk::VkDeviceMemory> importMemory (const vk::DeviceInterface& vkd,
vk::VkDevice device,
vk::VkBuffer buffer,
vk::VkImage image,
const vk::VkMemoryRequirements& requirements,
vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType,
NativeHandle& handle)
{
const bool isDedicated = !!buffer || !!image;
DE_ASSERT(!buffer || !image);
if (externalType == vk::VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR)
{
const vk::VkImportMemoryFdInfoKHR importInfo =
{
vk::VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
DE_NULL,
externalType,
handle.getFd()
};
const vk::VkMemoryDedicatedAllocateInfoKHR dedicatedInfo =
{
vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
&importInfo,
image,
buffer,
};
const vk::VkMemoryAllocateInfo info =
{
vk::VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
(isDedicated ? (const void*)&dedicatedInfo : (const void*)&importInfo),
requirements.size,
chooseMemoryType(requirements.memoryTypeBits)
};
vk::Move<vk::VkDeviceMemory> memory (vk::allocateMemory(vkd, device, &info));
handle.disown();
return memory;
}
else if (externalType == vk::VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR
|| externalType == vk::VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR)
{
const vk::VkImportMemoryWin32HandleInfoKHR importInfo =
{
vk::VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR,
DE_NULL,
externalType,
handle.getWin32Handle(),
DE_NULL
};
const vk::VkMemoryDedicatedAllocateInfoKHR dedicatedInfo =
{
vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
&importInfo,
image,
buffer,
};
const vk::VkMemoryAllocateInfo info =
{
vk::VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
(isDedicated ? (const void*)&dedicatedInfo : (const void*)&importInfo),
requirements.size,
chooseMemoryType(requirements.memoryTypeBits)
};
vk::Move<vk::VkDeviceMemory> memory (vk::allocateMemory(vkd, device, &info));
handle.disown();
return memory;
}
else
{
DE_FATAL("Unknown external memory type");
return vk::Move<vk::VkDeviceMemory>();
}
}