本文介绍了Vulkan可以释放从其他API导入到Vulkan的内存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在POSIX系统上,可以使用VkImportMemoryFdInfoKHR通过文件描述符从其他API导入内存对象(在Windows中,使用VkImportMemoryWin32HandleInfoKHR类似地工作).导入内存对象后,是否允许Vulkan使用vkFreeMemory释放基础内存,还是只能由分配了该对象的API释放该内存?谢谢您的帮助!

On POSIX systems, one can import memory objects from other APIs through file descriptors using VkImportMemoryFdInfoKHR (it works similarly on Windows using VkImportMemoryWin32HandleInfoKHR). Once the memory object has been imported, is Vulkan allowed to free the underlying memory with vkFreeMemory, or can the memory only be freed by the API that has allocated it? Thank you for your help!

推荐答案

Vulkan不仅被允许释放VkDeviceMemory对象,还需要释放VkDeviceMemory对象.这样做是必需的.当您将内存导入Vulkan时,规格很明显Vulkan现在拥有可以处理:

Vulkan is not merely allowed to free the VkDeviceMemory object; it is required to do so. When you import memory into Vulkan, the specification is clear that Vulkan now owns that handle:

因此,您不再可以在该文件描述符上使用常规命令. Vulkan拥有它,并且对它调用vkFreeMemory不是可选的:

So you're not allowed to use regular commands on that file descriptor anymore. Vulkan owns it, and calling vkFreeMemory on it is not optional:

...

  • VkDeviceMemory

由于内存导入操作而分配的VkDeviceMemory对象没有异常.

No exception is made for VkDeviceMemory objects allocated as the result of an memory import operation.

当然,现在您可以在不同的FD上执行操作,而恰恰是在与相同的内存通信(您甚至可以使用vkGetMemoryFdKHR这样做).但是您导入的特定FD归Vulkan拥有.释放内存将释放文件描述符;它不会影响内存本身.

Now of course, you can perform operations on a different FD that just so happens to be talking to the same memory (you can even use vkGetMemoryFdKHR to do so). But the specific FD you imported becomes owned by Vulkan. Freeing the memory frees the file descriptor; it doesn't affect the memory itself.

这篇关于Vulkan可以释放从其他API导入到Vulkan的内存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 14:36
查看更多