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 91 forks source link

Use XInitThreads to fix vulkan driver issues #116

Closed nyorain closed 3 years ago

nyorain commented 3 years ago

Hey and thanks for your work!

Under certain circumstances in linux, I am getting crashes (on master):

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
xcb_io.c:260: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

It seems there is a data race that is very rarely triggered with normal usage. I looked a bit around and it seems that the mesa vulkan drivers require XInitThreads to be called (they are indeed creating WSI threads internally), see here, also vkcube does it without using threads itself.

EDIT: nevermind, the spec itself states this must be done, search for XInitThreads in that chapter.

Adding this to the code fixes the issue for me.

kondrak commented 3 years ago

Thanks!