kondrak / vkQuake2

id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, macOS, FreeBSD, Raspberry Pi 4)
GNU General Public License v2.0
896 stars 90 forks source link

Assert failure in vmaCreateAllocator for Vulkan 1.3 #156

Closed per-mathisen-arm closed 1 year ago

per-mathisen-arm commented 1 year ago

Built on Ubuntu Linux 20.04 with NVIDIA GeForce RTX 2060 in debug mode. Driver has Vulkan 1.3. Runs into this issue:

quake2: ../ref_vk/vk_mem_alloc.h:18050: VkResult vmaCreateAllocator(const VmaAllocatorCreateInfo*, VmaAllocator_T**): Assertion `pCreateInfo->vulkanApiVersion == 0 || (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 22) == 1 && (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 12) & 0x3FFU) <= 2)' failed.

Backtrace:

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50

1 0x00007ffff7b63859 in __GI_abort () at abort.c:79

2 0x00007ffff7b63729 in __assert_fail_base (fmt=0x7ffff7cf9588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",

assertion=0x7ffff287c720 "pCreateInfo->vulkanApiVersion == 0 || (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 22) == 1 && (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 12) & 0x3FFU) <= 2)", 
file=0x7ffff2878e95 "../ref_vk/vk_mem_alloc.h", line=18050, function=<optimized out>) at assert.c:92

3 0x00007ffff7b74fd6 in __GI___assert_fail (

assertion=0x7ffff287c720 "pCreateInfo->vulkanApiVersion == 0 || (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 22) == 1 && (((uint32_t)(pCreateInfo->vulkanApiVersion) >> 12) & 0x3FFU) <= 2)", 
file=0x7ffff2878e95 "../ref_vk/vk_mem_alloc.h", line=18050, function=0x7ffff2880340 <vmaCreateAllocator::__PRETTY_FUNCTION__> "VkResult vmaCreateAllocator(const VmaAllocatorCreateInfo*, VmaAllocator_T**)")
at assert.c:101

4 0x00007ffff2847c15 in vmaCreateAllocator (pCreateInfo=0x7fffffffd1b0, pAllocator=0x7ffff28a5f58 ) at ../ref_vk/vk_mem_alloc.h:18049

5 0x00007ffff281e940 in QVk_Init () at ../ref_vk/vk_common.c:1762

6 0x00007ffff28632d1 in R_Init (hinstance=0x0, hWnd=0x0) at ../ref_vk/vk_rmain.c:1190

7 0x000055555562e3d4 in VID_LoadRefresh (name=0x7fffffffd6a0 "ref_vk.so") at ../linux/vid_so.c:332

8 0x000055555562e5c1 in VID_CheckChanges () at ../linux/vid_so.c:406

9 0x000055555562e874 in VID_Init () at ../linux/vid_so.c:465

10 0x000055555556d6df in CL_Init () at ../client/cl_main.c:1795

11 0x00005555556197b3 in Qcommon_Init (argc=23, argv=0x7fffffffd888) at ../qcommon/common.c:1481

12 0x000055555562f715 in main (argc=23, argv=0x7fffffffd888) at ../linux/sys_linux.c:310

Looks like VMA doesn't like Vulkan 1.3, but instead of actually choosing Vulkan 1.2, the vkQuake2 code appears to select the lower of the instance Vulkan version and the device Vulkan version... which doesn't really make much sense? I can get around this issue by commenting out the line in vk_common.c where vkEnumerateInstanceVersion() is called. Now Vulkan 1.0 is enforced, which makes VMA happy.

kondrak commented 1 year ago

The VMA in the project was fairly old - it predated the release of Vulkan 1.3, which might explain why there are problems with it. I updated it to 3.0.1 now, which should fix the problem. I cannot test it myself, unfortunately, since I don't have neither Mac nor Linux anymore - sorry I can't be of more help!