From 8ae65bea81cdb756570efed514db13d41ad64aae Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 11 Feb 2025 20:30:22 +0000
Subject: [PATCH 1/3] launch-options: Set SDL_VIDEO_DRIVER as well as
 SDL_VIDEODRIVER

SDL 2 uses SDL_VIDEODRIVER, SDL 3 prefers SDL_VIDEO_DRIVER. Having
individual control over the two libraries doesn't seem worth the extra
space taken up in the UI, so set both from the same combo box.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 bin/launch-options.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/launch-options.py b/bin/launch-options.py
index 9f1ae2c11..2ed19fa17 100755
--- a/bin/launch-options.py
+++ b/bin/launch-options.py
@@ -1828,6 +1828,7 @@ class Gui:
 
         if value is not None:
             environ['SDL_VIDEODRIVER'] = value
+            environ['SDL_VIDEO_DRIVER'] = value
 
         if self.debug_check.get_active():
             environ['STEAM_LINUX_RUNTIME_VERBOSE'] = '1'
-- 
GitLab


From f0bfdc3d63e680812a37bbcbb4476617560576f4 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 11 Feb 2025 20:31:00 +0000
Subject: [PATCH 2/3] launch-options: Allow control over SDL dynamic API
 overrides

By default, we will use a bundled copy of SDL 2 or SDL 3 if a game happens
to provide one: for example, Hitman (2016) has a bundled copy of SDL
2.0.5, and Dota 2 has a bundled copy of some intermediate version between
3.1.6 and 3.1.8 at the time of writing. When using pressure-vessel,
we can override that with the Steam Runtime's newer, presumably-better
version (steamrt/tasks#578).

For SDL 2, in runtime versions that contain sdl2-compat as a non-default
version, we can do the same to replace classic SDL 2 with sdl2-compat
(steamrt/tasks#579).

Expose this in steam-runtime-launch-options to make it more discoverable
and easier to test.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 bin/launch-options.py | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/bin/launch-options.py b/bin/launch-options.py
index 2ed19fa17..81fe529ba 100755
--- a/bin/launch-options.py
+++ b/bin/launch-options.py
@@ -626,6 +626,29 @@ class Gui:
 
         row += 1
 
+        label = Gtk.Label.new('SDL 2')
+        self.grid.attach(label, 0, row, 1, 1)
+
+        self.sdl2_dynapi_combo = Gtk.ComboBoxText.new()
+        self.sdl2_dynapi_combo.append(None, "Don't override")
+        self.sdl2_dynapi_combo.append('1', 'Use runtime copy')
+        self.sdl2_dynapi_combo.append('sdl2-compat', 'Use sdl2-compat')
+        self.sdl2_dynapi_combo.set_active(0)
+        self.grid.attach(self.sdl2_dynapi_combo, 1, row, 2, 1)
+
+        row += 1
+
+        label = Gtk.Label.new('SDL 3')
+        self.grid.attach(label, 0, row, 1, 1)
+
+        self.sdl3_dynapi_combo = Gtk.ComboBoxText.new()
+        self.sdl3_dynapi_combo.append(None, "Don't override")
+        self.sdl3_dynapi_combo.append('1', 'Use runtime copy')
+        self.sdl3_dynapi_combo.set_active(0)
+        self.grid.attach(self.sdl3_dynapi_combo, 1, row, 2, 1)
+
+        row += 1
+
         label = Gtk.Label.new('Graphics stack')
         self.grid.attach(label, 0, row, 1, 1)
 
@@ -1260,10 +1283,14 @@ class Gui:
 
         if self._changing_container_runtime:
             self._changing_container_runtime = False
+            # These widgets are features of pressure-vessel, and are
+            # applicable if and only if we are going to use it.
             widgets = [
                 self.graphics_provider_combo,
                 self.layered_runtime_combo,
                 self.remove_game_overlay_combo,
+                self.sdl2_dynapi_combo,
+                self.sdl3_dynapi_combo,
                 self.share_home_combo,
                 self.share_pid_combo,
                 self.vulkan_layers_combo,
@@ -1830,6 +1857,18 @@ class Gui:
             environ['SDL_VIDEODRIVER'] = value
             environ['SDL_VIDEO_DRIVER'] = value
 
+        value = self.sdl2_dynapi_combo.get_active_id()
+
+        if value is not None:
+            environ.pop('SDL_DYNAMIC_API', None)
+            environ['STEAM_COMPAT_RUNTIME_SDL2'] = value
+
+        value = self.sdl3_dynapi_combo.get_active_id()
+
+        if value is not None:
+            environ.pop('SDL3_DYNAMIC_API', None)
+            environ['STEAM_COMPAT_RUNTIME_SDL3'] = value
+
         if self.debug_check.get_active():
             environ['STEAM_LINUX_RUNTIME_VERBOSE'] = '1'
             environ['G_MESSAGES_DEBUG'] = 'all'
-- 
GitLab


From 0abdad3eda35b8385d539288cd5f2466d66eb422 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 11 Feb 2025 20:31:18 +0000
Subject: [PATCH 3/3] launch-options: Set DEBUG_INVOCATION=1 if extra debug is
 requested

systemd sets this variable for units with `RestartMode=debug`
if a previous attempt at starting the unit failed, and projects
like GLib and pressure-vessel are starting to use it as a
general-purpose opt-in to extra debug information. I suggested in
https://github.com/libsdl-org/SDL/issues/12275 that SDL could maybe do
the same.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 bin/launch-options.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/launch-options.py b/bin/launch-options.py
index 81fe529ba..da957b8c2 100755
--- a/bin/launch-options.py
+++ b/bin/launch-options.py
@@ -1870,8 +1870,9 @@ class Gui:
             environ['STEAM_COMPAT_RUNTIME_SDL3'] = value
 
         if self.debug_check.get_active():
-            environ['STEAM_LINUX_RUNTIME_VERBOSE'] = '1'
+            environ['DEBUG_INVOCATION'] = '1'
             environ['G_MESSAGES_DEBUG'] = 'all'
+            environ['STEAM_LINUX_RUNTIME_VERBOSE'] = '1'
 
         shell = self.shell_combo.get_active_id()
         terminal = self.terminal_combo.get_active_id()
-- 
GitLab