rhi: vulkan: Don't assert in VMA when vk header is older than runtime
Building Qt with e.g. a version 1.2.x Vulkan SDK and then running on an implementation providing 1.3 or 1.4, one will likely get an assert in debug builds upon initializing the memory allocator. Work it around by restricting the apiVersion passed in based on the preprocessor macros. Pick-to: 6.8 Change-Id: Ia689ffc29d5675b84b6683e289d0725d7e47220b Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit b6d4c1368d38242a8c677efc3144c10cfe363179) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
afc5747e9b
commit
80dee1a9f9
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user