问题
Some of the vkCmd*
functions specify when some parameters are consumed or not. For example, in the documentation of vkCmdBindDescriptorSets
:
The contents of pDynamicOffsets are consumed immediately during execution of vkCmdBindDescriptorSets.
However most of them do not clarify. Are all parameters consumed during the the vkCmd*
call? For example, in the following code:
void copyHelper() {
VkBufferCopy copy_region = {...};
vkCmdCopyBuffer(cmd_buffer, from_buffer, to_buffer, 1, ©_region);
}
after calling copyHelper()
, copy_region
is not in scope anymore although cmd_buffer
hasn't been submitted yet. Do I need to store copy_region
somewhere so that it stays valid? Or is it immediately consumed when calling vkCmdCopyBuffer
? What about the rest of the vkCmd*
functions?
Thanks.
回答1:
There is no per-command clarification, because all commands operate under the following blanket statement:
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.
Emphasis in the specification. The implementation has to be finished using the contents of any memory you pass by the time the function returns. Whether unformatted memory like a void*
or data structures.
Note that "duration" is defined as:
The duration of a Vulkan command refers to the interval between calling the command and its return to the caller.
来源:https://stackoverflow.com/questions/51236789/when-are-parameters-to-vkcmd-functions-consumed