PacktPublishing / Mastering-Graphics-Programming-with-Vulkan

MIT License
514 stars 65 forks source link

Command buffer submitted to wrong queue (Intel A770, Chapter 5) #31

Closed dorian-apanel-intel closed 1 year ago

dorian-apanel-intel commented 1 year ago

When running on Intel A770, following core validation error is triggered in Chapter5:

VUID-vkQueueSubmit2-commandBuffer-03878(ERROR / SPEC): msgNum: -628003580 - Validation Error: [ VUID-vkQueueSubmit2-commandBuffer-03878 ] Object 0: handle = 0x22e857a8750, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x22e853d52c0, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0xda916d04 | vkQueueSubmit2(): pSubmits[0].pCommandBufferInfos[0].commandBuffer Primary VkCommandBuffer 0x22e857a8750[] created in queue family 0 is being submitted on VkQueue 0x22e853d52c0[] from queue family 1. The Vulkan spec states: The commandBuffer member of any element of the pCommandBufferInfos member of any element of pSubmits must have been allocated from a VkCommandPool that was created for the same queue family queue belongs to (https://vulkan.lunarg.com/doc/view/1.3.239.0/windows/1.3-extensions/vkspec.html#VUID-vkQueueSubmit2-commandBuffer-03878)
    Objects: 2
       [0]  0x22e857a8750, type: 6, name: NULL
       [1]  0x22e853d52c0, type: 4, name: NULL
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in RaptorEngine_Chapter5_Debug.exe.

Command buffer created for universal queue is submitted to compute only queue.

Log regarding queues:

GPU Used: Intel(R) Arc(TM) A770M Graphics
Family 0, flags 15 queue count 1
Family 1, flags 2 queue count 1
Family 2, flags 4 queue count 1
dorian-apanel-intel commented 1 year ago

Issue can be reproduced on NVidia by commenting those two lines (pretending that single universal queue is advertised):

        // Search for main queue that should be able to do all work (graphics, compute and transfer)
        if ( (queue_family.queueFlags & ( VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT )) == ( VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT ) ) {
            main_queue_family_index = fi;

            if ( queue_family.queueCount > 1 ) {
                // compute_queue_family_index = fi;
                // compute_queue_index = 1;
            }

            continue;
        }
dorian-apanel-intel commented 1 year ago

After grepping the whole solution, I do not see vulkan_compute_queue_family being used anywhere, Pool of vkCommandPools are created either for universal, or for transfer queues.

theWatchmen commented 1 year ago

Hi Dorian, many thanks for reporting this and a few other issues. Thank you also for the PRs. We'll take a look soon, we are in the middle of preparing for a conference :)

theWatchmen commented 1 year ago

I "merged" your changes. If you're happy with them, could you close this issue?

dorian-apanel-intel commented 1 year ago

Thanks for merging. Verified it with 47e8c21 on top.

Side note: On GPU's with no compute queue, there is crash when creating device. The same is when you have two GPUs, and one without compute queue is picked. (Family index passed is 0xFFFFFFFF)

theWatchmen commented 1 year ago

Thanks, I'll have a look at this as well. I thought we had checks in place for that scenario, but clearly they don't cover all cases.