在 Vulkan Qt 中获取队列系列

Get Queue Families in Vulkan Qt

本文关键字:队列 系列 获取 Vulkan Qt      更新时间:2023-10-16

我正在使用QVulkanWindow示例,尝试加载图像并将其显示在Qt窗口中。

这将设置 Vulkan 实例:

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

现在,在 VulkanRenderer 类initResources(),我想从设备获取 GraphicsQueue:

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

我得到的错误是:

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 

Qt没有设置图形队列吗?还是我做错了?还是应该创建自己的VkInstance并将其传递给Qt?

VK_QUEUE_GRAPHICS_BIT

是一个枚举,而不是队列系列索引。所以代码从根本上是不正确的。

QVulkanWindowgraphicsQueue()方法返回可以使用的VkQueue