@@ -97,11 +97,15 @@ What was really run: see [Status](#status) (a real install into a scratch prefix
| `summit doctor` readiness list | **Working** (KDE Wayland) / **Tested** | Says whether the engine, its venv, torch with CUDA, the model, `ffmpeg`, `xrandr`, `xdg-open` and a file dialog are there, and what each missing one turns off. On Wayland also XWayland, the ScreenCast and GlobalShortcuts portals, `summit.desktop` for the app id (the warning's wording is hedged after the re-run: the portal worked once without it), PipeWire and GStreamer's `pipewiresrc`, KWin, the monitor tool and the GPU. Run on the KDE Wayland desktop, twice (all ok, torch 2.11+cu128 on the RTX 5080; the second time from an installed copy) and on the build machine; unit tests. |
| Pin to Home, custom artwork | **Working** / **Tested** | Pins from the CLI and the launcher; `summit art`. **New since the RC run**: the launcher's **Change artwork** opens the desktop's file dialog (kdialog on KDE, zenity elsewhere) and the cover and backdrop change at once: checked on Xvfb with a stand-in zenity, not on a real desktop. |
| Display profile applied at launch (monitor, resolution, refresh) and put back | **Working on X11 and KDE Wayland** | KDE Wayland: `summit run` switched HDMI-A-1 from 1920x1080 @ 119.98 to @ 60 Hz and back, four times, with `kscreen-doctor` picking the mode by id (that monitor has two modes named `1920x1080@120`, so the old name-based plan could restore the wrong one). X11, earlier: from a custom mode to 1280x800 @ 74.99 Hz and back. wlroots: unit tests only. GNOME Wayland: skipped with a message. |
-| Per-game profile editor (Profile on a game's page) | **Working** (earlier run) | Listed the monitor's real xrandr modes; every change is written to the profile. Not opened in this run. |
-| Launcher defaults with per-game overrides (Settings > Default launch profile; every setting: monitor and mode, window mode, focus, Enhance, upscaler and its quality, frame generation, model, motion detail, AI engine, Steady HUD, output rate, fill, VSync, watermark, launch arguments, environment) | **Tested** | New. Profiles are layered: `default.toml` holds the defaults, a game's file only what it changes; in the editor each game row starts with "Default · ". Unit tests cover the layering, the old-file migration and the editor rows; the CLI was run against a scratch config, and the editor was rendered headless and driven with keys (a choice changed, one reset with Delete, an environment variable typed and saved). The new engine flags (`--fsr-sharpness`, `--vsr-quality`, `--vfg-quality`, `--scale`, `--engine`, `--steady-hud`, `--fill`, `--vsync`) are checked as argv only, **not with a running engine**. |
+| Settings page built from the engine's settings registry: every engine setting in its section, a section list, search, the quick settings on top, help, picture/speed lines, Experimental tags, greyed with the reason when not used, a dot and reset for changed rows | **Tested** (headless) | New. The launcher asks the engine (`python -m framegen.settings`) and keeps no copy: a copy of the engine with an invented section, new settings, a new impact line and a setting without choices was rendered and showed all of them (`docs/media/launcher-ui/`, and a unit test). Rendered headless with the software renderer and driven with keys: a preset, a quick tile, a row, Delete, a typed search, the theme and the replay lengths each changed the real file (`settings.json`, `ui.toml`), which the engine's own `Settings.load` then read back. **Not run in a window on a desktop, not with a mouse, not with a controller**; animations were only seen as static frames. |
+| Engine presets (Quality, Balanced, Performance, Lowest delay), global or for one game, "Custom" once a value differs | **Tested** (headless) | New. One table (`crates/summit-core/src/presets.rs`); a test checks every value against the engine's registry. Applied with keys in a headless render, globally and to a game's profile. What each one costs is taken from the engine's own notes, **not measured for the presets**. |
+| A game's profile (Profile on its page): the same rows as Settings, each "Global" until the game sets its own | **Tested** (headless) | Rewritten. A game's engine settings go into an `[engine]` table in its profile and reach the engine as `--set KEY=VALUE` (new engine flag); `summit enhance --dry-run` printed them and the engine's parser took each. **No game was started with them.** Monitor modes were listed from xrandr in an earlier live run; not opened on a desktop in this one. |
+| A game's Statistics: time played, and the engine's session summaries | **Tested** / **Experimental** | New. Reads `*.json` under the engine's and Summit's `sessions` and `stats` folders as they are and shows the fields they hold. The engine's summaries come from another branch: **no real one was read**, only sample files and the empty state. |
+| Compare (a game's page): start with the engine's `--compare` | **Experimental** | New. Disabled with a note while the engine has no `--compare` (this branch's does not). Against a copy of the engine with a placeholder flag, a headless run built `summit run --compare=hz:60,90,120,150 --enhance`. The value spelling is a guess until the engine's side exists; **never run with a game**. |
+| Global settings with per-game overrides (launch settings: monitor and mode, window mode, focus, Enhance, launch arguments, environment; and every engine setting) | **Tested** | Profiles are layered: `default.toml` holds the game defaults (Settings > Game defaults), a game's file only what it changes. Engine settings are global in the engine's `settings.json` and per game in the profile's `[engine]` table. Unit tests cover the layering, the old-file migration, the rows and the argv; the CLI was run against a scratch config. Older profiles' named engine settings (`upscaler`, `framegen`...) still work and are replaced key by key as they are changed. With no multiplier in a profile, Summit now passes no `--hz`, so the engine's saved Frame multiplier counts. Checked as argv and with the engine's parser, **not with a running engine**. |
| Window mode (windowed / borderless / fullscreen), monitor and focus applied to the game's own window | **Working on KDE Plasma Wayland** / **Experimental elsewhere** | New. On the owner's Plasma Wayland desktop, `summit run` started an XWayland `xterm` from a launch script and a KWin script placed it: borderless covered HDMI-A-1 exactly (0,251 1920×1080), fullscreen moved it onto DP-1 and covered that, and windowed gave it a normal frame back. Other X11 desktops use `wmctrl` (unit tests only). A native Wayland game window, a Steam game (window class `steam_app_`) and KDE X11 were **not run**. |
| `summit enhance clip.mp4` (RIFE on a file) | **Working** (earlier run) | 30 fps 1080p to 60 fps at 14 ms per generated frame on the RTX 3090. |
-| Game controller navigation | **Experimental** | Reads `/dev/input/js*`; decoding and mapping unit tested, no real controller. The launcher listens to a pad only while its own window has the keyboard, and not at all while a game started from it runs (below). |
+| Game controller navigation | **Experimental** | Reads `/dev/input/js*`; decoding and mapping unit tested, no real controller. Y resets the focused setting, LB/RB change section in a profile. The launcher listens to a pad only while its own window has the keyboard, and not at all while a game started from it runs (below). |
| Play: a loading screen, then "now playing", and the launcher back when the game closes | **Working on X11; not yet tried on KDE Wayland or with a real Steam game** | Run for real in a private X server: Play on a game Summit starts itself put the loading screen up, then "now playing"; keys pressed in the launcher meanwhile changed nothing; Stop the game ended it; Esc took the launcher back with the game still running; when the game closed the launcher was back with the session counted. A Steam-style start (a stand-in `steam` command that hands the game off and returns, the game's processes marked as Steam marks them) showed Starting until the game's process appeared and the launcher was back about 3 s after it was gone. Not checked: a real Steam, Lutris or Heroic game, a real controller, and bringing the launcher's window to the front through KWin when the game ends. |
| Steam, Lutris, Heroic games started from the launcher | **Experimental** | Command lines are built and unit tested; no Steam, Lutris or Heroic on the test machines. Heroic (new): Epic and GOG games start through `xdg-open heroic://launch?appName=..&runner=..` (the format in Heroic's source), and the Flatpak Heroic's games are now found too. No Enhance for Lutris and Heroic games. Folders found on disk are not started directly: their button is **ADD** (see the Add a game row). |
| Compare settings live (C), anti-aliasing (`--aa`) | **Experimental** | New. Run in the engine's own window on the GPU test machine (RTX 3090 shared with another job, **software OpenGL** for the display) on recorded Voidrunner footage, started with `--compare`: four anti-aliasing strips, frame generation Off against 2x (30 and 61 fps measured), and the upscaler strips fullscreen (RTX VSR shown as unavailable, with why); the overlay's Compare tab was opened with injected keys and seen. Anti-aliasing measured there at 720p, GPU, steady state: FXAA 0.53, SMAA-style 0.69, CAS 0.33 ms a frame on average. Upscaler and look times there are software OpenGL's and mean nothing. **Not run**: a real game (over a game, C stays the game's key), RTX VSR in a strip, the divider drag, Compare in clips, a GPU-rendered display, Windows. |
@@ -133,8 +137,8 @@ A game's page has Play, an **Enhance** toggle and **Profile**. With Enhance on,
| | |
|---|---|
-|  |  |
-| Profile editor: monitor, resolution and refresh from xrandr | After Play: RIFE + FSR on the game's 720p window, full screen |
+|  |  |
+| A game's profile, Launch section (headless render; the modes were listed from xrandr in an earlier live run) | After Play: RIFE + FSR on the game's 720p window, full screen |
### Steam accounts
@@ -187,17 +191,30 @@ summit run custom:voidrunner --enhance # start the game and enhance its
summit enhance window:Voidrunner # or: enhance a game that is already running, by window title
```
-### Launch profiles: defaults and per-game overrides
+### Settings, presets and a game's profile
-Every setting a game launches with lives in a profile, and profiles are layered. **Settings > Default launch profile** (`~/.config/summit/profiles/default.toml`) holds the launcher's defaults; a game's **Profile** (its page) stores only what that game changes, so a new default reaches every game that has not set its own. In a game's editor each setting's first choice is "Default · ", the settings the game sets itself have an accent mark, **Delete** puts one back to the default and **Follow defaults** clears them all. From the command line: `summit profile set default ...`, `summit profile set ...`, `summit profile show ` (`--own` for the game's file alone) and `summit profile reset [settings]`.
-
-| Group | Settings |
+| | |
|---|---|
-| Display | monitor (switched at launch and put back), resolution, refresh rate, **window mode** (as the game opens it, windowed, borderless window, fullscreen), focus |
-| Upscaling | Enhance on Play, upscaler (FSR, RTX VSR, bilinear, off), FSR sharpening, RTX VSR quality, fill (fit, zoom, stretch, panorama) |
-| Frame generation | on/off, model (RIFE 4.22 lite, 4.25 lite, 4.25, 4.26, NVIDIA VFG), VFG quality, motion detail, AI engine, Steady HUD, output rate |
-| Engine window | VSync, watermark |
-| Launch | launch arguments, environment variables (a game's keys win over the defaults') |
+|  |  |
+| Settings > Frame generation: the engine's own sections, help and choices | Search across every section |
+|  |  |
+| A game's profile: "Global" until the game sets its own (dotted) | Not used right now: greyed, with why |
+|  |  |
+| Presets say exactly what they set | Statistics (the two sessions are sample files, see below) |
+
+These are headless renders of the real window (software renderer, invented demo library), each a settled frame: **animations are not shown and were only checked as static frames**. `docs/demo/launcher-ui-shots.sh` makes them again; all of them, in two themes each, are in `docs/media/launcher-ui/`.
+
+**Settings** (the gear) has a section list on the left: **Launcher** (layout, theme, size, motion, the overlay key, the clips folder, NVIDIA's runtime), **Game defaults** (the launch settings every game starts with), then the engine's own sections, exactly as the engine lists them. The launcher has no copy of the engine's settings: it asks the engine, so a setting the engine gains shows up by itself, in its section, with its help. Each row shows its help, what it does to the picture and to speed, an Experimental tag where the engine says so, and is greyed out with the reason when it is not used now (FSR sharpening while the upscaler is RTX VSR). A dot marks a row that is not the default; **Delete** (Y on a pad) puts it back, and each section ends with a reset for the whole section. `/` searches every section. The focused row's whole help text, every choice with its line, and the default are in the panel on the right.
+
+Where things are saved: the launcher's own settings in `~/.config/summit/ui.toml`, launch settings in `~/.config/summit/profiles/`, and the engine's global settings in the engine's own `settings.json` (the same file its in-game overlay writes), key by key. The two instant-replay lengths are in `ui.toml`, since Summit passes them on every start. Fullscreen is decided by **Window mode** once that is chosen, and the row says so.
+
+**Presets** (Quality, Balanced, Performance, Lowest delay) set six engine settings and nothing else; the panel lists them. "Now:" names the preset in use, or **Custom** once any of the six differs. In a game's profile a preset is set for that game only.
+
+**A game's Profile** (its page) is the same page for that game: **Launch** first (monitor and mode, window mode, focus, Enhance on Play, launch arguments, environment, the game's window), then the engine's sections, where every row starts as "Global · " and becomes the game's own (dotted) when changed. Delete, or the first choice, gives it back to the global setting. From the command line: `summit profile set default ...`, `summit profile set ...`, `summit profile show ` (`--own` for the game's file alone) and `summit profile reset [settings]`; a game's engine settings are an `[engine]` table in its file, e.g. `overlay_style = "graphs"`.
+
+**Statistics** (a game's page) shows the time played, the sessions Summit counted and their average length, and lists the session summaries the engine has written for the game: the duration, frame rates and settings a file holds, and every field of the selected one. The engine's summaries are being added on another branch; until an engine writes them the list says "No sessions yet". The two sessions in the picture above are sample files written by the screenshot script.
+
+**Compare** (a game's page, Experimental) starts the game with Enhance and the engine's live comparison of one setting's values. It is disabled, with a note, while the engine has no `--compare`.
Window mode and focus are applied to the game's own window once it opens: on KDE Plasma by a KWin script (Wayland and X11), on other X11 desktops with `wmctrl`. A Wayland desktop other than Plasma gives Summit no way to place another program's window, so there the game keeps its own. With Enhance on, the window mode is the engine's picture (windowed over the game's window, or covering the monitor) and the game's window is only moved and focused. Profiles written by older versions are read as layers: values that only meant "nothing chosen" (`false`, `""`, `0`) follow the defaults, and `fullscreen = true` becomes `window_mode = "borderless"`.
@@ -338,8 +355,8 @@ Headless renders of every style with made-up numbers (labelled on the picture) c
- **Home**: the focused game as a hero, over shelves: Jump back in (recently played), Pinned, Most played. Hours come from Steam's own playtime for Steam games and from Summit's sessions for everything else.
- **Library**: every game, installed or not. Cover grid or dense list, filter, sort, search, **+ Add a game**.
- **Unfiltered**: everything on this machine, grouped by source, with the reason each entry was detected.
-- **A game's page** (Enter on a game): stats, launch profile, detection reasons, Play, Pin.
-- **Settings** (the gear): layout, theme, interface size, animation speed and style, clip lengths and the clips folder, the in-game overlay's key, default upscaler and frame generation for `summit enhance`.
+- **A game's page** (Enter on a game): stats, launch profile, detection reasons, Play, Enhance, Compare (Experimental), Pin, Profile, Statistics, artwork.
+- **Settings** (the gear): the launcher's own settings, the game defaults, engine presets and every engine setting (see Settings, presets and a game's profile).
- If a game started from the launcher fails (`summit run` ends with an error), a toast says why; the full output is in `~/.cache/summit/last-run.log`.
**While you play.** Play puts up a loading screen, then a small "now playing" card, and that is all the launcher is until the game is gone: no menus behind it to steer by accident. The game's window gets the keyboard once it opens (KDE Plasma, or X11 with wmctrl), and when the game closes the launcher comes back by itself, in front.
@@ -355,12 +372,15 @@ Headless renders of every style with made-up numbers (labelled on the picture) c
| Esc | B | Back, or Home |
| Tab, Shift+Tab | RB, LB | Next, previous section |
| P | X | Pin or unpin the focused game |
-| / | | Search the library |
+| / | | Search the library; in Settings or a profile, search the settings |
+| Left, Right | d-pad, left stick | In Settings or a profile: change the focused setting |
+| Delete | Y | Reset the focused setting (in a profile: use the global one) |
+| Page Up, Page Down | LB, RB in a profile | Previous, next section of the settings |
| F11 | | Fullscreen |
The window uses Slint's OpenGL renderer (FemtoVG) and falls back to its software renderer. To add a theme, append one palette to `Theme.palettes` in `crates/summit-gui/ui/theme.slint`.
-Headless renders, for screenshots and for checking the UI without a display: `SUMMIT_SHOT=` writes a PNG and exits. `SUMMIT_VIEW`, `SUMMIT_LAYOUT`, `SUMMIT_THEME`, `SUMMIT_DETAIL`, `SUMMIT_KEYS`, `SUMMIT_SIZE` and `SUMMIT_SCALE` choose what is drawn; they are described at the top of `crates/summit-gui/src/shot.rs`.
+Headless renders, for screenshots and for checking the UI without a display: `SUMMIT_SHOT=` writes a PNG and exits. `SUMMIT_VIEW`, `SUMMIT_LAYOUT`, `SUMMIT_THEME`, `SUMMIT_DETAIL`, `SUMMIT_KEYS`, `SUMMIT_SIZE` and `SUMMIT_SCALE` choose what is drawn, and `SUMMIT_SECTION`, `SUMMIT_SEARCH`, `SUMMIT_ZONE`, `SUMMIT_EDITOR`, `SUMMIT_STATS` and `SUMMIT_COMPARE` where the settings pane and a game's overlays are; they are described at the top of `crates/summit-gui/src/shot.rs`.
## Credits
diff --git a/crates/summit-cli/src/main.rs b/crates/summit-cli/src/main.rs
index 011c328..e41b6df 100644
--- a/crates/summit-cli/src/main.rs
+++ b/crates/summit-cli/src/main.rs
@@ -32,6 +32,9 @@ enum Cmd {
#[arg(long, default_value_t = 60)] wait: u32,
/// With --enhance: hide the "summit - git.molberg.cloud/alex/summit" line in the corner
#[arg(long)] no_watermark: bool,
+ /// With --enhance: the engine's live comparison, `:,,...` (e.g. scaler:off,fsr).
+ /// Experimental: needs an engine that has --compare.
+ #[arg(long)] compare: Option,
/// The command hands the game to another program and returns at once (`steam steam://rungameid/N`).
/// With --enhance, Summit then waits for the engine (the game's window) instead of the command.
#[arg(long)] detached: bool,
@@ -341,7 +344,9 @@ fn main() -> Result<()> {
let missing = checks.iter().filter(|c| c.status == doctor::Status::Missing).count();
if missing == 0 { println!("all set"); } else { println!("{missing} missing: see the lines marked MISS"); }
}
- Cmd::Run { id, enhance, window, wait, no_watermark, detached, focus, title, mut cmd } => {
+ Cmd::Run { id, enhance, window, wait, no_watermark, compare, detached, focus, title, mut cmd } => {
+ let compare = compare.map(|c| engine::parse_compare(&c).map_err(|e| anyhow::anyhow!("--compare: {e}"))).transpose()?;
+ anyhow::ensure!(compare.is_none() || enhance, "--compare needs --enhance: the comparison is drawn by the engine");
// From here on a signal to summit stops the game and the engine and puts the display mode back.
signals::install();
let st = state::load();
@@ -402,7 +407,7 @@ fn main() -> Result<()> {
let status = if let (Some(eng), true) = (&eng, remote_play) {
// The engine first: it has to see the stream start (the codec header comes once, as the stream's
// first packet), so chiaki-ng is started once the engine says it is waiting on the frame tap.
- let live = engine::Live { wait_secs: 0, watermark: if no_watermark { Some(false) } else { None } };
+ let live = engine::Live { wait_secs: 0, watermark: if no_watermark { Some(false) } else { None }, compare: compare.clone() };
let mut args = engine::plan(eng, &engine::Source::Ps5, &p, true, None, None);
args.extend(engine::live_args(&live));
{
@@ -441,7 +446,7 @@ fn main() -> Result<()> {
} else if let Some(eng) = eng {
let mut game = child.spawn().map_err(|e| anyhow::anyhow!("could not start {}: {e}", cmd[0]))?;
placer = start_placer(s, d, &p, true, place_target(&id, window.as_deref(), game.id()), wait);
- let live = engine::Live { wait_secs: wait, watermark: if no_watermark { Some(false) } else { None } };
+ let live = engine::Live { wait_secs: wait, watermark: if no_watermark { Some(false) } else { None }, compare: compare.clone() };
let mut args = engine::run_enhance_plan(&eng, game.id(), window.as_deref(), &p, &live);
{
let ui = summit_core::ui::load();
diff --git a/crates/summit-core/src/engine.rs b/crates/summit-core/src/engine.rs
index 2270dff..923a887 100644
--- a/crates/summit-core/src/engine.rs
+++ b/crates/summit-core/src/engine.rs
@@ -87,9 +87,9 @@ pub fn plan(engine: &Path, src: &Source, p: &Profile, display: bool, out: Option
if let Some(v) = p.aa.as_deref().filter(|v| crate::profile::AA.contains(v)) { a.push(opt("aa", v)); }
if display {
a.push("--display".into());
- // the frame multiplier N: the engine shows N frames for each real one of a 30 fps game, 30 x N fps
- let hz = 30 * u32::from(p.multiplier().unwrap_or(2));
- a.push("--hz".into()); a.push(hz.to_string());
+ // the frame multiplier N: the engine shows N frames for each real one of a 30 fps game, 30 x N fps.
+ // Not set in the profile: no flag, so the engine's own saved Frame multiplier is used (2x unless changed).
+ if let Some(m) = p.multiplier() { a.push("--hz".into()); a.push((30 * u32::from(m)).to_string()); }
if let Some(g) = p.game_fps.as_deref().filter(|g| crate::profile::GAME_FPS.contains(g)) { a.push(opt("game-fps", g)); }
if let Some((w, h)) = p.output_res.as_deref().and_then(crate::profile::parse_res) { a.push(format!("--output-res={w}x{h}")); }
match p.window_mode.as_str() {
@@ -101,6 +101,11 @@ pub fn plan(engine: &Path, src: &Source, p: &Profile, display: bool, out: Option
if let Some(f) = &p.fill { a.push(opt("fill", f)); }
if let Some(v) = p.vsync { a.push(if v { "--vsync" } else { "--no-vsync" }.into()); }
} else if let Some(o) = out { a.push(opt("out", &o.to_string_lossy())); }
+ // Engine settings by key (the profile's `engine` table): `--set=KEY=`, read after the flags above, so
+ // these win. One the engine does not know (an older engine) is said in its log and left out.
+ for (k, v) in &p.engine {
+ if k.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') && !k.is_empty() { a.push(format!("--set={k}={}", crate::registry::from_toml(v))); }
+ }
if let Some(t) = max_ticks { a.push("--max-ticks".into()); a.push(t.to_string()); }
a
}
@@ -180,14 +185,35 @@ pub struct Live {
pub wait_secs: u32,
/// The "summit - git.molberg.cloud/alex/summit" line in a corner. None leaves the engine's saved setting (on by default).
pub watermark: Option,
+ /// The engine's live comparison: `:,,...` ([`parse_compare`]), passed on as `--compare`.
+ /// None: no comparison. Experimental: the engine's side of this is on another branch.
+ pub compare: Option,
+}
+impl Default for Live { fn default() -> Self { Self { wait_secs: 60, watermark: None, compare: None } } }
+
+/// Check a comparison as the engine's `--compare` takes it: `:,,...`, a setting's key (letters,
+/// digits, `_`, `-`) and at least two values. Returns it trimmed, with no spaces around the values.
+pub fn parse_compare(s: &str) -> Result {
+ let how = "a comparison is :,,... (e.g. scaler:off,fsr)";
+ let (dim, values) = s.split_once(':').ok_or(how)?;
+ let dim = dim.trim();
+ if !dim.starts_with(|c: char| c.is_ascii_alphanumeric()) || !dim.chars().all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-') { return Err(how.into()); }
+ let v: Vec<&str> = values.split(',').map(str::trim).collect();
+ if v.len() < 2 || v.iter().any(|x| x.is_empty()) { return Err(format!("{how}: at least two values")); }
+ Ok(format!("{dim}:{}", v.join(",")))
+}
+
+/// Whether this engine has the live comparison (its run.py knows `--compare`): the launcher only offers it then.
+pub fn has_compare(engine: &Path) -> bool {
+ std::fs::read_to_string(engine.join("run.py")).is_ok_and(|t| t.contains("\"--compare\""))
}
-impl Default for Live { fn default() -> Self { Self { wait_secs: 60, watermark: None } } }
/// Extra engine flags for a live window, after `plan()`'s.
pub fn live_args(l: &Live) -> Vec {
let mut a = vec![];
if l.wait_secs > 0 { a.push("--window-wait".to_string()); a.push(l.wait_secs.to_string()); }
if let Some(w) = l.watermark { a.push("--watermark".into()); a.push(if w { "on" } else { "off" }.into()); }
+ if let Some(c) = l.compare.as_deref().and_then(|c| parse_compare(c).ok()) { a.push(format!("--compare={c}")); }
a
}
@@ -404,6 +430,9 @@ mod tests {
#[test] fn ps5_display_plan() {
let a = plan(Path::new("/e"), &Source::Ps5, &p(), true, None, None);
assert_eq!(a[1..].join(" "), "--chiaki --model=4.25 --scaler vsr --display --hz 120 --fullscreen --monitor=HDMI-A-1");
+ // no multiplier in the profile: no --hz, so the engine's saved Frame multiplier counts
+ let a = plan(Path::new("/e"), &Source::Ps5, &Profile::default(), true, None, None);
+ assert_eq!(a[1..].join(" "), "--chiaki --display");
}
#[test] fn file_to_out_plan() {
// upscaler "none" (the editor's Off): the engine shows the picture at its own size
@@ -426,7 +455,7 @@ mod tests {
#[test] fn window_plan_names_the_source() {
let pr = Profile { framegen: "rife".into(), upscaler: "fsr".into(), ..Default::default() };
let a = plan(Path::new("/e"), &Source::Window("Voidrunner".into()), &pr, true, None, None);
- assert_eq!(a[1..].join(" "), "--source window --window=Voidrunner --scaler fsr --display --hz 60");
+ assert_eq!(a[1..].join(" "), "--source window --window=Voidrunner --scaler fsr --display");
}
#[test] fn parse_source_kinds() {
assert_eq!(parse_source("ps5"), Ok(Source::Ps5));
@@ -442,7 +471,7 @@ mod tests {
#[test] fn anti_aliasing_goes_through_when_the_profile_has_one() {
let pr = Profile { upscaler: "fsr".into(), aa: Some("smaa".into()), ..Default::default() };
let a = plan(Path::new("/e"), &Source::Window("Voidrunner".into()), &pr, true, None, None);
- assert_eq!(a[1..].join(" "), "--source window --window=Voidrunner --scaler fsr --aa=smaa --display --hz 60");
+ assert_eq!(a[1..].join(" "), "--source window --window=Voidrunner --scaler fsr --aa=smaa --display"); // (no --hz: the profile sets no multiplier, see ap/launcher-ui)
for aa in [None, Some("dlaa".to_string())] { // unset, or a value the engine has no such choice for: left out
let pr = Profile { aa, ..Default::default() };
assert!(!plan(Path::new("/e"), &Source::Window("x".into()), &pr, true, None, None).iter().any(|s| s.starts_with("--aa")));
@@ -456,12 +485,12 @@ mod tests {
}
#[test] fn run_enhance_window_override_and_watermark_off() {
let pr = Profile { framegen: "none".into(), upscaler: "fsr".into(), ..Default::default() };
- let a = run_enhance_plan(Path::new("/e"), 1, Some("class:steam_app_620"), &pr, &Live { wait_secs: 0, watermark: Some(false) });
- assert_eq!(a[1..].join(" "), "--source window --window=class:steam_app_620 --off --scaler fsr --display --hz 60 --watermark off");
+ let a = run_enhance_plan(Path::new("/e"), 1, Some("class:steam_app_620"), &pr, &Live { wait_secs: 0, watermark: Some(false), compare: None });
+ assert_eq!(a[1..].join(" "), "--source window --window=class:steam_app_620 --off --scaler fsr --display --watermark off");
}
#[test] fn live_args_leave_the_saved_watermark_alone_by_default() {
assert_eq!(live_args(&Live::default()).join(" "), "--window-wait 60");
- assert_eq!(live_args(&Live { wait_secs: 5, watermark: Some(true) }).join(" "), "--window-wait 5 --watermark on");
+ assert_eq!(live_args(&Live { wait_secs: 5, watermark: Some(true), compare: None }).join(" "), "--window-wait 5 --watermark on");
}
#[test] fn extra_args_split_on_spaces() {
assert_eq!(extra_args(Some(" --no-graph --fp32 ")), vec!["--no-graph", "--fp32"]);
@@ -584,7 +613,7 @@ mod tests {
let pr = Profile { framegen: "rife".into(), model: Some("vfg".into()), vfg_quality: Some("high".into()), motion: Some("half".into()), ai_engine: Some("trt".into()),
steady_hud: Some(true), upscaler: "fsr".into(), fsr_sharpness: Some(0.25), vsr_quality: Some(4), window_mode: "windowed".into(), fill: Some("zoom".into()), vsync: Some(false), ..Default::default() };
let a = plan(Path::new("/e"), &Source::Ps5, &pr, true, None, None);
- assert_eq!(a[1..].join(" "), "--chiaki --model=vfg --vfg-quality=high --scale=0.5 --engine=trt --steady-hud --scaler fsr --fsr-sharpness=0.25 --display --hz 60 --no-fullscreen --fill=zoom --no-vsync");
+ assert_eq!(a[1..].join(" "), "--chiaki --model=vfg --vfg-quality=high --scale=0.5 --engine=trt --steady-hud --scaler fsr --fsr-sharpness=0.25 --display --no-fullscreen --fill=zoom --no-vsync");
// VSR quality only with VSR, VFG quality only with VFG
let a = plan(Path::new("/e"), &Source::Ps5, &Profile { upscaler: "rtx-vsr".into(), vsr_quality: Some(3), vfg_quality: Some("low".into()), ..Default::default() }, true, None, None);
assert!(a.contains(&"--vsr-quality=3".to_string()) && !a.iter().any(|x| x.starts_with("--vfg-quality")), "{a:?}");
@@ -596,6 +625,39 @@ mod tests {
assert!(run_enhance_plan(Path::new("/e"), 1, None, &w, &Live { watermark: Some(true), ..Live::default() }).ends_with(&["--watermark".to_string(), "on".to_string()]));
}
#[test] fn dlss_is_not_an_engine_scaler() { assert_eq!(scaler_arg("dlss"), None); }
+ #[test] fn the_engine_table_goes_as_set_flags_after_the_named_ones() {
+ let mut pr = Profile { upscaler: "fsr".into(), ..Default::default() };
+ pr.engine.insert("overlay_style".into(), toml::Value::String("graphs".into()));
+ pr.engine.insert("hz".into(), toml::Value::Integer(120));
+ pr.engine.insert("interp".into(), toml::Value::Boolean(false));
+ pr.engine.insert("fsr_sharpness".into(), toml::Value::Float(0.25));
+ pr.engine.insert("bad key --x".into(), toml::Value::Integer(1));
+ let a = plan(Path::new("/e"), &Source::Ps5, &pr, true, None, None);
+ assert_eq!(a[1..].join(" "), "--chiaki --scaler fsr --display --set=fsr_sharpness=0.25 --set=hz=120 --set=interp=false --set=overlay_style=\"graphs\"");
+ // a value can never become another option: it stays inside its --set=
+ pr.engine.clear();
+ pr.engine.insert("look".into(), toml::Value::String("--out /etc/x".into()));
+ let a = plan(Path::new("/e"), &Source::Ps5, &pr, true, None, None);
+ assert_eq!(a.last().unwrap(), "--set=look=\"--out /etc/x\"");
+ }
+ #[test] fn compare_is_passed_through_only_when_asked_and_well_formed() {
+ assert_eq!(live_args(&Live::default()).join(" "), "--window-wait 60"); // None: nothing
+ let l = Live { compare: Some(" scaler : off, fsr ,vsr ".into()), ..Live::default() };
+ assert_eq!(live_args(&l).join(" "), "--window-wait 60 --compare=scaler:off,fsr,vsr");
+ let a = run_enhance_plan(Path::new("/e"), 7, None, &Profile::default(), &Live { compare: Some("hz:60,120".into()), ..Live::default() });
+ assert_eq!(a[1..].join(" "), "--source window --window=pid:7 --display --window-wait 60 --compare=hz:60,120");
+ assert_eq!(parse_compare("fsr_sharpness:0,0.5,2").as_deref(), Ok("fsr_sharpness:0,0.5,2"));
+ for bad in ["scaler", "scaler:fsr", ":a,b", "scaler:a,,b", "sc aler:a,b", "--x:a,b", ""] { assert!(parse_compare(bad).is_err(), "{bad}"); }
+ // one that is not well formed is never passed on
+ assert_eq!(live_args(&Live { compare: Some("nonsense".into()), ..Live::default() }).join(" "), "--window-wait 60");
+ let d = std::env::temp_dir().join(format!("summit-has-compare-{}", std::process::id()));
+ std::fs::create_dir_all(&d).unwrap();
+ std::fs::write(d.join("run.py"), "ap.add_argument(\"--hz\")\n").unwrap();
+ assert!(!has_compare(&d));
+ std::fs::write(d.join("run.py"), "ap.add_argument(\"--compare\", metavar=\"SPEC\")\n").unwrap();
+ assert!(has_compare(&d));
+ let _ = std::fs::remove_dir_all(&d);
+ }
#[test] fn framegen_none_turns_interp_off() {
let pr = Profile { framegen: "none".into(), ..Default::default() };
assert!(plan(Path::new("/e"), &Source::Ps5, &pr, true, None, None).contains(&"--off".to_string()));
@@ -631,7 +693,7 @@ mod tests {
}
#[test]
fn game_frame_rate_and_output_resolution_reach_the_engine() {
- let p = Profile { framegen: "rife".into(), game_fps: Some("60".into()), output_res: Some("2560 x 1440".into()), ..Default::default() };
+ let p = Profile { framegen: "rife".into(), framegen_multiplier: 2, game_fps: Some("60".into()), output_res: Some("2560 x 1440".into()), ..Default::default() };
let a = plan(Path::new("/e"), &Source::Window("pid:1".into()), &p, true, None, None).join(" ");
assert!(a.contains("--hz 60 --game-fps=60 --output-res=2560x1440"), "{a}");
let p = Profile { game_fps: Some("120".into()), output_res: Some("huge".into()), ..Default::default() };
diff --git a/crates/summit-core/src/launch.rs b/crates/summit-core/src/launch.rs
index fac9adb..647724a 100644
--- a/crates/summit-core/src/launch.rs
+++ b/crates/summit-core/src/launch.rs
@@ -179,6 +179,15 @@ pub fn with_focus(mut argv: Vec) -> Vec {
argv
}
+/// `summit run ... --enhance` with the engine's live comparison on (`:,,...`). Only a plan that goes
+/// through `summit run` with Enhance can carry it; any other is returned as it is.
+pub fn with_compare(mut argv: Vec, compare: &str) -> Vec {
+ let head = |a: &str| argv.iter().take_while(|x| x.as_str() != "--").any(|x| x == a);
+ let ours = argv.len() >= 3 && argv[1] == "run" && head("--enhance") && !argv.iter().take_while(|x| x.as_str() != "--").any(|x| x.starts_with("--compare"));
+ if ours { argv.insert(3, format!("--compare={compare}")); }
+ argv
+}
+
/// True when Play would install rather than start (owned Steam game that is not on disk).
pub fn is_install(e: &Entry) -> bool { e.source == Source::Steam && !e.installed && e.steam_app_id.is_some() }
@@ -204,6 +213,14 @@ mod tests {
// a game whose own arguments say --focus still gets ours
let own = vec!["/s".to_string(), "run".into(), "custom:x".into(), "--".into(), "/g".into(), "--focus".into()];
assert_eq!(with_focus(own)[3], "--focus");
+ // the comparison: only on a plan that runs the engine, once, and before the game's command
+ let enh: Vec = ["/b/summit", "run", "steam:1", "--enhance", "--", "steam", "--compare=x"].iter().map(|s| s.to_string()).collect();
+ let c = with_compare(enh.clone(), "scaler:off,fsr");
+ assert_eq!(c[3], "--compare=scaler:off,fsr");
+ assert_eq!(with_compare(c.clone(), "hz:60,120"), c);
+ let no_enh: Vec = ["/b/summit", "run", "steam:1", "--", "steam"].iter().map(|s| s.to_string()).collect();
+ assert_eq!(with_compare(no_enh.clone(), "scaler:off,fsr"), no_enh);
+ assert_eq!(with_compare(plain.clone(), "scaler:off,fsr"), plain);
}
#[test]
fn steam_installed_goes_through_summit_run() {
diff --git a/crates/summit-core/src/lib.rs b/crates/summit-core/src/lib.rs
index 9c22670..3096129 100644
--- a/crates/summit-core/src/lib.rs
+++ b/crates/summit-core/src/lib.rs
@@ -10,9 +10,12 @@ pub mod launch;
pub mod lutris;
pub mod model;
pub mod names;
+pub mod presets;
pub mod profile;
+pub mod registry;
pub mod running;
pub mod scan;
+pub mod sessions;
pub mod sgdb;
pub mod shortcuts;
pub mod signals;
diff --git a/crates/summit-core/src/presets.rs b/crates/summit-core/src/presets.rs
new file mode 100644
index 0000000..dd2d7d0
--- /dev/null
+++ b/crates/summit-core/src/presets.rs
@@ -0,0 +1,100 @@
+//! Engine presets: a few named sets of engine settings. This table is the only place they are defined; the
+//! launcher's Settings page, a game's profile and `summit preset` all read it.
+//!
+//! A preset only sets the keys listed here and leaves everything else alone. Every preset sets the same keys, so
+//! exactly one of them (or none: "Custom") matches at any time. The descriptions say what changes; the numbers in
+//! them are the engine's own notes (framegen/settings.py `impact`, measured on the engine author's PC), not
+//! something measured for these presets.
+use serde_json::Value;
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub enum V { B(bool), I(i64), S(&'static str) }
+impl V { pub fn json(self) -> Value { match self { V::B(b) => Value::Bool(b), V::I(i) => Value::from(i), V::S(s) => Value::String(s.into()) } } }
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub struct Preset {
+ pub id: &'static str,
+ pub name: &'static str,
+ /// One line: who it is for.
+ pub summary: &'static str,
+ /// What it changes and what that costs, in plain words.
+ pub detail: &'static str,
+ /// Registry key -> value. The same keys in every preset, in the same order.
+ pub set: &'static [(&'static str, V)],
+}
+
+impl Preset {
+ pub fn values(&self) -> Vec<(&'static str, Value)> { self.set.iter().map(|(k, v)| (*k, v.json())).collect() }
+}
+
+pub const PRESETS: &[Preset] = &[
+ Preset {
+ id: "quality", name: "Quality",
+ summary: "The best picture the engine makes, for a card with headroom.",
+ detail: "Frame generation on at 2x with motion detail Full (sharpest on fast detail, the slowest), FSR 1 upscaling straight to the screen's size, VSync on (no tear lines; up to one refresh more delay).",
+ set: &[("interp", V::B(true)), ("hz", V::I(60)), ("motion", V::S("full")), ("scaler", V::S("fsr")), ("output_res", V::S("screen")), ("vsync", V::B(true))],
+ },
+ Preset {
+ id: "balanced", name: "Balanced",
+ summary: "The engine's own defaults.",
+ detail: "Frame generation on at 2x with motion detail Auto (Full, dropping to Half only at high frame rates or big captures), FSR 1 upscaling to the screen's size, VSync off (lowest delay; fast turns can tear without G-Sync or FreeSync).",
+ set: &[("interp", V::B(true)), ("hz", V::I(60)), ("motion", V::S("auto")), ("scaler", V::S("fsr")), ("output_res", V::S("screen")), ("vsync", V::B(false))],
+ },
+ Preset {
+ id: "performance", name: "Performance",
+ summary: "The lightest for the graphics card, for when frames get left out.",
+ detail: "Frame generation on at 2x with motion detail Half (about 40% less time per AI frame, a little softer on small fast details), upscaling to 1080p and stretching that to the screen (softer on a 1440p or 4K screen), VSync off.",
+ set: &[("interp", V::B(true)), ("hz", V::I(60)), ("motion", V::S("half")), ("scaler", V::S("fsr")), ("output_res", V::S("1920x1080")), ("vsync", V::B(false))],
+ },
+ Preset {
+ id: "lowest-delay", name: "Lowest delay",
+ summary: "Upscaling only: nothing that waits for the next frame.",
+ detail: "Frame generation off, so the game's frames are shown as they come (generation is what adds about 20 to 40 ms), FSR 1 upscaling to the screen's size, VSync off. Motion is only as smooth as the game itself.",
+ set: &[("interp", V::B(false)), ("hz", V::I(60)), ("motion", V::S("auto")), ("scaler", V::S("fsr")), ("output_res", V::S("screen")), ("vsync", V::B(false))],
+ },
+];
+
+/// The keys presets set (the same for each).
+pub fn keys() -> Vec<&'static str> { PRESETS[0].set.iter().map(|(k, _)| *k).collect() }
+
+pub fn by_id(id: &str) -> Option<&'static Preset> { PRESETS.iter().find(|p| p.id.eq_ignore_ascii_case(id) || p.name.eq_ignore_ascii_case(id)) }
+
+/// The preset the current values are, or None ("Custom"). `value_of` gives the value in use for a key.
+pub fn current(value_of: &dyn Fn(&str) -> Value) -> Option<&'static Preset> {
+ PRESETS.iter().find(|p| p.set.iter().all(|(k, v)| crate::registry::same(&value_of(k), &v.json())))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::collections::BTreeMap;
+
+ #[test]
+ fn every_preset_sets_the_same_keys_and_no_two_are_alike() {
+ let k = keys();
+ for p in PRESETS {
+ assert_eq!(p.set.iter().map(|(k, _)| *k).collect::>(), k, "{}", p.id);
+ assert!(!p.summary.is_empty() && !p.detail.is_empty());
+ }
+ for (i, a) in PRESETS.iter().enumerate() { for b in &PRESETS[i + 1..] { assert_ne!(a.set, b.set, "{} and {}", a.id, b.id); } }
+ assert_eq!(by_id("Lowest delay").map(|p| p.id), Some("lowest-delay"));
+ assert_eq!(by_id("PERFORMANCE").map(|p| p.id), Some("performance"));
+ assert!(by_id("ultra").is_none());
+ }
+
+ #[test]
+ fn the_current_preset_is_custom_once_a_value_differs() {
+ let mut v: BTreeMap<&str, Value> = by_id("quality").unwrap().values().into_iter().collect();
+ let look = |v: &BTreeMap<&str, Value>| current(&|k| v.get(k).cloned().unwrap_or(Value::Null)).map(|p| p.id);
+ assert_eq!(look(&v), Some("quality"));
+ v.insert("vsync", Value::Bool(false));
+ assert_eq!(look(&v), None);
+ v.insert("motion", Value::String("auto".into()));
+ assert_eq!(look(&v), Some("balanced"));
+ v.insert("hz", Value::from(120));
+ assert_eq!(look(&v), None);
+ // the settings file may hold 60.0 for 60
+ v.insert("hz", serde_json::json!(60.0));
+ assert_eq!(look(&v), Some("balanced"));
+ }
+}
diff --git a/crates/summit-core/src/profile.rs b/crates/summit-core/src/profile.rs
index 3f2a8fb..2547cf7 100644
--- a/crates/summit-core/src/profile.rs
+++ b/crates/summit-core/src/profile.rs
@@ -99,6 +99,9 @@ pub struct Profile {
/// Which window Enhance takes, in the engine's `--window` form (`class:NAME`, part of the title, `dir:FOLDER`,
/// alternatives split by "|"). None: Summit works it out (launch::window_query), and asks when it can't.
pub window: Option,
+ /// Engine settings by the engine's own key (engine/framegen/settings.py), for anything the fields above do not
+ /// name: passed as `--set KEY=VALUE`, and winning over them. Empty: the engine's saved settings.
+ pub engine: BTreeMap,
}
impl Profile {
@@ -145,6 +148,8 @@ pub struct Layer {
#[serde(skip_serializing_if = "Option::is_none")] pub game_fps: Option,
#[serde(skip_serializing_if = "Option::is_none")] pub output_res: Option,
#[serde(skip_serializing_if = "Option::is_none")] pub aa: Option,
+ /// `[engine]`: engine settings by the engine's key (the launcher's settings rows write here). See [`Profile::engine`].
+ #[serde(skip_serializing_if = "Option::is_none")] pub engine: Option>,
/// Files from before layers: `fullscreen = true` is `window_mode = "borderless"` (the engine's picture over the
/// whole monitor, which is what it did). Read, never written.
#[serde(skip_serializing)] pub fullscreen: Option,
@@ -155,8 +160,11 @@ pub const KEYS: &[&str] = &[
"monitor", "width", "height", "refresh_hz", "window_mode", "focus", "enhance", "upscaler", "fsr_sharpness",
"vsr_quality", "framegen", "framegen_multiplier", "target_hz", "model", "vfg_quality", "motion", "ai_engine",
"steady_hud", "fill", "vsync", "watermark", "launch_args", "env", "window", "game_fps", "output_res",
- "aa",
+ "aa", "engine",
];
+/// The engine's setting keys that a named profile setting also decides (crate::registry::named_for).
+const NAMED_ENGINE_KEYS: &[&str] = &["interp", "hz", "game_fps", "output_res", "model", "vfg_quality", "motion", "engine", "steady_hud",
+ "scaler", "fsr_sharpness", "vsr_quality", "fill", "vsync", "watermark", "aa"];
/// The engine's anti-aliasing choices (`--aa`, framegen/aa.py).
pub const AA: &[&str] = &["off", "fxaa", "smaa", "cas"];
@@ -215,6 +223,10 @@ impl Layer {
if let Some(v) = &self.game_fps { p.game_fps = text(v); }
if let Some(v) = &self.output_res { p.output_res = text(v).filter(|r| r != "screen"); }
if let Some(v) = &self.aa { p.aa = text(v); }
+ // A later layer wins whichever way it says it: a named setting here replaces the same engine key from the
+ // layer below, and this layer's own engine table goes on top.
+ for k in NAMED_ENGINE_KEYS { if crate::registry::named_for(k).iter().any(|n| self.has(n)) { p.engine.remove(*k); } }
+ if let Some(v) = &self.engine { for (k, val) in v { p.engine.insert(k.clone(), val.clone()); } }
}
/// Whether this layer sets `key` (one of [`KEYS`]).
@@ -231,6 +243,7 @@ impl Layer {
"env" => self.env.is_some(), "window" => self.window.is_some(),
"game_fps" => self.game_fps.is_some(), "output_res" => self.output_res.is_some(),
"aa" => self.aa.is_some(),
+ "engine" => self.engine.as_ref().is_some_and(|m| !m.is_empty()),
_ => false,
}
}
@@ -250,6 +263,7 @@ impl Layer {
"launch_args" => self.launch_args = None, "env" => self.env = None, "window" => self.window = None,
"game_fps" => self.game_fps = None, "output_res" => self.output_res = None,
"aa" => self.aa = None,
+ "engine" => self.engine = None,
_ => return false,
}
true
@@ -455,4 +469,25 @@ mod tests {
let old = Layer { framegen_multiplier: Some(2), target_hz: Some(120), ..Default::default() };
assert_eq!(resolve(&[&old]).multiplier(), Some(4));
}
+ #[test]
+ fn the_engine_table_layers_like_everything_else() {
+ let t = |s: &str| toml::Value::String(s.into());
+ let d = parse_layer("version = 2\nupscaler = \"fsr\"\n\n[engine]\noverlay_style = \"graphs\"\nscaler = \"vsr\"\nhz = 90\n").unwrap();
+ assert_eq!(d.engine.as_ref().unwrap().get("hz"), Some(&toml::Value::Integer(90)));
+ let g = Layer { engine: Some([("overlay_style".to_string(), t("minimal")), ("vsync".to_string(), toml::Value::Boolean(true))].into()), ..Default::default() };
+ let p = resolve(&[&d, &g]);
+ assert_eq!(p.engine.get("overlay_style"), Some(&t("minimal"))); // the game's own
+ assert_eq!(p.engine.get("scaler"), Some(&t("vsr"))); // the defaults'
+ assert_eq!(p.engine.get("vsync"), Some(&toml::Value::Boolean(true)));
+ // a game that still names the upscaler the older way wins over the defaults' engine table
+ let old = Layer { upscaler: Some("bilinear".into()), ..Default::default() };
+ let p = resolve(&[&d, &old]);
+ assert!(!p.engine.contains_key("scaler") && p.upscaler == "bilinear");
+ assert!(g.has("engine") && !Layer::default().has("engine"));
+ let mut g2 = g.clone();
+ assert!(g2.unset("engine") && g2.is_empty());
+ // written and read back
+ let text = toml::to_string_pretty(&Layer { version: Some(LAYER_VERSION), monitor: Some("DP-1".into()), ..g.clone() }).unwrap();
+ assert_eq!(parse_layer(&text).unwrap().engine, g.engine, "{text}");
+ }
}
diff --git a/crates/summit-core/src/registry.rs b/crates/summit-core/src/registry.rs
new file mode 100644
index 0000000..f7a8ba9
--- /dev/null
+++ b/crates/summit-core/src/registry.rs
@@ -0,0 +1,478 @@
+//! The engine's settings registry, as the launcher reads it: `python -m framegen.settings` prints every setting
+//! (engine/framegen/settings.py SPECS) as JSON, so the launcher keeps no copy of the labels, choices or help.
+//! Parsed leniently: a field that is missing or of another type than expected is left empty, a setting without a key
+//! is skipped, and a setting this version has never heard of is shown like any other.
+//!
+//! Also here: the saved values (the engine's settings.json, read and written key by key so anything else in the
+//! file is kept) and how a launch profile's settings map onto the registry's keys ([`forced`]).
+use crate::profile::{Layer, Profile};
+use serde_json::Value;
+use std::collections::BTreeMap;
+use std::path::{Path, PathBuf};
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct Choice { pub value: Value, pub name: String, pub hint: String }
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct Spec {
+ pub key: String,
+ pub label: String,
+ /// Section ("" in the JSON becomes "Other").
+ pub group: String,
+ /// Heading inside the section ("" for none).
+ pub sub: String,
+ pub help: String,
+ pub default: Value,
+ /// Applies at once; false: at the next start.
+ pub live: bool,
+ /// Written to the settings file; false: one session only, so the launcher cannot set it.
+ pub saved: bool,
+ pub later: String,
+ pub quick: bool,
+ /// "picture" and "speed" lines (any other name the engine adds is kept and shown too).
+ pub impact: Vec<(String, String)>,
+ pub experimental: bool,
+ /// Only used with these sources (empty: all).
+ pub sources: Vec,
+ /// Source kind -> why it is not used there ("" for any other source).
+ pub elsewhere: BTreeMap,
+ /// Only used while setting `.0` has one of the values `.1`.
+ pub applies: Option<(String, Vec)>,
+ pub choices: Vec,
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct Registry {
+ /// The engine's settings file.
+ pub path: PathBuf,
+ /// The PC the numbers in the impact lines were measured on.
+ pub impact_pc: String,
+ pub specs: Vec,
+}
+
+/// Two JSON values that mean the same choice: numbers by value (1 and 1.0), everything else exactly.
+pub fn same(a: &Value, b: &Value) -> bool {
+ match (a.as_f64(), b.as_f64()) { (Some(x), Some(y)) => (x - y).abs() < 1e-9, _ => a == b }
+}
+
+/// A value as text, for a choice the registry gives no name for.
+pub fn plain(v: &Value) -> String {
+ match v {
+ Value::String(s) => s.clone(),
+ Value::Bool(true) => "On".into(), Value::Bool(false) => "Off".into(),
+ Value::Null => "Not set".into(),
+ other => other.to_string(),
+ }
+}
+
+fn text(v: Option<&Value>) -> String { v.and_then(Value::as_str).unwrap_or_default().to_string() }
+fn flag(v: Option<&Value>, default: bool) -> bool { v.and_then(Value::as_bool).unwrap_or(default) }
+
+impl Spec {
+ fn parse(v: &Value) -> Option {
+ let o = v.as_object()?;
+ let key = text(o.get("key"));
+ if key.is_empty() { return None; }
+ let label = match text(o.get("label")) { l if l.is_empty() => key.clone(), l => l };
+ let group = match text(o.get("group")) { g if g.trim().is_empty() => "Other".to_string(), g => g };
+ // choices: [{value, name, hint}], or bare values
+ let choices: Vec = o.get("choices").and_then(Value::as_array).map(|a| a.iter().map(|c| match c.as_object() {
+ Some(c) if c.contains_key("value") => {
+ let value = c.get("value").cloned().unwrap_or(Value::Null);
+ let name = match text(c.get("name")) { n if n.is_empty() => plain(&value), n => n };
+ Choice { name, hint: text(c.get("hint")), value }
+ }
+ _ => Choice { name: plain(c), hint: String::new(), value: c.clone() },
+ }).collect()).unwrap_or_default();
+ let mut impact: Vec<(String, String)> = o.get("impact").and_then(Value::as_object)
+ .map(|m| m.iter().filter_map(|(k, v)| Some((k.clone(), v.as_str()?.to_string()))).filter(|(_, v)| !v.is_empty()).collect()).unwrap_or_default();
+ impact.sort_by_key(|(k, _)| match k.as_str() { "picture" => 0, "speed" => 1, _ => 2 });
+ let applies = o.get("applies").and_then(Value::as_object).and_then(|a| {
+ let k = text(a.get("key"));
+ let vals = a.get("values").and_then(Value::as_array).cloned().unwrap_or_default();
+ (!k.is_empty()).then_some((k, vals))
+ });
+ Some(Spec {
+ key, label, group, sub: text(o.get("sub")), help: text(o.get("help")), default: o.get("default").cloned().unwrap_or(Value::Null),
+ live: flag(o.get("live"), true), saved: flag(o.get("saved"), true), later: text(o.get("later")), quick: flag(o.get("quick"), false),
+ impact, experimental: flag(o.get("experimental"), false),
+ sources: o.get("sources").and_then(Value::as_array).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()).unwrap_or_default(),
+ elsewhere: o.get("elsewhere").and_then(Value::as_object).map(|m| m.iter().filter_map(|(k, v)| Some((k.clone(), v.as_str()?.to_string()))).collect()).unwrap_or_default(),
+ applies, choices,
+ })
+ }
+
+ /// The index of `v` among the choices.
+ pub fn position(&self, v: &Value) -> Option { self.choices.iter().position(|c| same(&c.value, v)) }
+
+ /// What a value is called: the choice's name, else what the engine's own naming gives for a custom value (a
+ /// frame multiplier, an output size), else the value as text.
+ pub fn name_of(&self, v: &Value) -> String {
+ if let Some(i) = self.position(v) { return self.choices[i].name.clone(); }
+ match (self.key.as_str(), v) {
+ ("hz", Value::Number(n)) if n.as_u64().is_some_and(|hz| hz % 30 == 0 && hz > 0) => format!("{}x", n.as_u64().unwrap_or(0) / 30),
+ ("output_res", Value::String(s)) => crate::profile::parse_res(s).map(|(w, h)| format!("{w} x {h}")).unwrap_or_else(|| s.clone()),
+ _ => plain(v),
+ }
+ }
+
+ /// Why the setting is not used with these values (the setting it depends on has another value), or None.
+ pub fn unused_now(&self, reg: &Registry, value_of: &dyn Fn(&str) -> Value) -> Option {
+ let (key, values) = self.applies.as_ref()?;
+ let cur = value_of(key);
+ if values.iter().any(|v| same(v, &cur)) { return None; }
+ let (label, names) = match reg.get(key) {
+ Some(dep) => (dep.label.clone(), values.iter().map(|v| dep.name_of(v)).collect::>()),
+ None => (key.clone(), values.iter().map(plain).collect()),
+ };
+ let now = reg.get(key).map(|d| d.name_of(&cur)).unwrap_or_else(|| plain(&cur));
+ let want = match names.as_slice() {
+ [] => "set".to_string(),
+ [one] => one.clone(),
+ many if many.len() > 3 => format!("{}, {} or another of {}", many[0], many[1], many.len()),
+ many => format!("{} or {}", many[..many.len() - 1].join(", "), many[many.len() - 1]),
+ };
+ Some(format!("Only used while {label} is {want} (now {now})."))
+ }
+
+ /// Why the setting is not used with frames from `source` (the engine's kinds: "window", "chiaki", "capture",
+ /// "tap", "file"), or None if it is.
+ pub fn unused_with(&self, source: &str) -> Option {
+ if self.sources.is_empty() || self.sources.iter().any(|s| s == source) { return None; }
+ Some(self.elsewhere.get(source).or_else(|| self.elsewhere.get("")).cloned().filter(|s| !s.is_empty())
+ .unwrap_or_else(|| format!("Only used with these sources: {}.", self.sources.join(", "))))
+ }
+
+ /// The note for a setting that only some sources use, where no source is known (the Settings page).
+ pub fn source_note(&self) -> Option {
+ if self.sources.is_empty() { return None; }
+ Some(self.elsewhere.get("").cloned().filter(|s| !s.is_empty()).unwrap_or_else(|| format!("Only used with these sources: {}.", self.sources.join(", "))))
+ }
+}
+
+impl Registry {
+ /// Parse what `python -m framegen.settings` printed.
+ pub fn parse(json: &str) -> Result {
+ let v: Value = serde_json::from_str(json.trim()).map_err(|e| format!("not JSON: {e}"))?;
+ let o = v.as_object().ok_or("not a JSON object")?;
+ let mut specs: Vec = o.get("specs").and_then(Value::as_array).ok_or("no \"specs\" list")?.iter().filter_map(Spec::parse).collect();
+ let mut seen = std::collections::HashSet::new();
+ specs.retain(|s| seen.insert(s.key.clone()));
+ Ok(Registry { path: PathBuf::from(text(o.get("path"))), impact_pc: text(o.get("impact_pc")), specs })
+ }
+
+ /// Ask the engine (a few hundredths of a second: it loads no GPU library).
+ pub fn load(engine: &Path) -> Result {
+ let out = std::process::Command::new(crate::engine::python(engine)).current_dir(engine).args(["-m", "framegen.settings"])
+ .stdin(std::process::Stdio::null()).output().map_err(|e| format!("could not run the engine's Python: {e}"))?;
+ if !out.status.success() {
+ let err = String::from_utf8_lossy(&out.stderr);
+ return Err(format!("the engine could not list its settings: {}", err.lines().last().unwrap_or("no output").trim()));
+ }
+ let mut reg = Self::parse(&String::from_utf8_lossy(&out.stdout))?;
+ if reg.path.as_os_str().is_empty() { return Err("the engine did not say where its settings file is".into()); }
+ if let Some(p) = std::env::var_os("SUMMIT_ENGINE_SETTINGS").filter(|p| !p.is_empty()) { reg.path = p.into(); }
+ Ok(reg)
+ }
+
+ pub fn get(&self, key: &str) -> Option<&Spec> { self.specs.iter().find(|s| s.key == key) }
+
+ /// The sections in the order the registry first names them, each with its settings in registry order.
+ pub fn groups(&self) -> Vec<(String, Vec<&Spec>)> {
+ let mut out: Vec<(String, Vec<&Spec>)> = vec![];
+ for s in &self.specs {
+ match out.iter_mut().find(|(g, _)| *g == s.group) { Some((_, v)) => v.push(s), None => out.push((s.group.clone(), vec![s])) }
+ }
+ out
+ }
+}
+
+/// The values saved in the engine's settings file. A missing or damaged file is no values (the engine then uses its
+/// defaults, and so does the launcher).
+pub fn read_values(path: &Path) -> BTreeMap {
+ std::fs::read_to_string(path).ok().and_then(|t| serde_json::from_str::(&t).ok())
+ .and_then(|v| v.as_object().map(|o| o.iter().map(|(k, v)| (k.clone(), v.clone())).collect())).unwrap_or_default()
+}
+
+/// Set (or with None remove, which is the engine's default) values in the settings file, keeping everything else
+/// in it. Written whole and renamed into place, as the engine's own save is one write.
+pub fn write_values(path: &Path, changes: &[(&str, Option)]) -> anyhow::Result<()> {
+ let mut all = read_values(path);
+ for (k, v) in changes {
+ match v { Some(v) => { all.insert(k.to_string(), v.clone()); } None => { all.remove(*k); } }
+ }
+ let obj: serde_json::Map = all.into_iter().collect();
+ crate::state::write_atomic(path, serde_json::to_string_pretty(&Value::Object(obj))?.as_bytes())?;
+ Ok(())
+}
+
+pub fn to_toml(v: &Value) -> Option {
+ Some(match v {
+ Value::Bool(b) => toml::Value::Boolean(*b),
+ Value::Number(n) => match n.as_i64() { Some(i) => toml::Value::Integer(i), None => toml::Value::Float(n.as_f64()?) },
+ Value::String(s) => toml::Value::String(s.clone()),
+ _ => return None,
+ })
+}
+pub fn from_toml(v: &toml::Value) -> Value {
+ match v {
+ toml::Value::Boolean(b) => Value::Bool(*b),
+ toml::Value::Integer(i) => Value::from(*i),
+ toml::Value::Float(f) => serde_json::Number::from_f64(*f).map(Value::Number).unwrap_or(Value::Null),
+ toml::Value::String(s) => Value::String(s.clone()),
+ other => Value::String(other.to_string()),
+ }
+}
+
+/// What a resolved profile makes the engine use, by registry key: exactly what [`crate::engine::plan`] passes on
+/// the command line (the older named settings first, then the profile's `engine` table, which wins). A key that is
+/// not here is left to the engine's saved setting.
+pub fn forced(p: &Profile) -> BTreeMap {
+ let mut m: BTreeMap = BTreeMap::new();
+ let s = |v: &str| Value::String(v.to_string());
+ if p.framegen == "none" { m.insert("interp".into(), Value::Bool(false)); }
+ if let Some(x) = p.multiplier() { m.insert("hz".into(), Value::from(30 * u32::from(x))); }
+ if let Some(g) = p.game_fps.as_deref().filter(|g| crate::profile::GAME_FPS.contains(g)) { m.insert("game_fps".into(), s(g)); }
+ if let Some((w, h)) = p.output_res.as_deref().and_then(crate::profile::parse_res) { m.insert("output_res".into(), s(&format!("{w}x{h}"))); }
+ if let Some(x) = &p.model { m.insert("model".into(), s(x)); }
+ if let (Some("vfg"), Some(q)) = (p.model.as_deref(), &p.vfg_quality) { m.insert("vfg_quality".into(), s(q)); }
+ if let Some(x @ ("full" | "half")) = p.motion.as_deref() { m.insert("motion".into(), s(x)); }
+ if let Some(x) = &p.ai_engine { m.insert("engine".into(), s(x)); }
+ if let Some(x) = p.steady_hud { m.insert("steady_hud".into(), Value::Bool(x)); }
+ if let Some(sc) = crate::engine::scaler_arg(&p.upscaler) {
+ m.insert("scaler".into(), s(sc));
+ if let (Some(v), "fsr") = (p.fsr_sharpness, sc) { m.insert("fsr_sharpness".into(), Value::from(v as f64)); }
+ if let (Some(q), "vsr") = (p.vsr_quality, sc) { m.insert("vsr_quality".into(), Value::from(q)); }
+ }
+ match p.window_mode.as_str() {
+ "windowed" => { m.insert("fullscreen".into(), Value::Bool(false)); }
+ _ if p.fullscreen() => { m.insert("fullscreen".into(), Value::Bool(true)); }
+ _ => {}
+ }
+ if let Some(x) = &p.fill { m.insert("fill".into(), s(x)); }
+ if let Some(x) = p.vsync { m.insert("vsync".into(), Value::Bool(x)); }
+ if let Some(x) = p.watermark { m.insert("watermark".into(), Value::Bool(x)); }
+ if let Some(x) = p.aa.as_deref().filter(|v| crate::profile::AA.contains(v)) { m.insert("aa".into(), s(x)); }
+ for (k, v) in &p.engine { m.insert(k.clone(), from_toml(v)); }
+ m
+}
+
+/// The older named profile settings that say the same as registry key `key` (cleared when the key is set through
+/// the `engine` table, so two places never disagree). "fullscreen" has none: that is the window mode, a launch setting.
+pub fn named_for(key: &str) -> &'static [&'static str] {
+ match key {
+ "interp" => &["framegen"], "hz" => &["framegen_multiplier", "target_hz"], "game_fps" => &["game_fps"],
+ "output_res" => &["output_res"], "model" => &["model"], "vfg_quality" => &["vfg_quality"], "motion" => &["motion"],
+ "engine" => &["ai_engine"], "steady_hud" => &["steady_hud"], "scaler" => &["upscaler"], "fsr_sharpness" => &["fsr_sharpness"],
+ "vsr_quality" => &["vsr_quality"], "fill" => &["fill"], "vsync" => &["vsync"], "watermark" => &["watermark"],
+ "aa" => &["aa"],
+ _ => &[],
+ }
+}
+
+impl Layer {
+ /// Set registry key `key` in this layer (None: stop setting it, so the layer below or the engine's saved
+ /// setting decides). The older named setting for the same thing is dropped.
+ pub fn set_engine(&mut self, key: &str, value: Option<&Value>) {
+ for k in named_for(key) { self.unset(k); }
+ let mut map = self.engine.take().unwrap_or_default();
+ match value.and_then(to_toml) { Some(v) => { map.insert(key.to_string(), v); } None => { map.remove(key); } }
+ self.engine = (!map.is_empty()).then_some(map);
+ }
+
+ /// Whether this layer by itself decides registry key `key` (through the `engine` table or an older named setting).
+ pub fn sets_engine(&self, key: &str) -> bool {
+ self.engine.as_ref().is_some_and(|m| m.contains_key(key)) || forced(&crate::profile::resolve(&[self])).contains_key(key)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ const SAMPLE: &str = r#"{"path": "/tmp/x/settings.json", "impact_pc": "a PC", "specs": [
+ {"key": "interp", "label": "Frame generation", "group": "Frame generation", "sub": "Basics", "help": "h", "default": true, "live": true, "saved": true,
+ "later": "", "quick": true, "impact": {"speed": "Adds delay.", "picture": "Smoother."}, "experimental": false, "sources": null, "elsewhere": null, "applies": null,
+ "choices": [{"value": true, "name": "On", "hint": ""}, {"value": false, "name": "Off", "hint": "No new frames."}]},
+ {"key": "hz", "label": "Frame multiplier", "group": "Frame generation", "sub": "Basics", "default": 60, "quick": true,
+ "applies": {"key": "interp", "values": [true]}, "choices": [{"value": 60, "name": "2x", "hint": ""}, {"value": 90, "name": "3x", "hint": ""}]},
+ {"key": "capture_size", "label": "Capture card resolution", "group": "Sources", "default": "1080p", "experimental": true, "live": false,
+ "sources": ["capture"], "elsewhere": {"chiaki": "Remote Play is 1080p.", "": "Only used with a capture card."},
+ "choices": [{"value": "1080p", "name": "1080p", "hint": ""}, {"value": "2160p", "name": "4K", "hint": ""}]},
+ {"key": "fsr_sharpness", "label": "FSR sharpening", "group": "Upscaling", "default": 0.5,
+ "choices": [{"value": 0.0, "name": "Max"}, {"value": 0.5, "name": "Medium"}, {"value": 1.0, "name": "Low"}]}
+ ]}"#;
+
+ #[test]
+ fn parses_what_the_engine_prints() {
+ let r = Registry::parse(SAMPLE).unwrap();
+ assert_eq!(r.path, PathBuf::from("/tmp/x/settings.json"));
+ assert_eq!(r.specs.len(), 4);
+ let i = r.get("interp").unwrap();
+ assert_eq!((i.label.as_str(), i.group.as_str(), i.sub.as_str(), i.quick, i.saved, i.live), ("Frame generation", "Frame generation", "Basics", true, true, true));
+ assert_eq!(i.impact, vec![("picture".to_string(), "Smoother.".to_string()), ("speed".to_string(), "Adds delay.".to_string())]);
+ assert_eq!(i.choices[1], Choice { value: json!(false), name: "Off".into(), hint: "No new frames.".into() });
+ assert_eq!(r.get("hz").unwrap().applies, Some(("interp".to_string(), vec![json!(true)])));
+ let c = r.get("capture_size").unwrap();
+ assert!(c.experimental && !c.live && c.sources == vec!["capture"]);
+ assert_eq!(r.groups().iter().map(|(g, v)| (g.as_str(), v.len())).collect::>(), vec![("Frame generation", 2), ("Sources", 1), ("Upscaling", 1)]);
+ }
+
+ #[test]
+ fn a_registry_from_a_newer_engine_still_reads() {
+ // an unknown section, fields this version has never seen, a new kind of setting without choices, choices as
+ // bare values, wrong types, a spec without a key, the same key twice
+ let r = Registry::parse(r#"{"path": "/s.json", "new_top_level": 1, "specs": [
+ {"key": "aa", "label": "Anti-aliasing", "group": "Anti-aliasing", "sub": 7, "default": "off", "kind": "enum", "min": 1,
+ "impact": {"picture": "Smoother edges.", "memory": "More VRAM.", "bad": 3}, "choices": ["off", "fxaa", 2, true]},
+ {"key": "strength", "label": "Strength", "group": "", "default": 0.4, "type": "range", "range": [0, 1], "choices": null},
+ {"label": "no key"}, 17, {"key": "aa", "label": "again"},
+ {"key": "odd", "impact": "fast", "applies": {"key": "", "values": 3}, "sources": "all", "quick": "yes", "default": {"a": 1}}
+ ]}"#).unwrap();
+ assert_eq!(r.specs.iter().map(|s| s.key.as_str()).collect::>(), vec!["aa", "strength", "odd"]);
+ let aa = r.get("aa").unwrap();
+ assert_eq!(aa.choices.iter().map(|c| c.name.as_str()).collect::>(), vec!["off", "fxaa", "2", "On"]);
+ assert_eq!(aa.impact, vec![("picture".to_string(), "Smoother edges.".to_string()), ("memory".to_string(), "More VRAM.".to_string())]);
+ assert_eq!(aa.sub, "");
+ let s = r.get("strength").unwrap();
+ assert!(s.choices.is_empty() && s.group == "Other");
+ assert_eq!(s.name_of(&json!(0.4)), "0.4");
+ let odd = r.get("odd").unwrap();
+ assert!(odd.label == "odd" && odd.applies.is_none() && odd.sources.is_empty() && !odd.quick && odd.impact.is_empty());
+ assert_eq!(r.groups().iter().map(|(g, _)| g.as_str()).collect::>(), vec!["Anti-aliasing", "Other"]);
+ assert!(Registry::parse("[]").is_err() && Registry::parse("{}").is_err() && Registry::parse("nope").is_err());
+ }
+
+ #[test]
+ fn values_compare_by_meaning_and_custom_ones_get_a_name() {
+ let r = Registry::parse(SAMPLE).unwrap();
+ assert!(same(&json!(1), &json!(1.0)) && !same(&json!(true), &json!(1)) && !same(&json!("1"), &json!(1)));
+ assert_eq!(r.get("fsr_sharpness").unwrap().position(&json!(1)), Some(2));
+ let hz = r.get("hz").unwrap();
+ assert_eq!((hz.name_of(&json!(90)).as_str(), hz.name_of(&json!(210)).as_str()), ("3x", "7x"));
+ }
+
+ #[test]
+ fn says_why_a_setting_is_not_used() {
+ let r = Registry::parse(SAMPLE).unwrap();
+ let off = |k: &str| if k == "interp" { json!(false) } else { Value::Null };
+ let on = |k: &str| if k == "interp" { json!(true) } else { Value::Null };
+ let hz = r.get("hz").unwrap();
+ assert_eq!(hz.unused_now(&r, &off).as_deref(), Some("Only used while Frame generation is On (now Off)."));
+ assert_eq!(hz.unused_now(&r, &on), None);
+ let c = r.get("capture_size").unwrap();
+ assert_eq!(c.unused_with("capture"), None);
+ assert_eq!(c.unused_with("chiaki").as_deref(), Some("Remote Play is 1080p."));
+ assert_eq!(c.unused_with("window").as_deref(), Some("Only used with a capture card."));
+ assert_eq!(c.source_note().as_deref(), Some("Only used with a capture card."));
+ assert_eq!(hz.source_note(), None);
+ }
+
+ #[test]
+ fn the_settings_file_is_changed_key_by_key() {
+ let d = std::env::temp_dir().join(format!("summit-registry-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&d);
+ let f = d.join("deep/settings.json");
+ assert!(read_values(&f).is_empty());
+ write_values(&f, &[("scaler", Some(json!("vsr"))), ("hz", Some(json!(120)))]).unwrap();
+ // something the launcher does not know stays in the file
+ let mut v = read_values(&f);
+ v.insert("from_a_newer_engine".into(), json!([1, 2]));
+ std::fs::write(&f, serde_json::to_string(&v).unwrap()).unwrap();
+ write_values(&f, &[("hz", None), ("vsync", Some(json!(true)))]).unwrap();
+ let v = read_values(&f);
+ assert_eq!(v.get("scaler"), Some(&json!("vsr")));
+ assert_eq!(v.get("vsync"), Some(&json!(true)));
+ assert_eq!(v.get("from_a_newer_engine"), Some(&json!([1, 2])));
+ assert!(!v.contains_key("hz"));
+ std::fs::write(&f, "not json").unwrap();
+ assert!(read_values(&f).is_empty());
+ write_values(&f, &[("hz", Some(json!(90)))]).unwrap(); // a damaged file is replaced, not a reason to fail
+ assert_eq!(read_values(&f).get("hz"), Some(&json!(90)));
+ let _ = std::fs::remove_dir_all(&d);
+ }
+
+ #[test]
+ fn a_profile_forces_what_the_planner_passes() {
+ let p = Profile { framegen: "none".into(), upscaler: "rtx-vsr".into(), vsr_quality: Some(3), fsr_sharpness: Some(0.25), framegen_multiplier: 4,
+ window_mode: "borderless".into(), watermark: Some(false), motion: Some("half".into()), ..Default::default() };
+ let f = forced(&p);
+ assert_eq!(f.get("interp"), Some(&json!(false)));
+ assert_eq!(f.get("hz"), Some(&json!(120)));
+ assert_eq!(f.get("scaler"), Some(&json!("vsr")));
+ assert_eq!(f.get("vsr_quality"), Some(&json!(3)));
+ assert!(!f.contains_key("fsr_sharpness")); // only with FSR, as the planner
+ assert_eq!(f.get("fullscreen"), Some(&json!(true)));
+ assert_eq!(f.get("watermark"), Some(&json!(false)));
+ assert_eq!(f.get("motion"), Some(&json!("half")));
+ assert!(forced(&Profile::default()).is_empty());
+ // the engine table wins over the older named setting
+ let mut p = Profile { upscaler: "fsr".into(), ..Default::default() };
+ p.engine.insert("scaler".into(), toml::Value::String("bilinear".into()));
+ p.engine.insert("overlay_style".into(), toml::Value::String("graphs".into()));
+ let f = forced(&p);
+ assert_eq!((f.get("scaler"), f.get("overlay_style")), (Some(&json!("bilinear")), Some(&json!("graphs"))));
+ }
+
+ #[test]
+ fn setting_a_key_in_a_layer_drops_the_older_named_setting() {
+ let mut l = Layer { upscaler: Some("rtx-vsr".into()), framegen_multiplier: Some(4), target_hz: Some(120), ..Default::default() };
+ assert!(l.sets_engine("scaler") && l.sets_engine("hz") && !l.sets_engine("vsync"));
+ l.set_engine("scaler", Some(&json!("fsr")));
+ assert_eq!(l.upscaler, None);
+ assert_eq!(l.engine.as_ref().unwrap().get("scaler"), Some(&toml::Value::String("fsr".into())));
+ l.set_engine("hz", None);
+ assert_eq!((l.framegen_multiplier, l.target_hz), (None, None));
+ assert!(!l.sets_engine("hz"));
+ l.set_engine("fsr_sharpness", Some(&json!(0.25)));
+ l.set_engine("vsr_quality", Some(&json!(4)));
+ l.set_engine("overlay", Some(&json!(false)));
+ let text = toml::to_string_pretty(&l).unwrap();
+ let back: Layer = toml::from_str(&text).unwrap();
+ assert_eq!(back, l, "{text}");
+ let f = forced(&crate::profile::resolve(&[&back]));
+ assert_eq!((f.get("fsr_sharpness"), f.get("vsr_quality"), f.get("overlay")), (Some(&json!(0.25)), Some(&json!(4)), Some(&json!(false))));
+ l.set_engine("scaler", None); l.set_engine("fsr_sharpness", None); l.set_engine("vsr_quality", None); l.set_engine("overlay", None);
+ assert!(l.is_empty(), "{l:?}");
+ }
+
+ #[test]
+ fn the_anti_aliasing_profile_field_and_the_engine_table_agree() {
+ // Compare's named `aa` and the launcher's `[engine] aa` are one setting: the later layer wins either way
+ let named = Layer { aa: Some("smaa".into()), ..Default::default() };
+ let mut table = Layer::default();
+ table.set_engine("aa", Some(&json!("fxaa")));
+ assert!(named.sets_engine("aa") && table.sets_engine("aa"));
+ let p = crate::profile::resolve(&[&table, &named]);
+ assert_eq!(forced(&p).get("aa"), Some(&json!("smaa")));
+ assert!(!p.engine.contains_key("aa"), "the named setting above replaces the table's key below");
+ let p = crate::profile::resolve(&[&named, &table]);
+ assert_eq!(forced(&p).get("aa"), Some(&json!("fxaa")));
+ // the planner then passes --aa=smaa and, after it, --set=aa="fxaa": the engine applies --set last
+ let mut l = named.clone();
+ l.set_engine("aa", Some(&json!("cas")));
+ assert_eq!(l.aa, None, "the launcher's row drops the older named setting");
+ assert!(forced(&Profile { aa: Some("dlaa".into()), ..Default::default() }).is_empty());
+ }
+
+ #[test]
+ fn the_real_engine_registry_reads_when_python_is_here() {
+ let engine = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../engine");
+ let Ok(r) = Registry::load(&engine) else { eprintln!("skipped: no python3 to ask the engine"); return };
+ assert!(r.specs.len() > 30 && r.get("scaler").is_some() && r.get("hz").is_some());
+ assert!(r.specs.iter().all(|s| !s.label.is_empty() && !s.group.is_empty()));
+ assert!(r.specs.iter().filter(|s| s.quick).count() >= 4);
+ // every preset names a real setting and one of its choices
+ for p in crate::presets::PRESETS {
+ for (k, v) in p.values() {
+ let s = r.get(k).unwrap_or_else(|| panic!("preset {}: no setting {k}", p.id));
+ assert!(s.position(&v).is_some(), "preset {}: {k} has no choice {v}", p.id);
+ }
+ }
+ // every key the launch profile can force is a real setting, of the registry's type
+ for k in ["interp", "hz", "game_fps", "output_res", "model", "vfg_quality", "motion", "engine", "steady_hud", "scaler", "fsr_sharpness", "vsr_quality", "fullscreen", "fill", "vsync", "watermark", "replay", "replay_clip", "aa"] {
+ assert!(r.get(k).is_some(), "the engine has no setting {k}");
+ }
+ }
+}
diff --git a/crates/summit-core/src/sessions.rs b/crates/summit-core/src/sessions.rs
new file mode 100644
index 0000000..66dbe90
--- /dev/null
+++ b/crates/summit-core/src/sessions.rs
@@ -0,0 +1,228 @@
+//! Session summaries the engine writes after a run (JSON files), for a game's Statistics view.
+//!
+//! The format belongs to the engine and is not fixed here: every `*.json` in the sessions folders is read as it
+//! is, and what is shown is what the file holds (its fields, flattened). Only the names of a few fields are
+//! guessed, to pick a headline: a duration, an average frame rate, the lows, which game it was. A file that is
+//! not a JSON object is skipped; a missing folder is no sessions.
+use serde_json::Value;
+use std::path::{Path, PathBuf};
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct Summary {
+ pub file: PathBuf,
+ /// When it ended, as far as the file says (a "ended"/"end"/"time"/"timestamp" field in seconds), else the
+ /// file's modification time. Seconds since 1970; 0 if unknown.
+ pub when: u64,
+ /// The game it says it was for ("game", "title", "game_title", "name", "game_id", "id"), if it says.
+ pub game: Option,
+ /// Every scalar in the file as (dotted name, text), sorted by name; lists of scalars joined, other lists
+ /// counted.
+ pub fields: Vec<(String, String)>,
+ pub duration_s: Option,
+ pub fps_avg: Option,
+ /// (the field's own name, value): "1% low", "0.1% low", "min"...
+ pub lows: Vec<(String, f64)>,
+ /// The fields under a "settings" object (or any name ending in "settings"), as (key, text).
+ pub settings: Vec<(String, String)>,
+}
+
+/// Where summaries are looked for: $SUMMIT_SESSIONS_DIR, then `sessions` and `stats` folders under the engine's
+/// and Summit's data, state, cache and config folders. Folders that do not exist are fine.
+pub fn dirs() -> Vec {
+ let mut v: Vec = vec![];
+ if let Some(d) = std::env::var_os("SUMMIT_SESSIONS_DIR").filter(|d| !d.is_empty()) { v.push(d.into()); }
+ let roots = [::dirs::data_dir(), ::dirs::state_dir(), ::dirs::cache_dir(), ::dirs::config_dir()];
+ for root in roots.into_iter().flatten() {
+ for app in ["smoovplay", "summit"] { for sub in ["sessions", "stats"] { v.push(root.join(app).join(sub)); } }
+ }
+ v.dedup();
+ v
+}
+
+fn scalar(v: &Value) -> Option {
+ match v {
+ Value::String(s) => Some(s.clone()),
+ Value::Bool(b) => Some(if *b { "yes" } else { "no" }.into()),
+ Value::Number(n) => Some(match n.as_f64() { Some(f) if n.is_f64() => trim_num(f), _ => n.to_string() }),
+ Value::Null => None,
+ _ => None,
+ }
+}
+fn trim_num(f: f64) -> String {
+ let s = format!("{f:.2}");
+ s.trim_end_matches('0').trim_end_matches('.').to_string()
+}
+
+fn flatten(prefix: &str, v: &Value, depth: u8, out: &mut Vec<(String, String)>) {
+ match v {
+ Value::Object(o) if depth < 4 => for (k, v) in o { flatten(&if prefix.is_empty() { k.clone() } else { format!("{prefix}.{k}") }, v, depth + 1, out); },
+ Value::Object(o) => out.push((prefix.to_string(), format!("{} fields", o.len()))),
+ Value::Array(a) => {
+ let parts: Vec = a.iter().filter_map(scalar).collect();
+ if parts.len() == a.len() && a.len() <= 12 { out.push((prefix.to_string(), parts.join(", "))); }
+ else { out.push((prefix.to_string(), format!("{} values", a.len()))); }
+ }
+ other => if let Some(s) = scalar(other) { out.push((prefix.to_string(), s)); },
+ }
+}
+
+fn last(name: &str) -> String { name.rsplit('.').next().unwrap_or(name).to_lowercase() }
+
+/// Read one summary from JSON text. None if it is not a JSON object.
+pub fn parse(text: &str, file: &Path, mtime: u64) -> Option {
+ let v: Value = serde_json::from_str(text).ok()?;
+ let o = v.as_object()?;
+ let mut fields = vec![];
+ flatten("", &v, 0, &mut fields);
+ let num = |name: &str| -> Option { fields.iter().find(|(k, _)| k == name).and_then(|(_, v)| v.parse::().ok()) };
+ let pick = |test: &dyn Fn(&str) -> bool| -> Option<(String, f64)> {
+ fields.iter().find(|(k, v)| test(&k.to_lowercase()) && v.parse::().is_ok()).map(|(k, v)| (k.clone(), v.parse().unwrap_or(0.0)))
+ };
+ let game = ["game", "title", "game_title", "name", "game_id", "id"].iter()
+ .find_map(|k| o.get(*k).and_then(Value::as_str).map(str::trim).filter(|s| !s.is_empty()).map(String::from));
+ let when = ["ended", "ended_at", "end", "end_time", "time", "timestamp", "started", "start"].iter()
+ .find_map(|k| num(k)).filter(|t| *t > 1.0e9 && *t < 1.0e11).map(|t| t as u64).unwrap_or(mtime);
+ // seconds unless the name says otherwise
+ let duration_s = pick(&|k| { let l = last(k); l.contains("duration") || l.contains("elapsed") || l == "seconds" || l == "length_s" || l == "playtime" })
+ .map(|(k, v)| { let l = last(&k); if l.ends_with("_ms") { v / 1000.0 } else if l.ends_with("_min") || l.ends_with("minutes") { v * 60.0 } else { v } });
+ let is_fps = |k: &str| k.contains("fps") || k.contains("frame_rate") || k.contains("framerate");
+ let fps_avg = pick(&|k| is_fps(k) && (k.contains("avg") || k.contains("average") || k.contains("mean")))
+ .or_else(|| pick(&|k| { let l = last(k); l == "fps" || l == "output_fps" || l == "fps_out" })).map(|(_, v)| v);
+ let lows: Vec<(String, f64)> = fields.iter().filter(|(k, _)| { let k = k.to_lowercase(); (k.contains("low") || k.contains("p1") || k.contains("p01") || k.contains("min_fps") || k.contains("fps_min")) && !k.contains("settings") })
+ .filter_map(|(k, v)| Some((last(k).replace('_', " "), v.parse::().ok()?))).take(4).collect();
+ let settings: Vec<(String, String)> = fields.iter().filter_map(|(k, v)| {
+ let (head, rest) = k.split_once('.')?;
+ head.to_lowercase().ends_with("settings").then(|| (rest.to_string(), v.clone()))
+ }).collect();
+ Some(Summary { file: file.to_path_buf(), when, game, fields, duration_s, fps_avg, lows, settings })
+}
+
+/// Every summary in `dirs` (and one folder level below, for a folder per game), newest first. At most `max` files
+/// are read, and none bigger than 1 MB.
+pub fn read(dirs: &[PathBuf], max: usize) -> Vec {
+ let mut files: Vec<(PathBuf, u64, Option)> = vec![];
+ let scan = |dir: &Path, folder: Option, files: &mut Vec<(PathBuf, u64, Option)>| -> Vec {
+ let mut subs = vec![];
+ for e in std::fs::read_dir(dir).into_iter().flatten().flatten() {
+ let p = e.path();
+ let Ok(meta) = e.metadata() else { continue };
+ if meta.is_dir() { subs.push(p); continue; }
+ if p.extension().and_then(|x| x.to_str()) != Some("json") || meta.len() > 1_000_000 { continue; }
+ let mtime = meta.modified().ok().and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()).map(|d| d.as_secs()).unwrap_or(0);
+ files.push((p, mtime, folder.clone()));
+ }
+ subs
+ };
+ for d in dirs {
+ for sub in scan(d, None, &mut files) {
+ let name = sub.file_name().map(|n| n.to_string_lossy().into_owned());
+ scan(&sub, name, &mut files);
+ }
+ }
+ files.sort_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(&b.0)));
+ files.dedup_by(|a, b| a.0 == b.0);
+ files.truncate(max);
+ let mut out: Vec = files.into_iter().filter_map(|(p, mtime, folder)| {
+ let mut s = parse(&std::fs::read_to_string(&p).ok()?, &p, mtime)?;
+ if s.game.is_none() { s.game = folder; } // a folder per game names it
+ Some(s)
+ }).collect();
+ out.sort_by(|a, b| b.when.cmp(&a.when));
+ out
+}
+
+fn norm(s: &str) -> String { s.chars().filter(|c| c.is_alphanumeric()).flat_map(char::to_lowercase).collect() }
+
+/// Whether a summary is for the game with this id and title: it names one of them (letters and digits compared,
+/// so "Void Runner" is "voidrunner"). A summary that names no game belongs to none.
+pub fn is_for(s: &Summary, id: &str, title: &str) -> bool {
+ let Some(g) = s.game.as_deref().map(norm).filter(|g| !g.is_empty()) else { return false };
+ g == norm(title) || g == norm(id) || id.rsplit(':').next().is_some_and(|tail| g == norm(tail))
+}
+
+/// "1 h 12 min", "4 min 5 s", "42 s".
+pub fn duration_label(s: f64) -> String {
+ let t = s.max(0.0).round() as u64;
+ match (t / 3600, (t % 3600) / 60, t % 60) {
+ (0, 0, s) => format!("{s} s"),
+ (0, m, s) => format!("{m} min {s} s"),
+ (h, m, _) => format!("{h} h {m} min"),
+ }
+}
+
+/// A time as the wall clock here shows it: "2026-11-26 14:05". Seconds since 1970; "" for 0.
+pub fn stamp(t: u64) -> String {
+ if t == 0 { return String::new(); }
+ let secs = t as libc::time_t;
+ let mut tm: libc::tm = unsafe { std::mem::zeroed() };
+ // SAFETY: localtime_r only writes the tm it is given.
+ if unsafe { libc::localtime_r(&secs, &mut tm) }.is_null() { return String::new(); }
+ format!("{:04}-{:02}-{:02} {:02}:{:02}", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn shows_what_is_in_the_file_whatever_its_shape() {
+ let s = parse(r#"{"game": "Voidrunner", "ended": 1795000000, "duration_s": 754.4, "fps": {"avg": 118.26, "low_1": 96.5, "low_01": 71},
+ "settings": {"scaler": "fsr", "hz": 120, "interp": true}, "dropped": [1, 2, 3], "notes": null}"#, Path::new("a.json"), 5).unwrap();
+ assert_eq!(s.game.as_deref(), Some("Voidrunner"));
+ assert_eq!(s.when, 1795000000);
+ assert_eq!(s.duration_s, Some(754.4));
+ assert_eq!(s.fps_avg, Some(118.26));
+ assert_eq!(s.lows, vec![("low 01".to_string(), 71.0), ("low 1".to_string(), 96.5)]);
+ assert_eq!(s.settings, vec![("hz".to_string(), "120".to_string()), ("interp".to_string(), "yes".to_string()), ("scaler".to_string(), "fsr".to_string())]);
+ assert!(s.fields.contains(&("dropped".to_string(), "1, 2, 3".to_string())));
+ assert!(s.fields.contains(&("fps.avg".to_string(), "118.26".to_string())));
+ assert!(!s.fields.iter().any(|(k, _)| k == "notes"));
+ }
+
+ #[test]
+ fn other_names_and_nothing_at_all() {
+ let s = parse(r#"{"title": "X", "elapsed_ms": 90000, "average_fps": 59.9, "one_percent_low_fps": 48}"#, Path::new("b.json"), 77).unwrap();
+ assert_eq!((s.duration_s, s.fps_avg, s.when), (Some(90.0), Some(59.9), 77));
+ assert_eq!(s.lows, vec![("one percent low fps".to_string(), 48.0)]);
+ // nothing recognisable: still a summary, with its fields, and no made-up numbers
+ let s = parse(r#"{"a": 1, "b": {"c": "d"}}"#, Path::new("c.json"), 3).unwrap();
+ assert_eq!((s.duration_s, s.fps_avg, s.game.clone(), s.lows.len(), s.settings.len()), (None, None, None, 0, 0));
+ assert_eq!(s.fields, vec![("a".to_string(), "1".to_string()), ("b.c".to_string(), "d".to_string())]);
+ assert!(parse("[1, 2]", Path::new("d.json"), 0).is_none());
+ assert!(parse("{broken", Path::new("e.json"), 0).is_none());
+ assert!(parse("", Path::new("f.json"), 0).is_none());
+ }
+
+ #[test]
+ fn reads_folders_defensively_and_matches_games() {
+ let d = std::env::temp_dir().join(format!("summit-sessions-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&d);
+ assert!(read(&[d.clone(), d.join("nope")], 50).is_empty());
+ std::fs::create_dir_all(d.join("Voidrunner")).unwrap();
+ std::fs::write(d.join("one.json"), r#"{"game": "Void Runner", "ended": 1795000100, "duration": 60}"#).unwrap();
+ std::fs::write(d.join("Voidrunner/two.json"), r#"{"ended": 1795000200, "fps_avg": 90}"#).unwrap();
+ std::fs::write(d.join("other.json"), r#"{"game": "Else", "ended": 1795000300}"#).unwrap();
+ std::fs::write(d.join("junk.json"), "not json").unwrap();
+ std::fs::write(d.join("list.json"), "[]").unwrap();
+ std::fs::write(d.join("readme.txt"), "{}").unwrap();
+ let all = read(&[d.clone()], 50);
+ assert_eq!(all.iter().map(|s| s.when).collect::>(), vec![1795000300, 1795000200, 1795000100]);
+ let mine: Vec<&Summary> = all.iter().filter(|s| is_for(s, "custom:voidrunner", "Voidrunner")).collect();
+ assert_eq!(mine.len(), 2);
+ assert_eq!(mine[0].game.as_deref(), Some("Voidrunner")); // from its folder
+ assert!(!is_for(&Summary::default(), "x", "X"));
+ assert_eq!(read(&[d.clone()], 1).len(), 1);
+ let _ = std::fs::remove_dir_all(&d);
+ }
+
+ #[test]
+ fn stamps_are_dates() {
+ assert_eq!(stamp(0), "");
+ let s = stamp(1_795_000_000);
+ assert!(s.len() == 16 && s.starts_with("2026-11-1"), "{s}"); // (the hour depends on the time zone)
+ }
+ #[test]
+ fn durations_read_naturally() {
+ assert_eq!((duration_label(42.4).as_str(), duration_label(245.0).as_str(), duration_label(4330.0).as_str()), ("42 s", "4 min 5 s", "1 h 12 min"));
+ }
+}
diff --git a/crates/summit-gui/Cargo.toml b/crates/summit-gui/Cargo.toml
index ba2c50a..6f3ff2d 100644
--- a/crates/summit-gui/Cargo.toml
+++ b/crates/summit-gui/Cargo.toml
@@ -10,6 +10,7 @@ path = "src/main.rs"
[dependencies]
summit-core = { path = "../summit-core" }
+serde_json.workspace = true
# renderer-femtovg (OpenGL) is what a normal run uses; renderer-software is the fallback and the headless screenshot mode.
slint = { version = "1.19", default-features = false, features = ["std", "backend-winit", "renderer-femtovg", "renderer-software", "software-renderer-systemfonts", "compat-1-2", "unstable-winit-030"] }
# unstable-winit-030: whether the launcher's window has the keyboard (winit's has_focus), so a controller is only
diff --git a/crates/summit-gui/src/data.rs b/crates/summit-gui/src/data.rs
index 584a448..a7b3d4b 100644
--- a/crates/summit-gui/src/data.rs
+++ b/crates/summit-gui/src/data.rs
@@ -188,7 +188,6 @@ fn rates(p: &Profile, outs: &[Output]) -> Vec {
}
fn enc_bool(v: Option) -> Option { v.map(|b| if b { "on".into() } else { "off".into() }) }
-fn enc_num(v: Option) -> Option { v.map(|n| n.to_string()) }
/// A layer's value for a row, encoded as that row's choices are.
pub fn enc_get(l: &Layer, key: &str) -> Option {
@@ -197,24 +196,7 @@ pub fn enc_get(l: &Layer, key: &str) -> Option {
"resolution" => match (l.width, l.height) { (Some(w), Some(h)) if w > 0 && h > 0 => Some(format!("{w}x{h}")), (Some(_), _) | (_, Some(_)) => Some(String::new()), _ => None },
"refresh_hz" => l.refresh_hz.map(|r| if r > 0.0 { format!("{r}") } else { String::new() }),
"window_mode" => l.window_mode.clone(),
- "focus" => enc_bool(l.focus), "enhance" => enc_bool(l.enhance), "steady_hud" => enc_bool(l.steady_hud),
- "vsync" => enc_bool(l.vsync), "watermark" => enc_bool(l.watermark),
- "upscaler" => l.upscaler.as_deref().map(|u| if u == "vsr" { "rtx-vsr".into() } else { u.to_string() }),
- "fsr_sharpness" => l.fsr_sharpness.map(|v| if v < 0.0 { String::new() } else { format!("{v}") }),
- "vsr_quality" => l.vsr_quality.map(|v| if v == 0 { String::new() } else { v.to_string() }),
- "framegen" => l.framegen.clone(),
- "target_hz" => l.target_hz.map(|v| if v == 0 { String::new() } else { v.to_string() }),
- // the multiplier, or an older file's output rate read as one (120 Hz is 4x); "" a game's "engine setting"
- "framegen_multiplier" => match (l.framegen_multiplier, l.target_hz) {
- (Some(m), _) if summit_core::profile::MULTIPLIER_RANGE.contains(&m) => Some(m.to_string()),
- (_, Some(0)) | (Some(_), None) => Some(String::new()),
- (_, Some(hz)) => Some((hz / 30).to_string()),
- (None, None) => None,
- },
- "model" => l.model.clone(), "vfg_quality" => l.vfg_quality.clone(), "motion" => l.motion.clone(),
- "ai_engine" => l.ai_engine.clone(), "fill" => l.fill.clone(),
- "game_fps" => l.game_fps.clone(),
- "output_res" => l.output_res.as_deref().map(|r| summit_core::profile::parse_res(r).map(|(w, h)| format!("{w}x{h}")).unwrap_or_default()),
+ "focus" => enc_bool(l.focus), "enhance" => enc_bool(l.enhance),
_ => None,
}
}
@@ -235,22 +217,7 @@ pub fn enc_set(l: &mut Layer, key: &str, v: Option<&str>) {
}
"refresh_hz" => l.refresh_hz = v.map(|t| t.parse().unwrap_or(0.0)),
"window_mode" => l.window_mode = s(v),
- "focus" => l.focus = b(v), "enhance" => l.enhance = b(v), "steady_hud" => l.steady_hud = b(v),
- "vsync" => l.vsync = b(v), "watermark" => l.watermark = b(v),
- "upscaler" => l.upscaler = s(v),
- "fsr_sharpness" => l.fsr_sharpness = v.map(|t| t.parse().unwrap_or(-1.0)),
- "vsr_quality" => l.vsr_quality = v.map(|t| t.parse().unwrap_or(0)),
- "framegen" => l.framegen = s(v),
- "target_hz" => l.target_hz = v.map(|t| t.parse().unwrap_or(0)),
- "framegen_multiplier" => match v.map(str::parse::) {
- None => { l.framegen_multiplier = None; l.target_hz = None; }
- Some(Ok(m)) => { l.framegen_multiplier = Some(m); l.target_hz = None; }
- Some(Err(_)) => { l.framegen_multiplier = None; l.target_hz = Some(0); } // "": the engine's own
- },
- "model" => l.model = s(v), "vfg_quality" => l.vfg_quality = s(v), "motion" => l.motion = s(v),
- "ai_engine" => l.ai_engine = s(v), "fill" => l.fill = s(v),
- "game_fps" => l.game_fps = s(v),
- "output_res" => l.output_res = s(v),
+ "focus" => l.focus = b(v), "enhance" => l.enhance = b(v),
_ => {}
}
}
@@ -281,7 +248,6 @@ fn label_of(choices: &[Choice], v: &Option) -> String {
fn choices(key: &str, eff: &Profile, base: &Profile, outs: &[Output], own: &Layer) -> (Vec, Option) {
let c = |v: &str, l: &str| (Some(v.to_string()), l.to_string());
let unset = |l: &str| (None, l.to_string());
- let bool3 = |l: &str| vec![unset(l), c("off", "Off"), c("on", "On")];
let opt = |v: Option| Some(v.unwrap_or_default());
match key {
"monitor" => {
@@ -303,30 +269,6 @@ fn choices(key: &str, eff: &Profile, base: &Profile, outs: &[Output], own: &Laye
"window_mode" => (vec![unset("As the game opens it"), c("windowed", "Windowed"), c("borderless", "Borderless window"), c("fullscreen", "Fullscreen")], opt(Some(base.window_mode.clone()))),
"focus" => (vec![unset("Off"), c("on", "On")], Some(if base.focus { "on".into() } else { String::new() })),
"enhance" => (vec![unset("Off"), c("on", "On")], Some(if base.enhance { "on".into() } else { String::new() })),
- "upscaler" => (vec![unset("Engine setting (FSR)"), c("none", "Off (no upscaling)"), c("fsr", "AMD FSR 1"), c("rtx-vsr", "NVIDIA RTX VSR"), c("bilinear", "Bilinear")], opt(Some(if base.upscaler == "vsr" { "rtx-vsr".into() } else { base.upscaler.clone() }))),
- "fsr_sharpness" => (vec![unset("Engine setting"), c("0", "Max"), c("0.25", "High"), c("0.5", "Medium"), c("1", "Low"), c("2", "Minimal")], opt(base.fsr_sharpness.map(|v| format!("{v}")))),
- "vsr_quality" => (vec![unset("Engine setting"), c("1", "Low"), c("2", "Medium"), c("3", "High"), c("4", "Ultra")], opt(enc_num(base.vsr_quality))),
- "framegen" => (vec![unset("Engine setting (on)"), c("none", "Off"), c("rife", "On")], opt(Some(base.framegen.clone()))),
- "model" => (vec![unset("Engine setting"), c("4.22.lite", "RIFE 4.22 lite"), c("4.25.lite", "RIFE 4.25 lite"), c("4.25", "RIFE 4.25"), c("4.26", "RIFE 4.26"), c("vfg", "NVIDIA VFG")], opt(base.model.clone())),
- "vfg_quality" => (vec![unset("Engine setting"), c("low", "Low"), c("medium", "Medium"), c("high", "High")], opt(base.vfg_quality.clone())),
- "motion" => (vec![unset("Auto"), c("full", "Full"), c("half", "Half")], opt(base.motion.clone())),
- "ai_engine" => (vec![unset("Engine setting"), c("auto", "Auto"), c("trt", "TensorRT"), c("torch", "PyTorch")], opt(base.ai_engine.clone())),
- "target_hz" => (vec![unset("Engine setting"), c("60", "60 Hz"), c("90", "90 Hz"), c("120", "120 Hz")], opt(enc_num(base.target_hz))),
- "game_fps" => (vec![unset("Engine setting (Auto)"), c("auto", "Auto"), c("30", "30 fps"), c("60", "60 fps")], opt(base.game_fps.clone())),
- "output_res" => {
- let mut v = vec![unset("Same as the screen")];
- v.extend(summit_core::profile::OUTPUT_SIZES.iter().map(|r| c(r, &res_label(r))));
- (v, opt(base.output_res.clone()))
- }
- "framegen_multiplier" => {
- let mut v = vec![unset("Engine setting (2×)")];
- v.extend(summit_core::profile::MULTIPLIERS.iter().map(|m| c(&m.to_string(), &multiplier_label(*m))));
- (v, opt(base.multiplier().map(|m| m.to_string())))
- }
- "steady_hud" => (bool3("Engine setting"), Some(base.steady_hud.map(|b| if b { "on" } else { "off" }.to_string()).unwrap_or_default())),
- "fill" => (vec![unset("Engine setting"), c("fit", "Fit (bars)"), c("zoom", "Zoom (crop)"), c("stretch", "Stretch"), c("panorama", "Panorama")], opt(base.fill.clone())),
- "vsync" => (bool3("Engine setting"), Some(base.vsync.map(|b| if b { "on" } else { "off" }.to_string()).unwrap_or_default())),
- "watermark" => (bool3("Engine setting (on)"), Some(base.watermark.map(|b| if b { "on" } else { "off" }.to_string()).unwrap_or_default())),
_ => (vec![], None),
}
}
@@ -335,41 +277,14 @@ fn choices(key: &str, eff: &Profile, base: &Profile, outs: &[Output], own: &Laye
fn effective(cx: &EditCtx) -> Profile { let mut p = cx.base.clone(); cx.own.apply(&mut p); p }
/// A row's choices for the layer being edited. On a game "not chosen" becomes a value of its own (Some(""): e.g.
-/// never switch monitors, whatever the defaults say), and a first choice follows the defaults. Engine on/off
-/// settings have no "not chosen" a game can store, so a game picks Off or On there.
-fn layer_choices(key: &str, mut ch: Vec, defaults: bool, base_label: &str) -> Vec {
+/// never switch monitors, whatever the defaults say), and a first choice follows the defaults.
+fn layer_choices(_key: &str, mut ch: Vec, defaults: bool, base_label: &str) -> Vec {
if defaults { return ch; }
- if matches!(key, "steady_hud" | "vsync" | "watermark") { ch.retain(|c| c.0.is_some()); }
for c in ch.iter_mut() { if c.0.is_none() { c.0 = Some(String::new()); } }
ch.insert(0, (None, format!("Default · {base_label}")));
ch
}
-/// "4× (120 fps)": a frame multiplier and the rate it makes of a 30 fps game.
-pub fn multiplier_label(m: u8) -> String { format!("{m}×") }
-
-/// "1440p" for the presets, "2560 × 1080" for any other size.
-pub fn res_label(r: &str) -> String {
- match summit_core::profile::parse_res(r) {
- Some((3840, 2160)) => "4K (3840 × 2160)".into(),
- Some((w, h)) if summit_core::profile::OUTPUT_SIZES.contains(&format!("{w}x{h}").as_str()) => format!("{h}p ({w} × {h})"),
- Some((w, h)) => format!("{w} × {h}"),
- None => r.to_string(),
- }
-}
-
-/// The layer's output resolution when it isn't one of the editor's choices (typed in Custom output resolution).
-fn custom_res(l: &Layer) -> Option {
- let (w, h) = summit_core::profile::parse_res(l.output_res.as_deref()?)?;
- let r = format!("{w}x{h}");
- (!summit_core::profile::OUTPUT_SIZES.contains(&r.as_str())).then_some(r)
-}
-
-/// The layer's multiplier when it isn't one of the editor's choices (typed in Custom multiplier).
-fn custom_multiplier(l: &Layer) -> Option {
- l.framegen_multiplier.filter(|m| summit_core::profile::MULTIPLIER_RANGE.contains(m) && !summit_core::profile::MULTIPLIERS.contains(m))
-}
-
/// Text rows: launch arguments and environment variables, as one line each.
fn text_of(l: &Layer, key: &str) -> Option {
match key {
@@ -380,14 +295,12 @@ fn text_of(l: &Layer, key: &str) -> Option {
}
}
-/// The rows, in order, with headers. Rows that cannot matter with the other choices (FSR sharpening with RTX VSR,
-/// VFG quality with RIFE) are left out.
+/// The rows, in order, with headers: what belongs to the launch itself (monitor, window, arguments). The engine's
+/// settings are rows of their own, from the engine's registry (rows.rs).
pub fn edit_rows(cx: &EditCtx) -> Vec {
let eff = effective(cx);
let mut rows = vec![];
let header = |t: &str| EditRow { key: "", kind: RowKind::Header, label: t.into(), hint: String::new(), options: vec![], value: 0, text: String::new(), placeholder: String::new(), own: false };
- let up = eff.upscaler.as_str();
- let rife = !matches!(eff.model.as_deref(), Some("vfg")) && eff.framegen != "none";
let mon_hint = match cx.list_err {
Some(e) => format!("Monitors could not be listed: {e}."),
None => format!("Switched with {} when Summit starts the game and put back when it ends. The game's window is moved there too{}.", if cx.tool.is_empty() { "the desktop's tool" } else { cx.tool }, if cx.placer.is_ok() { "" } else { " (not on this desktop)" }),
@@ -400,27 +313,8 @@ pub fn edit_rows(cx: &EditCtx) -> Vec {
("refresh_hz", "Refresh rate", if eff.width.is_none() { "Pick a resolution first.".into() } else { "Rates this mode offers.".into() }),
("window_mode", "Window mode", format!("The game's window, windowed, as a borderless window over the monitor, or fullscreen. {place_note} With Enhance it is the engine's picture instead, and the game is left at its size.")),
("focus", "Focus the game", format!("Raise the game's window and give it the keyboard once it opens. {place_note}")),
- ("#", "ENHANCE: UPSCALING", String::new()),
- ("enhance", "Enhance on Play", "Play also runs Summit's engine on the game's window: the upscaler and frame generation below.".into()),
- ("upscaler", "Upscaler", "Enlarges the game's picture to the window or monitor. FSR is almost free and was run on the test machine; RTX VSR is wired but untested.".into()),
- ("fsr_sharpness", "FSR sharpening", "How strongly FSR 1 sharpens. Less keeps compression blocks from standing out.".into()),
- ("vsr_quality", "RTX VSR quality", "Higher is cleaner and asks more of the GPU.".into()),
- ("output_res", "Output resolution", "The size the upscaler makes the picture, then fitted to the screen: smaller is lighter, bigger than the screen sharpens (supersampling).".into()),
- ("output_res_custom", "Custom output resolution", "Any size, e.g. 2560x1080 (from 320x240 to 7680x4320). Enter to type it, Enter to save; empty goes back to the choice above.".into()),
- ("fill", "Fill the screen", "On a screen that is not 16:9: bars, crop, stretch, or panorama.".into()),
- ("#", "ENHANCE: FRAME GENERATION", String::new()),
- ("framegen", "Frame generation", "AI in-between frames. Needs an NVIDIA GPU and the engine's Python environment.".into()),
- ("model", "Model", "RIFE 4.22 lite is the one the engine is tuned and tested with. NVIDIA VFG is a separate download (RTX 40/50).".into()),
- ("vfg_quality", "VFG quality", "How much work NVIDIA VFG puts into each frame.".into()),
- ("motion", "Motion detail", "How finely RIFE tracks movement. Half is about 40% faster and a little softer.".into()),
- ("ai_engine", "AI engine", "TensorRT is about 12% faster at full motion detail; its first start takes a minute or two.".into()),
- ("steady_hud", "Steady HUD", "Keeps still parts of the picture (map, health bar) exactly as the game drew them.".into()),
- ("framegen_multiplier", "Frame multiplier", "Frames shown for each one the game draws: 2× makes 30 fps 60 and 60 fps 120. Needs a display that fast; more needs a faster card.".into()),
- ("multiplier_custom", "Custom multiplier", "Any whole number from 2 to 10. Enter to type it, Enter to save; empty goes back to the choice above.".into()),
- ("game_fps", "Game frame rate", "Auto works it out as the game plays. 60 fps: the multiplier works from 60 (2× is 120 fps). 30 fps: every other frame is new.".into()),
- ("#", "ENGINE WINDOW", String::new()),
- ("vsync", "VSync", "Sync the engine's picture to the display (G-Sync/FreeSync).".into()),
- ("watermark", "Watermark", "The \"summit - git.molberg.cloud/alex/summit\" line in a corner of the picture.".into()),
+ ("#", "ENHANCE", String::new()),
+ ("enhance", "Enhance on Play", "Play also runs Summit's engine on the game's window: frame generation and the upscaler, with the engine settings in the other sections.".into()),
("#", "LAUNCH", String::new()),
("launch_args", "Launch arguments", "Added after the game's command, e.g. -windowed -dx11. Quotes group words. Enter to edit, Enter to save.".into()),
("env", "Environment", "KEY=VALUE pairs, e.g. MANGOHUD=1 PROTON_ENABLE_NVAPI=1. A game's keys win over the defaults'. Enter to edit.".into()),
@@ -431,34 +325,10 @@ pub fn edit_rows(cx: &EditCtx) -> Vec {
// a window belongs to one game: not a default
if cx.defaults && (key == "window" || label == "GAME WINDOW") { continue; }
if key == "#" { rows.push(header(label)); continue; }
- let skip = match key {
- "fsr_sharpness" => !matches!(up, "" | "fsr"),
- "vsr_quality" => !matches!(up, "rtx-vsr" | "vsr"),
- "vfg_quality" => eff.model.as_deref() != Some("vfg") || eff.framegen == "none",
- "model" | "framegen_multiplier" | "multiplier_custom" | "game_fps" | "steady_hud" => eff.framegen == "none",
- "motion" | "ai_engine" => !rife,
- _ => false,
- };
- if skip && !cx.own.has(key) && key != "multiplier_custom" { continue; }
- if skip && key == "multiplier_custom" { continue; }
- if key == "output_res_custom" {
- let text = custom_res(cx.own).unwrap_or_default();
- let placeholder = match eff.output_res.as_deref() { Some(r) => format!("Now {}", res_label(r)), None => "e.g. 2560x1080".into() };
- rows.push(EditRow { key, kind: RowKind::Text, label: label.into(), hint, options: vec![], value: 0, text, placeholder, own: !cx.defaults && custom_res(cx.own).is_some() });
- continue;
- }
let own = !cx.defaults && match key {
"resolution" => cx.own.width.is_some() || cx.own.height.is_some(),
- "framegen_multiplier" => cx.own.framegen_multiplier.is_some() || cx.own.target_hz.is_some(),
- "multiplier_custom" => custom_multiplier(cx.own).is_some(),
k => cx.own.has(k),
};
- if key == "multiplier_custom" {
- let text = custom_multiplier(cx.own).map(|m| m.to_string()).unwrap_or_default();
- let placeholder = match eff.multiplier() { Some(m) => format!("Now {}", multiplier_label(m)), None => "e.g. 7".into() };
- rows.push(EditRow { key, kind: RowKind::Text, label: label.into(), hint, options: vec![], value: 0, text, placeholder, own });
- continue;
- }
if key == "window" {
let placeholder = match cx.auto_window { Some(q) => format!("Automatic: {q}"), None => "Automatic: asks you to pick it".into() };
rows.push(EditRow { key, kind: RowKind::Text, label: label.into(), hint, options: vec![], value: 0, text: text_of(cx.own, key).unwrap_or_default(), placeholder, own });
@@ -477,15 +347,8 @@ pub fn edit_rows(cx: &EditCtx) -> Vec {
let cur = if cx.defaults { cur.filter(|v| !v.is_empty()) } else { cur };
let value = match ch.iter().position(|c| c.0 == cur || (key == "refresh_hz" && c.0.as_deref().zip(cur.as_deref()).is_some_and(|(a, b)| a.parse::().ok().zip(b.parse::().ok()).is_some_and(|(a, b)| same_rate(a, b))))) {
Some(i) => i,
- None => {
- // a value the list doesn't have: a custom multiplier, or something a newer Summit (or the CLI) wrote
- let l = match (key, cur.as_deref().and_then(|c| c.parse::().ok())) {
- ("framegen_multiplier", Some(m)) => format!("{} (custom)", multiplier_label(m)),
- ("output_res", _) if cur.as_deref().is_some_and(|c| !c.is_empty()) => format!("{} (custom)", res_label(cur.as_deref().unwrap_or_default())),
- _ => cur.clone().unwrap_or_default(),
- };
- ch.push((cur, l)); ch.len() - 1
- }
+ // a value the list doesn't have (something a newer Summit, or the CLI, wrote)
+ None => { let l = cur.clone().unwrap_or_default(); ch.push((cur, l)); ch.len() - 1 }
};
rows.push(EditRow { key, kind: RowKind::Choice, label: label.into(), hint, options: ch.iter().map(|c| c.1.clone()).collect(), value, text: String::new(), placeholder: String::new(), own });
}
@@ -510,24 +373,6 @@ pub fn edit_text(own: &Layer, key: &str, text: &str) -> Result {
"launch_args" => l.launch_args = if t.is_empty() { None } else { Some(summit_core::profile::split_args(t)) },
"env" => l.env = if t.is_empty() { None } else { Some(summit_core::profile::parse_env_line(t)?) },
"window" => l.window = if t.is_empty() { None } else { Some(t.to_string()) },
- "output_res_custom" => {
- if t.is_empty() {
- if custom_res(&l).is_some() { l.output_res = None; } // back to the choice above
- } else {
- let (w, h) = summit_core::profile::parse_res(t).ok_or_else(|| "A size like 2560x1440, from 320x240 to 7680x4320".to_string())?;
- l.output_res = Some(format!("{w}x{h}"));
- }
- }
- "multiplier_custom" => {
- if t.is_empty() {
- if custom_multiplier(&l).is_some() { l.framegen_multiplier = None; } // back to the choice above
- } else {
- let m = t.trim_end_matches(['x', 'X', '×']).trim().parse::().ok().filter(|m| summit_core::profile::MULTIPLIER_RANGE.contains(m))
- .ok_or_else(|| "The multiplier is a whole number from 2 to 10".to_string())?;
- l.framegen_multiplier = Some(m);
- l.target_hz = None;
- }
- }
_ => {}
}
Ok(l)
@@ -725,9 +570,11 @@ mod tests {
let q = set(&l, &base, true, &o, "monitor", "Don't switch");
assert_eq!((q.monitor, q.width, q.refresh_hz), (None, None, None));
// the defaults store nothing for their first choice
- let l = set(&Layer::default(), &base, true, &o, "upscaler", "AMD FSR 1");
- assert_eq!(l.upscaler.as_deref(), Some("fsr"));
- assert_eq!(set(&l, &base, true, &o, "upscaler", "Engine setting (FSR)").upscaler, None);
+ let l = set(&Layer::default(), &base, true, &o, "window_mode", "Borderless window");
+ assert_eq!(l.window_mode.as_deref(), Some("borderless"));
+ assert_eq!(set(&l, &base, true, &o, "window_mode", "As the game opens it").window_mode, None);
+ // the engine's settings are not rows here any more: they come from the engine's registry (rows.rs)
+ assert!(!rows.iter().any(|r| matches!(r.key, "upscaler" | "framegen" | "model" | "vsync")));
}
#[test]
fn a_game_follows_the_defaults_or_overrides_them() {
@@ -736,8 +583,6 @@ mod tests {
let base = summit_core::profile::resolve(&[&d]);
let g = Layer::default();
let rows = edit_rows(&cx(&g, &base, false, &o));
- let up = row(&rows, "upscaler");
- assert_eq!((up.options[0].as_str(), up.value, up.own), ("Default · AMD FSR 1", 0, false));
assert_eq!(row(&rows, "window_mode").options[0], "Default · Borderless window");
assert_eq!(row(&rows, "monitor").options[0], "Default · Virtual-1");
assert_eq!(row(&rows, "enhance").options[0], "Default · On");
@@ -745,17 +590,13 @@ mod tests {
let g2 = set(&g, &base, false, &o, "monitor", "Don't switch");
assert_eq!(g2.monitor.as_deref(), Some(""));
assert_eq!(summit_core::profile::resolve(&[&d, &g2]).monitor, None);
- let g3 = set(&g, &base, false, &o, "upscaler", "NVIDIA RTX VSR");
+ let g3 = set(&g, &base, false, &o, "window_mode", "Windowed");
let rows = edit_rows(&cx(&g3, &base, false, &o));
- assert!(row(&rows, "upscaler").own);
- assert!(rows.iter().any(|r| r.key == "vsr_quality") && !rows.iter().any(|r| r.key == "fsr_sharpness"));
+ assert!(row(&rows, "window_mode").own);
// back to Default: left out of the file again
- assert!(set(&g3, &base, false, &o, "upscaler", "Default · AMD FSR 1").is_empty());
+ assert!(set(&g3, &base, false, &o, "window_mode", "Default · Borderless window").is_empty());
let g4 = set(&g, &base, false, &o, "enhance", "Off");
assert_eq!(g4.enhance, Some(false));
- // engine on/off settings: Default, Off or On on a game
- assert_eq!(row(&edit_rows(&cx(&g, &base, false, &o)), "vsync").options, vec!["Default · Engine setting", "Off", "On"]);
- assert_eq!(set(&g, &base, false, &o, "vsync", "Off").vsync, Some(false));
}
#[test]
fn a_game_on_its_own_monitor_offers_that_monitors_modes() {
@@ -768,19 +609,6 @@ mod tests {
assert_eq!((g.width, g.height), (Some(1280), Some(720)));
}
#[test]
- fn frame_generation_rows_follow_the_choices() {
- let o = outs();
- let base = Profile::default();
- let l = set(&Layer::default(), &base, true, &o, "framegen", "Off");
- let rows = edit_rows(&cx(&l, &base, true, &o));
- assert!(!rows.iter().any(|r| r.key == "model" || r.key == "motion"));
- let l = set(&Layer::default(), &base, true, &o, "model", "NVIDIA VFG");
- let rows = edit_rows(&cx(&l, &base, true, &o));
- assert!(rows.iter().any(|r| r.key == "vfg_quality") && !rows.iter().any(|r| r.key == "motion"));
- let l = set(&l, &base, true, &o, "vfg_quality", "High");
- assert_eq!(l.vfg_quality.as_deref(), Some("high"));
- }
- #[test]
fn text_rows_for_arguments_and_environment() {
let d = Layer { env: Some([("MANGOHUD".to_string(), "1".to_string())].into()), ..Default::default() };
let base = summit_core::profile::resolve(&[&d]);
@@ -821,52 +649,4 @@ mod tests {
assert_eq!(window_wait("[window] waiting for a window matching 'class:a' (up to 300 s)\n"), WindowWait::Waiting { asking: false });
assert_eq!(window_wait("[window] waiting for a window matching 'class:a'\nError: no window matches 'class:a' after 300 s\n"), WindowWait::GaveUp);
}
- #[test]
- fn frame_multiplier_rows() {
- let base = Profile { framegen: "rife".into(), target_hz: Some(120), ..Default::default() }; // the defaults: 4x
- let g = Layer::default();
- let rows = edit_rows(&cx(&g, &base, false, &[]));
- let r = row(&rows, "framegen_multiplier");
- assert_eq!(r.options[r.value], "Default · 4×");
- assert!(r.options.contains(&"8×".to_string()));
- // picking 6x: the game's own, and no older output rate left beside it
- let six = r.options.iter().position(|o| o.starts_with("6×")).unwrap();
- let g = edit_apply(&cx(&g, &base, false, &[]), "framegen_multiplier", six);
- assert_eq!((g.framegen_multiplier, g.target_hz), (Some(6), None));
- // a custom 7x: typed, shown as custom in the choice row, cleared again with an empty line
- let g = edit_text(&g, "multiplier_custom", " 7x ").unwrap();
- assert_eq!(g.framegen_multiplier, Some(7));
- let rows = edit_rows(&cx(&g, &base, false, &[]));
- assert_eq!(row(&rows, "multiplier_custom").text, "7");
- let r = row(&rows, "framegen_multiplier");
- assert_eq!(r.options[r.value], "7× (custom)");
- assert!(edit_text(&g, "multiplier_custom", "11").is_err() && edit_text(&g, "multiplier_custom", "1.5").is_err());
- assert_eq!(edit_text(&g, "multiplier_custom", "").unwrap().framegen_multiplier, None);
- // frame generation off: neither row
- let off = Profile { framegen: "none".into(), ..Default::default() };
- let rows = edit_rows(&cx(&Layer::default(), &off, false, &[]));
- assert!(!rows.iter().any(|r| r.key == "framegen_multiplier" || r.key == "multiplier_custom"));
- }
- #[test]
- fn game_frame_rate_and_output_resolution_rows() {
- let base = Profile { framegen: "rife".into(), ..Default::default() };
- let g = Layer::default();
- let rows = edit_rows(&cx(&g, &base, false, &[]));
- let fps = row(&rows, "game_fps");
- let sixty = fps.options.iter().position(|o| o == "60 fps").unwrap();
- assert_eq!(edit_apply(&cx(&g, &base, false, &[]), "game_fps", sixty).game_fps.as_deref(), Some("60"));
- let r = row(&rows, "output_res");
- assert!(r.options.contains(&"1440p (2560 × 1440)".to_string()) && r.options.contains(&"4K (3840 × 2160)".to_string()));
- let k = r.options.iter().position(|o| o.starts_with("1440p")).unwrap();
- assert_eq!(edit_apply(&cx(&g, &base, false, &[]), "output_res", k).output_res.as_deref(), Some("2560x1440"));
- // any size, typed: shown as custom in the choice row
- let g = edit_text(&g, "output_res_custom", " 2560 x 1080 ").unwrap();
- assert_eq!(g.output_res.as_deref(), Some("2560x1080"));
- let rows = edit_rows(&cx(&g, &base, false, &[]));
- assert_eq!(row(&rows, "output_res_custom").text, "2560x1080");
- let r = row(&rows, "output_res");
- assert_eq!(r.options[r.value], "2560 × 1080 (custom)");
- assert!(edit_text(&g, "output_res_custom", "99x99").is_err() && edit_text(&g, "output_res_custom", "big").is_err());
- assert_eq!(edit_text(&g, "output_res_custom", "").unwrap().output_res, None);
- }
}
diff --git a/crates/summit-gui/src/main.rs b/crates/summit-gui/src/main.rs
index 6d8b859..1159a76 100644
--- a/crates/summit-gui/src/main.rs
+++ b/crates/summit-gui/src/main.rs
@@ -3,6 +3,8 @@ mod accounts;
mod art;
mod data;
mod pad;
+mod pane;
+mod rows;
mod shot;
use slint::{ComponentHandle, Image, Model, ModelRc, SharedString, VecModel};
@@ -40,9 +42,14 @@ pub struct App {
pub headless: bool,
base_scale: Cell,
fullscreen: Cell,
- save_timer: slint::Timer,
- /// What the profile editor is editing, if it is open.
- editing: RefCell