5.4. 命令缓冲区的提交
可调用下列的命令把命令缓冲区提交到队列:
VkResult vkQueueSubmit(
VkQueue queue,
uint32_t submitCount,
const VkSubmitInfo* pSubmits,
VkFence fence);
-
queue是命令缓冲区被提交到的队列。 -
submitCount是pSubmits数组元素的大小。 -
pSubmits是一个指向 元素类型为VkSubmitInfo的数组的指针,每一个元素都指定了一个命令缓冲区提交batch。 -
fence是一个可选的handle,指向一个将被激发的fence。如果fence不是VK_NULL_HANDLE,它定义了一个 fence signal operation。
|
注意
提交可能是一个代价很高的操作,应用程序应该尝试批量的工作,尽量少的调用 |
vkQueueSubmit是一个队列提交命令,每一批任务通过pSubmits中由VkSubmitInfo表示的一批任务定义。 pSubmits中各批次的任务依出现的顺序执行,但是,完成的顺序可能是乱序的。
通过vkQueueSubmit提交的栅栏和信号量操作和其他的命令提交有另外的顺序限制,依赖于队列中前后操作。 关于这些量外的限制的信息可以在“同步”一章的信号量 and 栅栏 小节中看到。
VkSubmitInfo 类型数据结构定义如下:
typedef struct VkSubmitInfo {
VkStructureType sType;
const void* pNext;
uint32_t waitSemaphoreCount;
const VkSemaphore* pWaitSemaphores;
const VkPipelineStageFlags* pWaitDstStageMask;
uint32_t commandBufferCount;
const VkCommandBuffer* pCommandBuffers;
uint32_t signalSemaphoreCount;
const VkSemaphore* pSignalSemaphores;
} VkSubmitInfo;
-
sType是本数据结构的类型。 -
pNext为NULL或者指向拓展特定结构的指针。 -
waitSemaphoreCountis the number of semaphores upon which to wait before executing the command buffers for the batch. -
pWaitSemaphoresis a pointer to an array of semaphores upon which to wait before the command buffers for this batch begin execution. If semaphores to wait on are provided, they define a semaphore wait operation. -
pWaitDstStageMaskis a pointer to an array of pipeline stages at which each corresponding semaphore wait will occur. -
commandBufferCountis the number of command buffers to execute in the batch. -
pCommandBuffersis a pointer to an array of command buffers to execute in the batch. -
signalSemaphoreCountis the number of semaphores to be signaled once the commands specified inpCommandBuffershave completed execution. -
pSignalSemaphoresis a pointer to an array of semaphores which will be signaled when the command buffers for this batch have completed execution. If semaphores to be signaled are provided, they define a semaphore signal operation.
命令缓冲区在pCommandBuffers中出现的顺序决定了submission order, implicit ordering guarantees 也取决于这个顺序。 除了这些隐式的顺序保证 和其他的explicit synchronization primitives,这些命令缓冲区可能重叠或者乱序执行。
5.5. 队列发送进度(Queue Forward Progress)
应用程序必须保证在任何队列上没有剩下的操作时命令缓冲区提交将能够完成。 在vkQueueSubmit调用之后,对等待一个信号量的每个排队等待者必须是一个比信号量更早的信号, 该信号量不会被一个不同的等待者消耗。
提交的命令缓冲区可以包含等待不会被队列中更早的命令所激发的事件的vkCmdWaitEvents命令, 这些事件必须通过应用程序使用vkSetEvent来激发,且等待这些事件的vkCmdWaitEvents命令不能在一个render pass内。 Vulkan实现可能对命令缓冲区等待的时长有限制,以避免和设备的其他clients的工作进度有干扰。 如果没有这些限制条件下事件被激发了,结果是未定义的,可能包括设备丢失。
本文介绍Vulkan API中的命令缓冲区提交过程及队列发送进度的重要性。详细解释了vkQueueSubmit函数的参数作用,并说明如何正确使用VkSubmitInfo结构。此外,还讨论了命令提交时的注意事项及队列发送进度的保障措施。
188

被折叠的 条评论
为什么被折叠?



