什么时候使用 vkCmd* 函数的参数?

When are parameters to vkCmd* functions consumed?

某些 vkCmd* 函数指定何时使用或不使用某些参数。例如,在 vkCmdBindDescriptorSets 的文档中:

The contents of pDynamicOffsets are consumed immediately during execution of vkCmdBindDescriptorSets.

不过大部分都没有说清楚。 vkCmd* 调用期间是否使用了所有参数?例如,在下面的代码中:

void copyHelper() {
  VkBufferCopy copy_region = {...};
  vkCmdCopyBuffer(cmd_buffer, from_buffer, to_buffer, 1, &copy_region);
}

调用 copyHelper() 后,copy_region 不再在范围内,尽管 cmd_buffer 尚未提交。我是否需要将 copy_region 存储在某处以使其保持有效?还是在调用vkCmdCopyBuffer时立即消耗? vkCmd* 函数的其余部分呢?

谢谢。

没有针对每个命令的说明,因为所有命令都在以下笼统声明下运行:

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.

规范中的重点。必须使用您在函数 returns 之前传递的任何内存的内容来完成实现。无论是像 void* 还是数据结构这样的未格式化内存。

注意 "duration" 定义为:

The duration of a Vulkan command refers to the interval between calling the command and its return to the caller.