rhi: vulkan: Enable all core features on the device

...except robustness.

Have the appropriate compile and runtime checks. This way we still
compile with any older (1.0, 1.1, 1.2) headers, and can function
at runtime with a plain 1.0 implementation. With Vulkan 1.2+ we
can start filling out the additional, version-specific (1.1, 1.2,
1.3) feature structs.

Task-number: QTBUG-105158
Change-Id: I0ba87f0f467bc11782e9203ff11f1ce494aaaf63
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2022-08-09 11:47:54 +02:00
parent cec3b3b4f9
commit ba30155638
2 changed files with 41 additions and 4 deletions

View File

@ -389,6 +389,8 @@ bool QRhiVulkan::create(QRhi::Flags flags)
f = inst->functions();
caps.vulkan11OrHigher = inst->apiVersion() >= QVersionNumber(1, 1);
caps.vulkan12OrHigher = inst->apiVersion() >= QVersionNumber(1, 2);
caps.vulkan13OrHigher = inst->apiVersion() >= QVersionNumber(1, 3);
rhiFlags = flags;
@ -583,7 +585,7 @@ bool QRhiVulkan::create(QRhi::Flags flags)
devInfo.enabledExtensionCount = uint32_t(requestedDevExts.count());
devInfo.ppEnabledExtensionNames = requestedDevExts.constData();
// Enable all 1.0 core features that are reported as supported, except
// Enable all features that are reported as supported, except
// robustness because that potentially affects performance.
//
// Enabling all features mainly serves third-party renderers that may
@ -596,10 +598,43 @@ 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
if (caps.vulkan12OrHigher) {
physDevFeatures2.pNext = &features11;
features11.pNext = &features12;
#ifdef VK_VERSION_1_3
if (caps.vulkan13OrHigher)
features12.pNext = &features13;
#endif
f->vkGetPhysicalDeviceFeatures2(physDev, &physDevFeatures2);
physDevFeatures2.features.robustBufferAccess = VK_FALSE;
#ifdef VK_VERSION_1_3
features13.robustImageAccess = VK_FALSE;
#endif
devInfo.pNext = &physDevFeatures2;
}
#endif // VK_VERSION_1_2
VkPhysicalDeviceFeatures features;
if (!devInfo.pNext) {
memcpy(&features, &physDevFeatures, sizeof(features));
features.robustBufferAccess = VK_FALSE;
devInfo.pEnabledFeatures = &features;
}
VkResult err = f->vkCreateDevice(physDev, &devInfo, nullptr, &dev);
if (err != VK_SUCCESS) {

View File

@ -857,6 +857,8 @@ public:
bool vulkan11OrHigher = false;
bool geometryShader = false;
bool nonFillPolygonMode = false;
bool vulkan12OrHigher = false;
bool vulkan13OrHigher = false;
} caps;
VkPipelineCache pipelineCache = VK_NULL_HANDLE;