在Vulkan中,是否可以在提交之前多次开始和结束VkCommandBuffer?

huangapple go评论54阅读模式
英文:

Is it possible to begin then end a VkCommandBuffer multiple times before submitting it in Vulkan?

问题

我想知道是否可以在开始记录命令到命令缓冲区后,结束命令缓冲区,然后再次开始(使用 vkBeginCommandBuffer ),同时仍然保留在第一个开始-结束会话中记录的所有命令。在Vulkan中是否可能实现这一点?

例如,您是否可以:

vkBeginCommandBuffer(commandBuffer, &beginInfo);

vkCmdFoo(commandBuffer, ...);

vkEndCommandBuffer(commandBuffer);

// 然后稍后:

vkBeginCommandBuffer(commandBuffer, &beginInfo);

vkCmdBar(commandBuffer, ...)

vkEndCommandBuffer(commandBuffer);

// 最后,提交命令缓冲区
vkQueueSubmit(...)

如果可以这样做,是否保证vkCmdFoo和vkCmdBar都会记录在命令缓冲区中?

谢谢!

英文:

I want to know if it is possible to begin recording commands into a command buffer, then end the command buffer before starting it again (with vkBeginCommandBuffer) while still maintaining all the commands recorded in the first begin-end session. Is this possible in vulkan?

For example, can you:

vkBeginCommandBuffer(commandBuffer, &beginInfo);

vkCmdFoo(commandBuffer, ...);

vkEndCommandBuffer(commandBuffer);

// then later on:

vkBeginCommandBuffer(commandBuffer, &beginInfo);

vkCmdBar(commandBuffer, ...)

vkEndCommandBuffer(commandBuffer);

// finally, submit the command buffer
vkQueueSubmit(...)

And if you can do this, is it guaranteed that vkCmdFoo and vkCmdBar would both be recorded in the command buffer?

Thanks!

答案1

得分: 3

不。

除非重置并丢失当前内容,否则只能开始记录一次命令缓冲区。如果您需要多个开始/结束循环,您需要使用多个命令缓冲区。或者,只使用一个命令缓冲区,将vkEndCommandBuffer()延迟到您确切知道已完成时。

请参阅规范中的生命周期说明:

英文:

No.

You can only begin recording a command buffer once, unless you reset and lose the current content. If you want multiple begin/end cycles you would need to use multiple command buffers. Alternatively use one, and defer the vkEndCommandBuffer() until you know you are really done.

See the lifecycle in the spec here:

huangapple
  • 本文由 发表于 2023年6月22日 01:27:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76525807.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定