我正在使用QVulkanWindow示例,尝试加载图像并将其显示在Qt窗口中。
这将设置Vulkan实例:
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
VulkanWindow w;
w.setVulkanInstance(&inst);
现在initResources()
,在VulkanRenderer类中,我想从设备获取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
是一个枚举数,而不是队列家族索引。因此该代码从根本上来说是不正确的。
该graphicsQueue()
方法QVulkanWindow
返回一个VkQueue
可以使用。
实际上,这是类型错误。遗憾的是,编译器不会阻止这种情况,因为历史上枚举数被隐式转换为int。