跨队列系列的 Vulkan 信号量?

Vulkan semaphores across queue families?

我有两个命令缓冲区,我提交给来自两个不同队列系列的两个不同队列:

当我这样提交它们时:

{
  VkSubmitInfo submitInfo = VK_STYPE;
  submitInfo.commandBufferCount = 1;
  submitInfo.pCommandBuffers = &commandBuffer;
  submitInfo.signalSemaphoreCount = 1;
  submitInfo.pSignalSemaphores = &semaphore;
  vkQueueSubmit(TransferQueue, 1, &submitInfo, VK_NULL_HANDLE);
}
{
  VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
  VkSubmitInfo submitInfo = VK_STYPE;
  submitInfo.commandBufferCount = 1;
  submitInfo.pCommandBuffers = &commandBuffer2;
  submitInfo.waitSemaphoreCount = 1;
  submitInfo.pWaitSemaphores = &semaphore;
  submitInfo.pWaitDstStageMask = &waitDstStageMask;
  vkQueueSubmit(GraphicsQueue, 1, &submitInfo, fence);
}

代码在没有验证投诉的情况下工作。

当我更改它们的提交顺序时,我确实收到验证投诉和运行时错误:

{
  VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
  VkSubmitInfo submitInfo = VK_STYPE;
  submitInfo.commandBufferCount = 1;
  submitInfo.pCommandBuffers = &commandBuffer2;
  submitInfo.waitSemaphoreCount = 1;
  submitInfo.pWaitSemaphores = &semaphore;
  submitInfo.pWaitDstStageMask = &waitDstStageMask;
  vkQueueSubmit(GraphicsQueue, 1, &submitInfo, fence);
}
{
  VkSubmitInfo submitInfo = VK_STYPE;
  submitInfo.commandBufferCount = 1;
  submitInfo.pCommandBuffers = &commandBuffer;
  submitInfo.signalSemaphoreCount = 1;
  submitInfo.pSignalSemaphores = &semaphore;
  vkQueueSubmit(TransferQueue, 1, &submitInfo, VK_NULL_HANDLE);
}

我希望在第二个示例中发生的情况是,第一个命令会阻塞在队列中等待信号量,直到我提交发出信号的第二个命令。

我在这里错过了什么?第二个例子违反了什么规则?

验证错误有与之关联的文本。该文本会指出 you cannot submit a batch containing a binary semaphore wait until the batch that signals the binary semaphore has been submitted.

因此,如果您在多个线程中跨队列使用二进制信号量,则必须使用 CPU 同步工具以正确的顺序提交它们。这是时间轴信号量存在的原因之一:它们没有那个限制。