f1nalspace / final_game_tech

Game related libraries written in C/C++ written by T. Spaete
MIT License
177 stars 10 forks source link

[Vulkan/X11] Crash on XCloseDisplay #115

Closed f1nalspace closed 3 years ago

f1nalspace commented 3 years ago

In the develop branch i started to create vulkan implementation - with and without FPL. On win32 it works, i have a blue cleared screen and re-create the swap-chain on resize. On X11 it works too, but it crashes when i destroy the X11 window :-(

I looked at the official spec and i found something, which may help? https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#platformCreateSurface_xlib -> XInitThreads()

From looking around other implementations, there is one important note - which applies to opengl as well.

NOTE: In the current fpl_vulkan.c i tried that and it still crashes the application :-( Not sure why, in GLFW/SDL they load/unload the library before the window is being created and after the window has been shut down. Weird problem.

I have to create a separate c file, without any FPL code - to identify that. Bad i have removed my old playgrounds from the early days :-(

f1nalspace commented 3 years ago

I made a single file which reproduces the error:

https://pastebin.com/iZ2guWTy

Compile with: gcc -std=c99 -g3 -DDEBUG main.c -ldl -lm -lX11 -o vulkan

f1nalspace commented 3 years ago

Fixed by moving destroying of the VkInstance after the window has been closed.