diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 9d217a3bfdd..d0528fd7c75 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1017,9 +1017,37 @@ bool QRhiVulkan::create(QRhi::Flags flags) allocatorInfo.device = dev; allocatorInfo.pVulkanFunctions = &funcs; allocatorInfo.instance = inst->vkInstance(); - allocatorInfo.vulkanApiVersion = VK_MAKE_VERSION(caps.apiVersion.majorVersion(), - caps.apiVersion.minorVersion(), - caps.apiVersion.microVersion()); + + // Logic would dictate setting allocatorInfo.vulkanApiVersion to caps.apiVersion. + // However, VMA has asserts to test if the header version Qt was built with is + // older than the runtime version. This is nice, but a bit unnecessary (in Qt we'd + // rather prefer losing the affected features automatically, and perhaps printing + // a warning, instead of aborting the application). Restrict the runtime version + // passed in based on the preprocessor macro to keep VMA happy. +#ifdef VK_VERSION_1_4 + if (caps.apiVersion >= QVersionNumber(1, 4)) + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_4; + else +#endif +#ifdef VK_VERSION_1_3 + if (caps.apiVersion >= QVersionNumber(1, 3)) + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_3; + else +#endif +#ifdef VK_VERSION_1_2 + if (caps.apiVersion >= QVersionNumber(1, 2)) + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_2; + else +#endif +#ifdef VK_VERSION_1_1 + if (caps.apiVersion >= QVersionNumber(1, 1)) + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_1; + else +#endif +#ifdef VK_VERSION_1_0 + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_0; +#endif + VmaAllocator vmaallocator; VkResult err = vmaCreateAllocator(&allocatorInfo, &vmaallocator); if (err != VK_SUCCESS) {