diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-06-20 12:52:28 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-06-21 22:54:19 +0200 |
commit | fc3ee08737ab53b8ad033e50b3b14fc8bba4bca1 (patch) | |
tree | d8af7650250cfd6fcb25b722a57bb7413c8cf15c /src/gui/rhi/qrhivulkan.cpp | |
parent | 300da03e3a0b80797e8cb9ddae90233244704691 (diff) |
rhi: vulkan: Shuffle post-1.0 phys.dev.feature queries
Make it so that what we query with regards to 1.1, 1.2, and 1.3 features
are stored for later use. This will be relevant for e.g. multiview where
the multiview field will need to be checked when deciding if the feature
is supported at run time.
All this is only really compatible with Vulkan 1.2 and newer. Vulkan 1.1
does not have the 1.2 approach, i.e. there is no
VkPhysicalDeviceVulkan11Features
in Vulkan 1.1 (!). That is a struct added in Vulkan 1.2. In 1.1 one had
the feature (extension) specific structs, such as
VkPhysicalDeviceMultiviewFeatures
in case of multiview. That we do not bother with at the moment.
Then again that's nothing new. The existing code to enable all features
with a few exceptions, that's already tied to the 1.2+ way of working
with physical device features, and not quite compatible with a pure
1.1 (not 1.0, not 1.2+) implementation (which should be hopefully rare
out there).
Pick-to: 6.6
Change-Id: I661f2634651d28edd9b5feec66a423220920f894
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/gui/rhi/qrhivulkan.cpp')
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index cc9bcc2883..4b7af8a89e 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -529,7 +529,31 @@ bool QRhiVulkan::create(QRhi::Flags flags) driverInfoStruct.vendorId = physDevProperties.vendorID; driverInfoStruct.deviceType = toRhiDeviceType(physDevProperties.deviceType); - f->vkGetPhysicalDeviceFeatures(physDev, &physDevFeatures); +#ifdef VK_VERSION_1_2 // Vulkan11Features is only in Vulkan 1.2 + VkPhysicalDeviceFeatures2 physDevFeaturesChainable = {}; + physDevFeaturesChainable.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + physDevFeatures11 = {}; + physDevFeatures11.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; + physDevFeatures12 = {}; + physDevFeatures12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; +#ifdef VK_VERSION_1_3 + physDevFeatures13 = {}; + physDevFeatures13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; +#endif + if (caps.apiVersion >= QVersionNumber(1, 2)) { + physDevFeaturesChainable.pNext = &physDevFeatures11; + physDevFeatures11.pNext = &physDevFeatures12; +#ifdef VK_VERSION_1_3 + if (caps.apiVersion >= QVersionNumber(1, 3)) + physDevFeatures12.pNext = &physDevFeatures13; +#endif + f->vkGetPhysicalDeviceFeatures2(physDev, &physDevFeaturesChainable); + memcpy(&physDevFeatures, &physDevFeaturesChainable.features, sizeof(VkPhysicalDeviceFeatures)); + } else +#endif // VK_VERSION_1_2 + { + f->vkGetPhysicalDeviceFeatures(physDev, &physDevFeatures); + } // Choose queue and create device, unless the device was specified in importParams. if (!importedDevice) { @@ -662,42 +686,18 @@ bool QRhiVulkan::create(QRhi::Flags flags) // tessellationShader, geometryShader // textureCompressionETC2, textureCompressionASTC_LDR, textureCompressionBC -#ifdef VK_VERSION_1_2 // Vulkan11Features is only in Vulkan 1.2 - VkPhysicalDeviceFeatures2 physDevFeatures2 = {}; - physDevFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; - - VkPhysicalDeviceVulkan11Features features11 = {}; - features11.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; - VkPhysicalDeviceVulkan12Features features12 = {}; - features12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; -#ifdef VK_VERSION_1_3 - VkPhysicalDeviceVulkan13Features features13 = {}; - features13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; -#endif - +#ifdef VK_VERSION_1_2 if (caps.apiVersion >= QVersionNumber(1, 2)) { - physDevFeatures2.pNext = &features11; - features11.pNext = &features12; -#ifdef VK_VERSION_1_3 - if (caps.apiVersion >= QVersionNumber(1, 3)) - features12.pNext = &features13; -#endif - f->vkGetPhysicalDeviceFeatures2(physDev, &physDevFeatures2); - - physDevFeatures2.features.robustBufferAccess = VK_FALSE; + physDevFeaturesChainable.features.robustBufferAccess = VK_FALSE; #ifdef VK_VERSION_1_3 - features13.robustImageAccess = VK_FALSE; + physDevFeatures13.robustImageAccess = VK_FALSE; #endif - - devInfo.pNext = &physDevFeatures2; - } + devInfo.pNext = &physDevFeaturesChainable; + } else #endif // VK_VERSION_1_2 - - VkPhysicalDeviceFeatures features; - if (!devInfo.pNext) { - memcpy(&features, &physDevFeatures, sizeof(features)); - features.robustBufferAccess = VK_FALSE; - devInfo.pEnabledFeatures = &features; + { + physDevFeatures.robustBufferAccess = VK_FALSE; + devInfo.pEnabledFeatures = &physDevFeatures; } VkResult err = f->vkCreateDevice(physDev, &devInfo, nullptr, &dev); |