Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.2
-
None
Description
The file qtbase/src/gui/rhi/qrhivulkan.cpp creates the Vulkan device but leaves all features disabled.
This is extremely problematic when these features are needed.
I'm currently doing Qt 5.15 -> OgreNext integration (see post) to be used in Gazebo simulator and this issue is getting in the way to keep validation from complaining.
Note that this bug does not only affect integration with 3rd Party software, but also affects anyone who directly wants to use Vulkan commands (e.g. like in vulkantextureimport/vulkantextureimport.cpp sample) and needs these features.
The following patch fixes this issue:
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 26c153afff..617271b0c2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -540,6 +540,31 @@ bool QRhiVulkan::create(QRhi::Flags flags) devInfo.enabledExtensionCount = uint32_t(requestedDevExts.count()); devInfo.ppEnabledExtensionNames = requestedDevExts.constData(); + // Declared at this scope because they must be alive for devInfo.pNext + VkPhysicalDeviceFeatures deviceFeatures; + VkPhysicalDeviceFeatures2 deviceFeatures2; + + // Enable all features that are safe to do so + // If we don't do this, Vulkan assumes they are all false / 0 by default + if (inst->extensions().contains(QByteArrayLiteral("VK_KHR_get_physical_device_properties2"))) { + memset(&deviceFeatures2, 0, sizeof(deviceFeatures2)); + deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + + PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR = + (PFN_vkGetPhysicalDeviceFeatures2KHR)inst->getInstanceProcAddr( + "vkGetPhysicalDeviceFeatures2KHR" ); + + // Send the same chain to vkCreateDevice + devInfo.pNext = &deviceFeatures2; + + GetPhysicalDeviceFeatures2KHR( physDev, &deviceFeatures2 ); + } + else { + memset(&deviceFeatures, 0, sizeof(deviceFeatures)); + f->vkGetPhysicalDeviceFeatures( physDev, &deviceFeatures ); + devInfo.pEnabledFeatures = deviceFeatures; + } + err = f->vkCreateDevice(physDev, &devInfo, nullptr, &dev); if (err != VK_SUCCESS) { qWarning("Failed to create device: %d", err);
This bug may affect 6.x; and it definitely affects 5.15.2.
We hope this patch lands makes it to 5.15.3