Warm tip: This article is reproduced from stackoverflow.com, please click
c++ QT vulkan

Get Queue Families in Vulkan Qt

发布于 2020-05-02 22:27:44

I am using the QVulkanWindow example, trying to load an image and display it in the Qt window.

This sets up the Vulkan instance:

if (!inst.create())
    qFatal("Failed to create Vulkan instance: %d", inst.errorCode());

VulkanWindow w;
w.setVulkanInstance(&inst);

Now in initResources() of the VulkanRenderer class I want to get the GraphicsQueue from the device:

m_devFuncs->vkGetDeviceQueue(device, VK_QUEUE_GRAPHICS_BIT, 0, &graphicsQueue);

The error I get is:

vkDebug: Validation: 0:  [ VUID-vkGetDeviceQueue-queueFamilyIndex-00384 ] Object: 0x564e779a5f90 (Type = 3) | 
vkGetDeviceQueue: queueFamilyIndex (= 1) is not one of the queue families given via VkDeviceQueueCreateInfo structures when the device was created. 
The Vulkan spec states: queueFamilyIndex must be one of the queue family indices specified when device was created, via the VkDeviceQueueCreateInfo structure 

Did Qt not set up the Graphics Queue? Or am I doing it wrong? Or should I create my own VkInstance and pass it to Qt?

Questioner
tde
Viewed
30
krOoze 2020-02-13 22:07

VK_QUEUE_GRAPHICS_BIT is an enumerant, not a queue family index. So that code is fundamentally incorrect.

The graphicsQueue() method of QVulkanWindow returns a VkQueue you can use.