From e4c211b98790fd1bbe28e496bd13a88486509d2c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 4 Apr 2026 14:13:21 -0500 Subject: [PATCH] Automatically set SDL_KMSDRM_ATOMIC=0 on older SDL3 versions Fixes #1824 --- app/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index edd153d5..abbe833f 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -801,6 +801,34 @@ int main(int argc, char *argv[]) "Running with SDL %d.%d.%d", runtimeVersion.major, runtimeVersion.minor, runtimeVersion.patch); + // If we're running under sdl2-compat, it may tell us the underlying SDL3 version + const char* sdl3Version = SDL_GetHint("SDL3_VERSION"); + int sdl3VersionInt = 0; + if (sdl3Version) { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "SDL3 version: %s", + sdl3Version); + + // Parse the version into integer form + QStringList list = QString(sdl3Version).split('.'); + Q_ASSERT(list.size() == 3); + if (list.size() == 3) { + sdl3VersionInt = SDL_VERSIONNUM(list.at(0).toInt(), list.at(1).toInt(), list.at(2).toInt()); + } + } + + // SDL 3.4.0 and 3.4.2 have bugs in atomic KMSDRM support that break us, + // so disable atomic on the affected SDL3 versions. Since not all versions + // of sdl2-compat will set the SDL3_VERSION hint, we assume that versions + // prior to 2.32.66 are affected (since that was released at the same time + // as SDL 3.4.4 with the atomic fixes). + if ((sdl3VersionInt != 0 && sdl3VersionInt < SDL_VERSIONNUM(3, 4, 4)) || + (runtimeVersion.patch >= 50 && runtimeVersion.patch < 66)) { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Setting SDL_KMSDRM_ATOMIC=0 for older sdl2-compat/SDL3 version"); + SDL_SetHint("SDL_KMSDRM_ATOMIC", "0"); + } + // Apply the initial translation based on user preference StreamingPreferences::get()->retranslate();