Daemon
Daemon copied to clipboard
Some systems don't support 640×480 resolution so we can't use that as a fallback in all cases
When the engine fails to run on the configured resolution, it falls back on 640×480.
But here on some Lenovo Thinkpad X1 carbon laptop (4th gen), that resolution isn't supported:
[28360.179490] i915 0000:00:02.0: [drm] User-defined mode not supported: "640x480": 60 23875 640 656 720 800 480 481 484 497 0x20 0x6
In fact the last time it tried to use that resolution the while display server crashed. Having the display server crashing is likely a bug in some underlying software like a driver bug, but the game can't run anyway.
So, when the configured resolution is not renderable, we may first fallback to the lowest resolution from the list of known resolution if the currently configured one is not part of it, then only try 640×480 is last resort.
Could we change the fallback to be: start in 640x480 and in windowed mode? Would that solve this problem?
Yes we can, it would work I guess.
In fact 640x480 in windowed mode is the fallback:
https://github.com/DaemonEngine/Daemon/blob/96f06112cc28ff0561bc41c39b42758a71a637d3/src/engine/sys/sdl_glimp.cpp#L2770
(The false second argument means not fullscreen). Though it is not tried if the first attempt was 640x480 (via r_mode 3) and full screen.
This might not work correctly when the originally requested config was fullscreen though, because it tries making a window in windowed mode, but does not update the r_fullscreen cvar. So probably the code that checks for r_fullscreen modifications will immediately try to put it back in full-screen mode.