Andrew Tomazos
Andrew Tomazos

Reputation: 68698

What does vulkan API copy?

When an application calls a Vulkan API command, in some cases there are pointers to memory owned by the application passed. Does Vulkan ever store such a pointer passed to it? How do you know?

For example, let's take the vkCmdWaitEvents command. I pass a pEvents pointer to an array of VkEvent. Immediately after vkCmdWaitEvents returns, can I delete that array? Or do I have to wait until that wait has been executed and the enclosing CommandBuffer has been destroyed? ie does vulkan take a copy of the array, or does it just store a pointer to the first element of the array? How do you know which?

Upvotes: 2

Views: 254

Answers (1)

ratchet freak
ratchet freak

Reputation: 48216

It never does.

To quote the spec

The ownership of application-owned memory is immediately acquired by any Vulkan command it is passed into. Ownership of such memory must be released back to the application at the end of the duration of the command, so that the application can alter or free this memory as soon as all the commands that acquired it have returned.

The only time a pointer must be kept valid for more than a single call is when it is used as pUserData for a callback like the VkDebugReportCallbackCreateInfoEXT or the allocation callbacks.

Upvotes: 4

Related Questions