0
votes

Note that this is mostly a follow-up question to this post: Can memory imported to Vulkan from another API be freed by Vulkan? (no need to read it to understand the question, might be interesting nonetheless)

Memory objects can be imported to Vulkan from other APIs using the VK_KHR_external_memory* family of extensions. As explained by @Nicol Bolas in the previous post, all memory objects need to be freed prior to destroying the VkDevice, no matter if they're imported or not. There are two options I can think of what could happen when an imported memory object is freed:

  • When vkFreeMemory is called, the given region is freed globally (as indicated by the function name) and can be used by any application after the call
  • The driver knows that the memory object is imported and might be in use by another application, so the memory region isn't marked as available

I think assumption 2 is true, but if it was, the function name vkFreeMemory would be misleading. I couldn't find anything about this in the specification so I figured I'll ask here.

1

1 Answers

1
votes

Import pNext struct changes the vkAllocateMemory semantics into an Import Operation. Common sense implies vkFreeMemory is equally affected. I.e. it just unimports the memory. That way you also do not break OO design of the other API. Simply, the API that (really) allocated the memory will also be unallocating it.

If you are a trained engineer, read the specification directly, and still don't understand, chances are you are not the only one. I would much prefer if you reported these kinds of things at KhronosGroup/Vulkan-Docs (they even accept patches if that is your thing). That way it will get fixed for everybody.