When are parameters to vkCmd* functions consumed?

半腔热情 提交于 2019-12-11 00:27:26

问题


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, &copy_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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!