godot: VmaCountBitsSet crashes on older CPUs without support for POPCNT

Godot version

4.0.dev (fe95aa2c9)

System information

Windows 10, Vulkan, Nvidia 750ti (30.0.15.1123)

Issue description

4.0 master crash on startup. Same with --single-window, -e project. I have bisected and found issue starting from commit fe95aa2c90ddd9116f545c77e00cb5eec99fe486 is the first bad commit Fix extension registration order.

Example of error message

I:\Work> Godot Engine v4.0.alpha.custom_build.2b8a6c14d - https://godotengine.org
Vulkan API 1.2.189 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 750 Ti

I:\Work> Godot Engine v4.0.alpha.custom_build.2b8a6c14d - https://godotengine.org
================================================================
CrashHandlerException: Program crashed
Vulkan API 1.2.189 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 750 Ti
Engine version: Godot Engine v4.0.alpha.custom_build (2b8a6c14dfcfa480d8a9e88c823578a74b43bd73)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] VmaCountBitsSet (I:\Work\godot\thirdparty\vulkan\vk_mem_alloc.h:3064)
[1] vmaFindMemoryTypeIndex (I:\Work\godot\thirdparty\vulkan\vk_mem_alloc.h:16806)
[2] VmaAllocator_T::AllocateMemory (I:\Work\godot\thirdparty\vulkan\vk_mem_alloc.h:15462)
[3] vmaCreateBuffer (I:\Work\godot\thirdparty\vulkan\vk_mem_alloc.h:17545)
[4] RenderingDeviceVulkan::_insert_staging_block (I:\Work\godot\drivers\vulkan\rendering_device_vulkan.cpp:1388)
[5] RenderingDeviceVulkan::initialize (I:\Work\godot\drivers\vulkan\rendering_device_vulkan.cpp:8932)
[6] DisplayServerWindows::DisplayServerWindows (I:\Work\godot\platform\windows\display_server_windows.cpp:3486)
[7] DisplayServerWindows::create_func (I:\Work\godot\platform\windows\display_server_windows.cpp:3529)
[8] DisplayServer::create (I:\Work\godot\servers\display_server.cpp:602)
[9] Main::setup2 (I:\Work\godot\main\main.cpp:1579)
[10] Main::setup (I:\Work\godot\main\main.cpp:1485)
[11] widechar_main (I:\Work\godot\platform\windows\godot_windows.cpp:156)
[12] _main (I:\Work\godot\platform\windows\godot_windows.cpp:191)
[13] main (I:\Work\godot\platform\windows\godot_windows.cpp:205)
[14] WinMain (I:\Work\godot\platform\windows\godot_windows.cpp:219)
[15] __scrt_common_main_seh (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[16] BaseThreadInitThunk
-- END OF BACKTRACE --
================================================================

Steps to reproduce

  1. Run, observe immediate crash

Minimal reproduction project

Not required

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

I realized what’s going on. My 10 years old CPU doesnt have POPCNT instruction. VmaCountBitsSet had been optimized with intrinsic but doesn’t actually check cpuid if that’s available on machine.

#ifdef _MSC_VER return __popcnt(v); #elif defined __GNUC__ || defined __clang__ return static_cast<uint32_t>(__builtin_popcount(v)); #else //...byte crunching implementation

Replacing with latter implementation allowed Godot to launch.

@akien-mga I have traced my crash to this commit 648a10514bfd574eebcd332ff5b672659ead5850 is the first bad commit vk_mem_alloc: Update to latest commit

Some observation I can’t run builds starting from 648a10514bfd574eebcd332ff5b672659ead5850 neither debug or release_debug I can’t run this artifact which is corresponds to 4.0 Alpha 3 https://github.com/godotengine/godot/actions/runs/1878375090 However i CAN run alpha3 which I downloaded from https://downloads.tuxfamily.org/godotengine/4.0/alpha3/

Curious if there is some difference in build process on Windows. From what I gather default scons build is with use_volk=yes I had no success in building with use_volk=no due to fatal error LNK1181: cannot open input file 'vulkan.lib'