From 815099f833287142011e92606d0ccb60c5cd217b Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Thu, 20 Jan 2022 14:29:54 +0100 Subject: [PATCH 1/2] Changelog: Mention #386 that was an important fix --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 855d5b45..e52c1b47 100644 --- a/Changelog.md +++ b/Changelog.md @@ -56,6 +56,7 @@ Note: Numbers starting with a "#" like #330 refer to the bugreport with that num * (Optionally) use libbacktrace on non-Windows platforms for more useful backtraces in case of crashes (usually linked statically) * Fixed a deadlock (freeze) on Windows when printing messages from another thread +* Fixed endless loop (game locking up at startup) if graphics settings couldn't be applied (#386) * Fixed some warnings and uninitialized variables (thanks *turol*!) * Work around dmap bug caused by GCC using FMA "optimizations" (#147) * Prevent dhewm3 from being run as root on Unix-like systems to improve security From d09ccb853901d611841cc3ff206e425cded67d07 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 24 Jan 2022 05:40:30 +0100 Subject: [PATCH 2/2] If creating window fails, first try to reduce MSAA level, fix #440 so if someone configured 16x AA on a system that doesn't support it (like when using AMDs open source driver), 8x will be tried before falling back to a 640x480 window with no AA at all. (and then it'll try 4x and then 2x and then no AA at all, and only then reducing color depth will start, and even later it'll fall back to a small 640x480 window) --- neo/sys/glimp.cpp | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index 6166796c..30c704a6 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -168,6 +168,9 @@ bool GLimp_Init(glimpParms_t parms) { int stencilbits = 8; for (int i = 0; i < 16; i++) { + + int multisamples = parms.multiSamples; + // 0 - default // 1 - minus colorbits // 2 - minus depthbits @@ -226,6 +229,8 @@ bool GLimp_Init(glimpParms_t parms) { int talphabits = r_waylandcompat.GetBool() ? 0 : channelcolorbits; +try_again: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, channelcolorbits); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, channelcolorbits); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, channelcolorbits); @@ -237,8 +242,8 @@ bool GLimp_Init(glimpParms_t parms) { SDL_GL_SetAttribute(SDL_GL_STEREO, parms.stereo ? 1 : 0); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, parms.multiSamples ? 1 : 0); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (multisamples > 1) ? 1 : 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisamples); #if SDL_VERSION_ATLEAST(2, 0, 0) @@ -284,9 +289,23 @@ bool GLimp_Init(glimpParms_t parms) { parms.width, parms.height, flags); if (!window) { - common->DPrintf("Couldn't set GL mode %d/%d/%d: %s", - channelcolorbits, tdepthbits, tstencilbits, SDL_GetError()); + common->Warning("Couldn't set GL mode %d/%d/%d with %dx MSAA: %s", + channelcolorbits, tdepthbits, tstencilbits, parms.multiSamples, SDL_GetError()); + + // before trying to reduce color channel size or whatever, first try reducing MSAA, if possible + if(multisamples > 1) { + multisamples = (multisamples <= 2) ? 0 : (multisamples/2); + + // using goto because enhancing that logic which reduces attributes + // based on i (so it'd first try reducing MSAA) would be too painful + goto try_again; + } + continue; + } else { + // creating the window succeeded, so adjust r_multiSamples to the value that was actually used + parms.multiSamples = multisamples; + r_multiSamples.SetInteger(multisamples); } /* Check if we're really in the requested display mode. There is @@ -380,7 +399,21 @@ bool GLimp_Init(glimpParms_t parms) { if (!window) { common->DPrintf("Couldn't set GL mode %d/%d/%d: %s", channelcolorbits, tdepthbits, tstencilbits, SDL_GetError()); + + // before trying to reduce color channel size or whatever, first try reducing MSAA, if possible + if(multisamples > 1) { + multisamples = (multisamples <= 2) ? 0 : (multisamples/2); + + // using goto because enhancing that logic which reduces attributes + // based on i (so it'd first try reducing MSAA) would be too painful + goto try_again; + } + continue; + } else { + // creating the window succeeded, so adjust r_multiSamples to the value that was actually used + parms.multiSamples = multisamples; + r_multiSamples.SetInteger(multisamples); } glConfig.vidWidth = window->w;