So I've been battling with this issue for a few days now and nothing I do fixes it.
If anyone knows what Im doing wrong, I would be glad to get some help about it!
ERROR:
*validation layer: Validation Error: [ VUID-vkQueueSubmit-pCommandBuffers-00071 ] Object 0: handle = 0x24f86c36d90, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x2e2f4d65 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] VkCommandBuffer 0x24f98d28300[] is already in use and is not marked for simultaneous use. The Vulkan spec states: If any element of the pCommandBuffers member of any element of pSubmits was not recorded with the VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, it must not be in the pending state (https://vulkan.lunarg.com/doc/view/1.3.250.1/windows/1.3-extensions/vkspec.html#VUID-vkQueueSubmit-pCommandBuffers-00071)*
I use 2 frames in flight.
This is the exact steps I do:
- Init the synch modules and commandBuffers.
std::vector<VkSemaphore> renderingSemaphores(modulo);
for(auto& semaphore : renderingSemaphores)
VulkanHelper::CheckVk(vkCreateSemaphore(_window.GetDevice(), &semaphoreInfo, nullptr, &semaphore));
std::vector<BoxelCommandBuffer> renderingCommandBuffers(modulo, BoxelCommandBuffer(_window.GetDevice(), _renderingCommandPool->GetPool()));
std::vector<VkFence> renderingFences(modulo);
VkFenceCreateInfo info{};
info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
for (auto& fence : renderingFences)
VulkanHelper::CheckVk(vkCreateFence(_window.GetDevice(), &info, nullptr, &fence));
IN MAIN LOOP:
- I wait for the fences for that frame.
vkWaitForFences(_window.GetDevice(), 1, &renderingFences[frameCounter % modulo], VK_TRUE, UINT64_MAX);
vkResetFences(_window.GetDevice(), 1, &renderingFences[frameCounter % modulo]);
- Begin commandBuffer at
renderingCommandBuffers[frameCounter % modulo].Begin(); - Record commands.
- End commandBuffer at
renderingCommandBuffers[frameCounter % modulo].End(); - Send eveyrthing and present.
VkCommandBuffer _renderingCommandBufferPointer = renderingCommandBuffers[frameCounter % modulo].Get();
VkPipelineStageFlags flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo{};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &imageAvailableSemaphore;
submitInfo.pWaitDstStageMask = &flags;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &_renderingCommandBufferPointer;
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &renderingSemaphores[frameCounter % modulo];
VulkanHelper::CheckVk(vkQueueSubmit(_window.GetQueue(), 1, &submitInfo, renderingFences[frameCounter % modulo]));
// 5. Present the image
VkSwapchainKHR _swapChainPointer = _swapChain.GetSwapChain();
VkPresentInfoKHR presentInfo{};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &renderingSemaphores[frameCounter % modulo];
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &_swapChainPointer;
presentInfo.pImageIndices = &imageIndex;
VulkanHelper::CheckVk(vkQueuePresentKHR(_window.GetQueue(), &presentInfo));
frameCounter++;
if (frameCounter % modulo == 0 && frameCounter > 10000)
frameCounter = 0;
Repeat at step 2.
Please help, I'm getting insane lol.