When I run the tutorial 08 code, I get the following validation layer error that vkBeginCommandBuffer is being called on an active command buffer. I get the same error when running my own version of the code, but instead of getting it for a single command buffer it occurs for all 3 command buffers.
validation layer: Validation Error: [ VUID-vkBeginCommandBuffer-commandBuffer-00049 ] Object 0: handle = 0x6000029add58, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x84029a9f | Calling vkBeginCommandBuffer() on active VkCommandBuffer 0x6000029add58[] before it has completed. You must check command buffer fence before this call. The Vulkan spec states: commandBuffer must not be in the recording or pending state (https://vulkan.lunarg.com/doc/view/1.2.182.0/mac/1.2-extensions/vkspec.html#VUID-vkBeginCommandBuffer-commandBuffer-00049)
validation layer: Validation Error: [ VUID-vkBeginCommandBuffer-commandBuffer-00049 ] Object 0: handle = 0x6000029ade28, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x84029a9f | Calling vkBeginCommandBuffer() on active VkCommandBuffer 0x6000029ade28[] before it has completed. You must check command buffer fence before this call. The Vulkan spec states: commandBuffer must not be in the recording or pending state (https://vulkan.lunarg.com/doc/view/1.2.182.0/mac/1.2-extensions/vkspec.html#VUID-vkBeginCommandBuffer-commandBuffer-00049)
validation layer: Validation Error: [ VUID-vkBeginCommandBuffer-commandBuffer-00049 ] Object 0: handle = 0x6000029adef8, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x84029a9f | Calling vkBeginCommandBuffer() on active VkCommandBuffer 0x6000029adef8[] before it has completed. You must check command buffer fence before this call. The Vulkan spec states: commandBuffer must not be in the recording or pending state (https://vulkan.lunarg.com/doc/view/1.2.182.0/mac/1.2-extensions/vkspec.html#VUID-vkBeginCommandBuffer-commandBuffer-00049)
I can make the error go away by adding vkWaitDeviceIdle() in the main loop after draw_frame(). Both LveSwapChain::acquireNextImage() and LveSwapChain::submitCommandBuffers() wait for the fences but this doesn't seem to have the correct effect now that buffers are being recorded each frame rather than once at command buffer creation.
I note that in the relevant tutorial video, these validation errors do not show.
I've tried running on my Windows machine and the error does not reproduce, so I think it's likely an M1 or MoltenVK issue. Is there anything we can do in the code to guard against this error where it does occur?
When I run the tutorial 08 code, I get the following validation layer error that
vkBeginCommandBuffer
is being called on an active command buffer. I get the same error when running my own version of the code, but instead of getting it for a single command buffer it occurs for all 3 command buffers.I can make the error go away by adding
vkWaitDeviceIdle()
in the main loop afterdraw_frame()
. BothLveSwapChain::acquireNextImage()
andLveSwapChain::submitCommandBuffers()
wait for the fences but this doesn't seem to have the correct effect now that buffers are being recorded each frame rather than once at command buffer creation.I note that in the relevant tutorial video, these validation errors do not show.
Relevant specs: