#Hey there, could someone help me out on this issue I have with some CommandBuffers?

8 messages · Page 1 of 1 (latest)

tacit quartz
#

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:

  1. 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:

  1. 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]);
  1. Begin commandBuffer at renderingCommandBuffers[frameCounter % modulo].Begin();
  2. Record commands.
  3. End commandBuffer at renderingCommandBuffers[frameCounter % modulo].End();
  4. 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.

rotund raven
#
std::vector<BoxelCommandBuffer> renderingCommandBuffers(modulo, BoxelCommandBuffer(_window.GetDevice(), _renderingCommandPool->GetPool()));

You're creating a vector with size 2, but they're both the same command buffer

#

You need to do the same thing you're doing with semaphores and fences, creating each one individually

tacit quartz
rotund raven
tacit quartz
#

thanks a lot mate

rotund raven
#

As a side note: If you're going to make your own classes around Vulkan objects, if you do any vkDestroy* or vkFree* in the destructor, you must delete the copy constructor/assignment operator. Otherwise, you'll have two objects both trying to destroy the same Vulkan object.