My window handling code for Win32 / X11 / Cocoa lives in the main thread, and all my Vulkan code is compartmentalized into the rendering thread. The only place this causes problems is with window resizing. The main thread is capable of resizing a window while the rendering thread is in the middle of a render. I can generate validation layer errors in Vulkan that says something like “the swap chain image size does not match device window size” or something like that.
The application is a 3D game engine that is intended for use both as a real-time game engine and as a 3D rendering system embedded in a GUI application. It will run in both real-time and event-driven apps with multiple 3D viewports in a resizable window.
I’ve tried many things but have encountered the following problems:
- WM_WINDOWPOSCHANGING / WM_WINDOWPOSCHANGED don’t actually seem to occur in pairs, so it’s difficult to use those to toggle a mutex.
- There seems to be no LInux equivalent to the above events.
At this point I am leaning towards implementing a multithreaded “game” mode that does not support resizable windows, along with a single-threaded application mode that does support resizable windows. Before I give up on this, can anyone advise me otherwise? Am I trying to do something no sane person would do or is there a known common solution to this problem?