Frame generation for 60 fps games, output resolution, and a regrouped overlay

60 fps games
- A game at a steady 60 fps (found after a second at 57+, or Game frame rate
  set to the new 60 fps) goes on the frame timeline, which draws in-between
  frames at any rate; the 60 Hz beat alone only ever showed its own frames
- The frame multiplier works from the game's rate: 2x makes 30 fps 60 and
  60 fps 120 (labels are now just "2x", "3x"...)
- --sim60 plays a 60 fps file as a 60 fps game, for testing

Output resolution
- The upscaler makes the picture at a chosen size (720p .. 4K, or any WxH),
  then it's fitted to the screen: lighter below the screen's size,
  supersampling above it. --output-res, the overlay, Summit's profile editor
  (with a custom size), `summit profile set --output-res`

In-game overlay
- Tabs regrouped with headings: Home, Frame generation (Basics, AI model,
  Smoothing), Upscaling (Upscaler, Output), Display (Window, Colour and look),
  Overlay (Stats, Graphs, This menu, Branding), Clips, Sources; one table
  (settings.LAYOUT) says where each setting goes
- Bigger: 1100 px wide, 11 rows; headings are skipped by keys and the mouse
- Home adds Game frame rate and Output resolution

Summit: Game frame rate and Output resolution per game (profile, editor, CLI)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ZebraticandClaude Opus 5.5 committed 2026-11-25 03:22:53 +01:00
1 parent 023f8b3ecc
commit 2eec6b324d
12 files changed
+413 -68

No files matched your search

+13 -1
View File
@@ -177,6 +177,10 @@ enum ProfileCmd {
/// Which window Enhance takes: class:NAME, part of its title, dir:FOLDER ("|" between alternatives; see
/// `summit windows`). "" goes back to automatic
#[arg(long, allow_hyphen_values = true)] window: Option<String>,
/// The game's frame rate for frame generation: auto, 30 or 60 (60: the multiplier works from 60)
#[arg(long)] game_fps: Option<String>,
/// Output resolution: the upscaler makes the picture at this size, e.g. 2560x1440 ("screen": the screen's)
#[arg(long)] output_res: Option<String>,
},
/// Forget settings, so the defaults decide again: the ones named (e.g. `upscaler window_mode`), or all of them
Reset { id: String, keys: Vec<String> },
@@ -507,7 +511,7 @@ fn main() -> Result<()> {
}
}
}
Cmd::Profile { cmd: ProfileCmd::Set { id, monitor, width, height, refresh, window_mode, fullscreen, focus, enhance, upscaler, fsr_sharpness, vsr_quality, framegen, multiplier, target_hz, model, vfg_quality, motion, ai_engine, steady_hud, fill, vsync, watermark, args, env, unset_env, window } } => {
Cmd::Profile { cmd: ProfileCmd::Set { id, monitor, width, height, refresh, window_mode, fullscreen, focus, enhance, upscaler, fsr_sharpness, vsr_quality, framegen, multiplier, target_hz, model, vfg_quality, motion, ai_engine, steady_hud, fill, vsync, watermark, args, env, unset_env, window, game_fps, output_res } } => {
use profile as pr;
let window_mode = match (window_mode, fullscreen) {
(Some(m), _) => Some(pick("window-mode", m, pr::WINDOW_MODES, true)?),
@@ -517,6 +521,12 @@ fn main() -> Result<()> {
if let Some(v) = fsr_sharpness { anyhow::ensure!(pr::FSR_SHARPNESS.contains(&v), "--fsr-sharpness is 0, 0.25, 0.5, 1 or 2"); }
if let Some(v) = vsr_quality { anyhow::ensure!(pr::VSR_QUALITIES.contains(&v), "--vsr-quality is 1, 2, 3 or 4"); }
if let Some(v) = target_hz { anyhow::ensure!(v == 0 || pr::TARGET_HZ.contains(&v), "--target-hz is 60, 90 or 120 (0: the engine's setting); --multiplier takes 2 to 10"); }
if let Some(v) = &game_fps { anyhow::ensure!(pr::GAME_FPS.contains(&v.as_str()), "--game-fps is auto, 30 or 60"); }
let output_res = match output_res.as_deref() {
None => None,
Some("screen") | Some("") => Some(String::new()),
Some(r) => Some(pr::parse_res(r).map(|(w, h)| format!("{w}x{h}")).ok_or_else(|| anyhow::anyhow!("--output-res is a size like 2560x1440, or screen"))?),
};
if let Some(v) = multiplier { anyhow::ensure!(pr::MULTIPLIER_RANGE.contains(&v), "--multiplier is a whole number from 2 to 10 (2x = 60 fps, 4x = 120 fps)"); }
let upscaler = upscaler.map(|v| pick("upscaler", v, pr::UPSCALERS, true)).transpose()?;
let framegen = framegen.map(|v| pick("framegen", v, pr::FRAMEGENS, true)).transpose()?;
@@ -537,6 +547,8 @@ fn main() -> Result<()> {
if refresh.is_some() { l.refresh_hz = refresh; }
if window_mode.is_some() { l.window_mode = window_mode; }
if let Some(w) = window { l.window = Some(w.trim().to_string()).filter(|w| !w.is_empty()); }
if game_fps.is_some() { l.game_fps = game_fps; }
if let Some(r) = output_res { l.output_res = Some(r).filter(|r| !r.is_empty()); }
if focus.is_some() { l.focus = focus; }
if enhance.is_some() { l.enhance = enhance; }
if upscaler.is_some() { l.upscaler = upscaler; }
+11
View File
@@ -89,6 +89,8 @@ pub fn plan(engine: &Path, src: &Source, p: &Profile, display: bool, out: Option
// 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());
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() {
"windowed" => a.push("--no-fullscreen".into()),
_ if p.fullscreen() => a.push("--fullscreen".into()),
@@ -606,4 +608,13 @@ mod tests {
assert_eq!(got, vec![1, 2, 3]);
let _ = std::fs::remove_dir_all(&root);
}
#[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 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() };
let a = plan(Path::new("/e"), &Source::Window("pid:1".into()), &p, true, None, None).join(" ");
assert!(!a.contains("--game-fps") && !a.contains("--output-res"), "{a}"); // nothing the engine would refuse
}
}
+21 -1
View File
@@ -35,6 +35,16 @@ pub const TARGET_HZ: &[u32] = &[60, 90, 120];
/// fps). These are the editor's choices; any whole number in MULTIPLIER_RANGE works (a custom one).
pub const MULTIPLIERS: &[u8] = &[2, 3, 4, 5, 6, 8];
pub const MULTIPLIER_RANGE: std::ops::RangeInclusive<u8> = 2..=10;
pub const GAME_FPS: &[&str] = &["auto", "30", "60"];
/// Output resolution presets (any WxH from 320x240 to 7680x4320 works: [`parse_res`]).
pub const OUTPUT_SIZES: &[&str] = &["1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160"];
/// "2560x1440" (or "2560 x 1440", "2560X1440") as a size the engine takes.
pub fn parse_res(s: &str) -> Option<(u32, u32)> {
let (w, h) = s.trim().split_once(['x', 'X', '×'])?;
let (w, h) = (w.trim().parse::<u32>().ok()?, h.trim().parse::<u32>().ok()?);
((320..=7680).contains(&w) && (240..=4320).contains(&h)).then_some((w, h))
}
/// The settings a game launches with, after the layers are put together. `None` (and "") everywhere means "not
/// chosen": the monitor is not switched, the window is left alone, the engine uses its own saved setting.
@@ -80,6 +90,10 @@ pub struct Profile {
pub launch_args: Vec<String>,
/// Set for the game's process (e.g. MANGOHUD=1, PROTON_ENABLE_NVAPI=1). The game's own keys win over the defaults'.
pub env: BTreeMap<String, String>,
/// The game's frame rate for frame generation: "auto" | "30" | "60" (None: the engine's own setting).
pub game_fps: Option<String>,
/// The size the upscaler makes the picture, "2560x1440" (None: the screen's own).
pub output_res: Option<String>,
/// 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<String>,
@@ -126,6 +140,8 @@ pub struct Layer {
#[serde(skip_serializing_if = "Option::is_none")] pub launch_args: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")] pub env: Option<BTreeMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")] pub window: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] pub game_fps: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] pub output_res: Option<String>,
/// 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<bool>,
@@ -135,7 +151,7 @@ pub struct Layer {
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",
"steady_hud", "fill", "vsync", "watermark", "launch_args", "env", "window", "game_fps", "output_res",
];
impl Layer {
@@ -189,6 +205,8 @@ impl Layer {
if let Some(v) = &self.launch_args { p.launch_args = v.clone(); }
if let Some(v) = &self.env { for (k, val) in v { p.env.insert(k.clone(), val.clone()); } }
if let Some(v) = &self.window { p.window = Some(v.trim().to_string()).filter(|v| !v.is_empty()); }
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"); }
}
/// Whether this layer sets `key` (one of [`KEYS`]).
@@ -203,6 +221,7 @@ impl Layer {
"ai_engine" => self.ai_engine.is_some(), "steady_hud" => self.steady_hud.is_some(), "fill" => self.fill.is_some(),
"vsync" => self.vsync.is_some(), "watermark" => self.watermark.is_some(), "launch_args" => self.launch_args.is_some(),
"env" => self.env.is_some(), "window" => self.window.is_some(),
"game_fps" => self.game_fps.is_some(), "output_res" => self.output_res.is_some(),
_ => false,
}
}
@@ -220,6 +239,7 @@ impl Layer {
"motion" => self.motion = None, "ai_engine" => self.ai_engine = None, "steady_hud" => self.steady_hud = None,
"fill" => self.fill = None, "vsync" => self.vsync = None, "watermark" => self.watermark = None,
"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,
_ => return false,
}
true
+76 -9
View File
@@ -121,7 +121,7 @@ pub fn profile_summary(p: &Profile, own: usize) -> ProfileSummary {
(f, _) => f.to_string(),
};
match p.multiplier() {
Some(m) => format!("{name} {m}×, {} fps out", 30 * u32::from(m)),
Some(m) => format!("{name} {m}×"),
None => name,
}
}
@@ -213,6 +213,8 @@ pub fn enc_get(l: &Layer, key: &str) -> Option<String> {
},
"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()),
_ => None,
}
}
@@ -247,6 +249,8 @@ pub fn enc_set(l: &mut Layer, key: &str, v: Option<&str>) {
},
"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),
_ => {}
}
}
@@ -308,6 +312,12 @@ fn choices(key: &str, eff: &Profile, base: &Profile, outs: &[Output], own: &Laye
"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))));
@@ -336,7 +346,24 @@ fn layer_choices(key: &str, mut ch: Vec<Choice>, defaults: bool, base_label: &st
}
/// "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}× ({} fps)", 30 * u32::from(m)) }
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<String> {
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<u8> {
@@ -378,6 +405,8 @@ pub fn edit_rows(cx: &EditCtx) -> Vec<EditRow> {
("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()),
@@ -386,8 +415,9 @@ pub fn edit_rows(cx: &EditCtx) -> Vec<EditRow> {
("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 real one of a 30 fps game: 2× is 60 fps, 4× is 120. Needs a display that fast; more needs a faster card.".into()),
("multiplier_custom", "Custom multiplier", "Any whole number from 2 to 10 (7× is 210 fps). Enter to type it, Enter to save; empty goes back to the choice above.".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()),
@@ -405,12 +435,18 @@ pub fn edit_rows(cx: &EditCtx) -> Vec<EditRow> {
"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" | "steady_hud" => 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(),
@@ -445,6 +481,7 @@ pub fn edit_rows(cx: &EditCtx) -> Vec<EditRow> {
// 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::<u8>().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
@@ -473,6 +510,14 @@ pub fn edit_text(own: &Layer, key: &str, text: &str) -> Result<Layer, String> {
"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
@@ -639,7 +684,7 @@ mod tests {
assert_eq!((s.monitor.as_str(), s.mode.as_str(), s.upscaler.as_str(), s.framegen.as_str(), s.window.as_str(), s.set), ("Default", "Default", "Engine setting", "RIFE", "Default", false));
let p = Profile { monitor: Some("HDMI-A-1".into()), width: Some(3840), height: Some(2160), refresh_hz: Some(59.94), window_mode: "borderless".into(), focus: true, upscaler: "fsr".into(), framegen: "rife".into(), target_hz: Some(120), ..Default::default() };
let s = profile_summary(&p, 3);
assert_eq!((s.monitor.as_str(), s.mode.as_str(), s.upscaler.as_str(), s.framegen.as_str(), s.window.as_str(), s.set), ("HDMI-A-1", "3840 × 2160 at 59.94 Hz", "FSR", "RIFE 4×, 120 fps out", "Borderless window, focused", true));
assert_eq!((s.monitor.as_str(), s.mode.as_str(), s.upscaler.as_str(), s.framegen.as_str(), s.window.as_str(), s.set), ("HDMI-A-1", "3840 × 2160 at 59.94 Hz", "FSR", "RIFE 4×", "Borderless window, focused", true));
assert_eq!(profile_summary(&Profile { framegen: "none".into(), ..Default::default() }, 0).framegen, "None");
}
#[test]
@@ -782,8 +827,8 @@ mod tests {
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× (120 fps)");
assert!(r.options.contains(&"8× (240 fps)".to_string()));
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);
@@ -794,7 +839,7 @@ mod tests {
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× (210 fps) (custom)");
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
@@ -802,4 +847,26 @@ mod tests {
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);
}
}
+15
View File
@@ -293,6 +293,8 @@ UNEVEN_OFF = (35, 58) # ...and outside which it switches off again
UNEVEN_DWELL = 60 # ticks (a second) the rate has to stay there first, so a 30 fps game's 60 fps menu doesn't
# flip it on and off
UNEVEN_MAX_DELAY = 2.0 # ticks
FULL_ON, FULL_OFF = 57, 52 # new frames in the last second at which a game counts as a 60 fps one (FrameTimeline.full),
# and below which it stops counting (after UNEVEN_DWELL ticks, as for uneven)
# Dip smoothing (DipWatch, FrameTimeline.at_arrival): a 30 fps game that misses its slot shows a frame
# for 3 ticks (50 ms) or, waiting for the next 30 fps slot, 4 (67 ms; Gotham Knights' hitches on PS5 Remote Play).
@@ -401,6 +403,8 @@ class FrameTimeline:
self._dwell = 0
self._hz, self._j = 0, 0 # slots(): the output rate, and the next output frame's number
self.at_arrival = False # Dip smoothing: frames timed as they arrived (set_at_arrival)
self.full = False # a game at about 60 fps: frame generation works from 60 (the pipeline times it here)
self._full_dwell = 0
def set_at_arrival(self, on: bool) -> None:
if on == self.at_arrival:
@@ -466,6 +470,17 @@ class FrameTimeline:
self.uneven, self._dwell = want_on, 0
if want_on:
self.delay = self._want_delay()
want_full = self.full
if fps is not None:
if fps >= FULL_ON:
want_full = True
elif fps <= FULL_OFF:
want_full = False
self._full_dwell = self._full_dwell + 1 if want_full != self.full else 0
if self._full_dwell >= UNEVEN_DWELL:
self.full, self._full_dwell = want_full, 0
if want_full:
self.delay = max(self.delay, self._want_delay())
return added
def slots(self, hz: int) -> list[float]:
+57 -3
View File
@@ -120,14 +120,18 @@ class Ps5SimSource:
"""
def __init__(self, path: str, realtime: bool = False, hitch: float = 0.0, noise: float = 0.0,
max_ticks: int | None = None, seed: int = 0) -> None:
max_ticks: int | None = None, seed: int = 0, game60: bool = False) -> None:
from .sources import source_info
self.dec = _Decoder(path)
self.w, self.h = self.dec.w, self.dec.h
self.info = source_info("sim", live=realtime)
self.realtime, self.hitch, self.max_ticks = realtime, hitch, max_ticks
self.step = 2 if self.dec.fps > 45 else 1 # 60 fps source: drop odd frames; 30 fps: use all
if self.step == 1:
self.game60 = game60 # --sim60: a 60 fps file played as a 60 fps game, a new frame every tick
if game60:
self.step = 1
print(f"[sim] {self.dec.fps:.2f} fps source played as a 60 fps game (no ground truth)")
elif self.step == 1:
print(f"[sim] {self.dec.fps:.2f} fps source: using every frame as a game frame (no ground truth)")
self.rng = random.Random(seed)
self.history: OrderedDict[int, np.ndarray] = OrderedDict()
@@ -149,7 +153,7 @@ class Ps5SimSource:
self.history.popitem(last=False)
if i % self.step:
continue # odd frames of a 60 fps source: the game "never rendered" these
repeats = 3 if self.rng.random() < self.hitch else 2
repeats = 1 if self.game60 else 3 if self.rng.random() < self.hitch else 2
for r in range(repeats):
if self.max_ticks is not None and tick >= self.max_ticks:
return
@@ -1528,6 +1532,38 @@ class GLWindowSink:
dw, dh, x0, y0 = layout(self.fill, fw, fh, self.w, self.h) # (Fill the screen: always the same 16:9 picture)
return fw, fh, s, dw, dh, x0, y0
def _output_size(self, dw: int, dh: int) -> tuple[int, int] | None:
"""Output resolution: the size to make the picture at (its shape kept, within the size asked for), or None
when that's the screen's own (the upscaler then draws straight to the screen)."""
from .settings import parse_res
want = parse_res(getattr(self.settings, "output_res", "screen"))
if want is None or dw <= 0 or dh <= 0:
return None
k = min(want[0] / dw, want[1] / dh)
ow, oh = max(2, round(dw * k)) & ~1, max(2, round(dh * k)) & ~1
return None if abs(ow - dw) <= 2 and abs(oh - dh) <= 2 else (ow, oh)
def _out_target(self, w: int, h: int) -> int:
"""The framebuffer the picture is drawn into at the output resolution (made again when the size changes)."""
GL = self.GL
have = getattr(self, "_out", None)
if have is not None and have[2:] == (w, h):
return have[1]
if have is not None:
GL.glDeleteFramebuffers(1, [have[1]])
GL.glDeleteTextures([have[0]])
tex = GL.glGenTextures(1)
GL.glBindTexture(GL.GL_TEXTURE_2D, tex)
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, w, h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, None)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
fbo = GL.glGenFramebuffers(1)
GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, fbo)
GL.glFramebufferTexture2D(GL.GL_DRAW_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_TEXTURE_2D, tex, 0)
self._out = (tex, fbo, w, h)
print(f"[display] output resolution {w}x{h}", flush=True)
return fbo
def _panorama_on(self, fw: int, fh: int) -> bool:
return self.fill == "panorama" and self.overlay_of is None and wider(fw, fh, self.w, self.h)
@@ -1672,6 +1708,16 @@ class GLWindowSink:
self.panorama = Panorama(GL)
target, x0, y0 = self.panorama.target(dw, dh), 0, 0
GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, target)
# Output resolution: the upscaler makes the picture at that size, in a texture of its own, which is then
# stretched (or shrunk: supersampling) onto the screen where the picture goes
out_to = None
out_size = None if pano else self._output_size(dw, dh)
if out_size is not None:
out_to = (target, x0, y0, dw, dh)
target = self._out_target(*out_size)
x0, y0, dw, dh = 0, 0, *out_size
GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, target)
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
mode = self.mode
if mode == "off" and (dw > self.w or dh > self.h):
# Upscaling off: the picture at its own size (never enlarged), in the middle of where it would go
@@ -1710,6 +1756,14 @@ class GLWindowSink:
# Image row 0 is the top; GL row 0 is the bottom, so blit with destination Y flipped.
GL.glBlitFramebuffer(0, 0, self.w, self.h, x0, y0 + dh, x0 + dw, y0, GL.GL_COLOR_BUFFER_BIT,
GL.GL_LINEAR)
if out_to is not None:
to, tx, ty, tw, th = out_to
GL.glBindFramebuffer(GL.GL_READ_FRAMEBUFFER, target)
GL.glBindFramebuffer(GL.GL_DRAW_FRAMEBUFFER, to)
GL.glBlitFramebuffer(0, 0, dw, dh, tx, ty, tx + tw, ty + th, GL.GL_COLOR_BUFFER_BIT, GL.GL_LINEAR)
GL.glViewport(0, 0, fw, fh)
label += f" at {dw}x{dh} -> {tw}x{th}"
dw, dh = tw, th
if pano:
self.panorama.draw(screen, fw, fh, panorama_t(fw, fh, self.w, self.h))
label += " + panorama"
+39 -12
View File
@@ -27,10 +27,10 @@ import numpy as np
from . import ui_draw as U
from .settings import SPECS, Settings, Spec
VISIBLE = 8 # rows shown at once; longer tabs scroll
VISIBLE = 11 # rows shown at once (headings count); longer tabs scroll
DROP_VISIBLE = 7 # choices shown at once in a drop-down list
HOME = "Home"
TAB_NAMES = {"Instant replay": "Clips", "PS5 Remote Play": "Remote Play"} # shorter, for the tab strip
TAB_NAMES: dict[str, str] = {} # shorter names for the tab strip, if a section's is too long
PERF = "perf" # Home's "Performance overlay": the settings "overlay" and "overlay_style" as one row
PERF_CHOICES = ("off", "minimal", "detailed", "graphs")
@@ -48,7 +48,7 @@ QUIT_HELP = "Closes Summit's picture. A game started from Summit's launcher is c
@dataclass(frozen=True)
class Row:
kind: str # "setting" | "perf" | "action"
kind: str # "setting" | "perf" | "action" | "header" (a heading inside a tab: drawn, never highlighted)
key: str # the setting's key, "perf", or the action: "restart", "clip", "quit"
label: str
spec: Spec | None = None
@@ -131,7 +131,14 @@ class Menu:
if "overlay" in values and "overlay_style" in values:
rows.append(Row(PERF, PERF, "Performance overlay"))
else:
rows = [Row("setting", s.key, s.label, s) for s in self.specs if s.group == tab and s.applies_to(values)]
rows, sub = [], None
for s in self.specs:
if s.group != tab or not s.applies_to(values):
continue
if s.sub and s.sub != sub:
rows.append(Row("header", "#" + s.sub, s.sub))
sub = s.sub
rows.append(Row("setting", s.key, s.label, s))
if self.restart_reasons():
rows.append(Row("action", "restart", "Restart now"))
if tab is None:
@@ -205,11 +212,23 @@ class Menu:
if self.index == self._at and self._sel in keys: # (index set from outside: that row, as given)
self.index = keys.index(self._sel)
self.index = max(0, min(self.index, len(rows) - 1))
self.index = self._usable(rows, self.index, 1)
self._sel, self._at = keys[self.index], self.index
self._scroll = max(0, min(self._scroll, len(rows) - VISIBLE))
if self._drop is not None and self._drop not in keys:
self._drop = None
@staticmethod
def _usable(rows: list[Row], i: int, direction: int) -> int:
"""The row at i, or (a heading) the nearest one that isn't a heading, looking `direction` first."""
for d in (direction, -direction):
j = i
while 0 <= j < len(rows):
if rows[j].kind != "header":
return j
j += d
return i
def _reveal(self) -> None:
"""Scrolls the highlighted row into view (the keyboard moved it; the mouse never needs this)."""
if self.index < self._scroll:
@@ -217,13 +236,16 @@ class Menu:
elif self.index >= self._scroll + VISIBLE:
self._scroll = self.index - VISIBLE + 1
def _select(self, i: int, rows: list[Row] | None = None, reveal: bool = True) -> None:
def _select(self, i: int, rows: list[Row] | None = None, reveal: bool = True, direction: int = 1) -> None:
rows = self.rows() if rows is None else rows
self.index = max(0, min(i, len(rows) - 1))
self.index = self._usable(rows, max(0, min(i, len(rows) - 1)), direction)
self._sel, self._at = rows[self.index].key, self.index
self._follow(rows)
if reveal:
self._reveal()
# a heading just above the first row shown comes into view with it
if self._scroll > 0 and rows[self._scroll - 1].kind == "header" and self.index == self._scroll:
self._scroll -= 1
def show(self, tab: str | None) -> None:
"""Goes to a tab, on the row it was left on."""
@@ -283,10 +305,10 @@ class Menu:
self.focus = "rows"
return None
if name == "up":
if self.index == 0:
if all(r.kind == "header" for r in rows[:self.index]):
self.focus = "tabs"
else:
self._select(self.index - 1, rows)
self._select(self.index - 1, rows, direction=-1)
elif name == "down":
self._select(self.index + 1, rows)
elif row.kind == "action":
@@ -381,7 +403,7 @@ class Menu:
if self._in(self._hit.get("close", (0, 0, 0, 0)), x, y):
self._hover = ("close",)
i = self._row_at(x, y)
if i is not None and (i != self.index or self.focus != "rows"):
if i is not None and self.rows()[i].kind != "header" and (i != self.index or self.focus != "rows"):
self.focus, self.armed = "rows", False
self._select(i, reveal=False)
@@ -490,7 +512,7 @@ class Menu:
self.focus = "rows"
return None
i = self._row_at(x, y)
if i is None:
if i is None or self.rows()[i].kind == "header":
self.armed = False
return None
rows = self.rows()
@@ -560,8 +582,8 @@ class Menu:
rows = self.rows()
self._follow(rows)
tabs = self.tabs()
W, pad = px(880), px(28)
head_h, tabs_h, row_h, help_h, foot_h = px(70), px(40), px(46), px(178), px(46)
W, pad = px(1100), px(32)
head_h, tabs_h, row_h, help_h, foot_h = px(72), px(42), px(44), px(150), px(46)
y_tabs = head_h + px(12)
y_rows = y_tabs + tabs_h + px(12)
y_help = y_rows + VISIBLE * row_h + px(12)
@@ -609,6 +631,11 @@ class Menu:
for i in range(self._scroll, min(len(rows), self._scroll + VISIBLE)):
row, ry = rows[i], y_rows + (i - self._scroll) * row_h
mid = ry + row_h // 2
if row.kind == "header": # a heading: small capitals in the accent, a rule after it
hy = ry + row_h - px(14)
tw = c.spaced(pad + px(8), hy, row.label.upper(), U.font(px(11), "bold"), U.ACCENT, px(1.6))
c.line(pad + px(8) + tw + px(12), hy, x1 - px(8), hy, U.BORDER, 1)
continue
selected = i == self.index
lit = selected and self.focus == "rows"
if selected:
+19 -6
View File
@@ -136,10 +136,8 @@ def rate_advice(game_fps: float | None, test: bool, even: bool = False) -> str:
if g <= 38:
return f"Simulate is for 60 fps games. This one is at {g} fps already: turn Simulate off (menu: M)"
return f"Simulate needs a steady 60 fps game. This one is at about {g}, so quality isn't measured"
if g <= 38 or (even and g <= 56):
if g <= 38 or (even and g <= 56) or g >= 55: # (a 60 fps game: frame generation works from 60)
return ""
if g >= 55:
return f"Game at {g} fps: no gaps to fill. Frame generation is for 30 fps modes (Quality/Fidelity)"
return f"Game at about {g} fps, not 30: few gaps to fill. Its 30 fps mode (Quality/Fidelity) is smoother"
@@ -375,6 +373,7 @@ class Pipeline:
When the pipeline is running behind, a tick skips the extra frame(s) and shows what 60 Hz would (the 1/2
frame, or B), so it never builds a backlog.
"""
game60 = False # a 60 fps game (Game frame rate 60, or Auto finding one): the multiplier works from 60
if settings is not None:
enabled, hz = settings.interp, settings.hz if sink is not None else 60
it, sched, st = self.interp, CadenceScheduler(), Stats(private=bool(getattr(self.interp, "private", False)))
@@ -513,7 +512,8 @@ class Pipeline:
st.stale += 1
continue
if settings is not None: # changed in the menu (or by a hotkey) since the last tick?
want_hz = settings.hz if sink is not None else 60
# The multiplier N is settings.hz / 30: N frames for each real one, so a 60 fps game shows 60 x N
want_hz = min(600, settings.hz * (2 if game60 else 1)) if sink is not None else 60
if want_hz != hz:
hz, gap, quarter_due, ov_next = want_hz, 0.95 / want_hz, False, 0.0
st.hz_used.add(hz)
@@ -656,8 +656,19 @@ class Pipeline:
timeline.set_at_arrival(dipping)
added = timeline.tick(is_new, is_cut, tick.frame, tick.t_arrival)
was_timed = timed
timed = dipping or (timeline.uneven and sink is not None and gt_fn is None
and (settings is None or getattr(settings, "even_out", True)))
# A 60 fps game: on the timeline too (each frame timed as it came, a frame of delay), which draws
# in-between frames at any output rate; the 60 Hz beat alone would only show its own frames.
was_60 = game60
game_fps = getattr(settings, "game_fps", "auto") if settings is not None else "auto"
game60 = (sink is not None and gt_fn is None
and (game_fps == "60" or (game_fps == "auto" and timeline.full)))
if game60 != was_60:
print(f"[pipeline] {'60 fps game: frame generation works from 60' if game60 else 'game no longer at 60 fps'}")
if game60 and hasattr(sink, "toast") and "60" not in toasted:
toasted.add("60")
sink.toast("Game at 60 fps: the frame multiplier works from 60 (2x is 120 fps)", 6.0)
timed = dipping or (sink is not None and gt_fn is None and (
game60 or (timeline.uneven and (settings is None or getattr(settings, "even_out", True)))))
if timed != was_timed:
if timed and dipping:
unshown = None
@@ -666,6 +677,8 @@ class Pipeline:
toasted.add("dips")
sink.toast("Game dipping below 30 fps: Summit is spacing its frames by when they "
"arrived (Dip smoothing)", 6.0)
elif timed and game60:
unshown = None # (said above)
elif timed:
unshown = None
print(f"[pipeline] game at about {timeline.fps()} fps: evening out its frames")
+86 -13
View File
@@ -9,6 +9,8 @@ offers "Restart now" when any are pending.
"""
from __future__ import annotations
import re
import json
import os
from dataclasses import dataclass, field
@@ -30,7 +32,9 @@ class Spec:
live: bool = True # applies immediately; False = on the next restart
help: str = ""
saved: bool = True # False: this session only, never written to the settings file (e.g. test modes)
group: str = "" # section on the launcher's Settings page; SPECS lists each section's rows together
group: str = "" # section on the launcher's Settings page and tab of the in-game overlay; SPECS lists each
# section's rows together
sub: str = "" # a heading inside its section (the overlay draws one where it changes)
quick: bool = False # one of the few big choices at the top of the launcher's Settings page
applies: tuple = () # (key, values): only used, and only shown, while setting `key` is one of `values`
later: str = "" # a note at the end of the launcher's dropdown, about choices that aren't offered yet
@@ -46,12 +50,16 @@ class Spec:
def name(self, value: Any) -> str:
if self.key == "hz" and value not in self.names and valid_hz(value): # a custom multiplier
return f"{value // 30}x ({value} fps)"
return f"{value // 30}x"
if self.key == "output_res" and value not in self.names and parse_res(value): # a custom size
w, h = parse_res(value)
return f"{w} x {h}"
return self.names.get(value, str(value))
def accepts(self, value: Any) -> bool:
"""One of the choices, or (Frame multiplier) any multiple of 30 fps that valid_hz takes."""
return value in self.choices or (self.key == "hz" and valid_hz(value))
return (value in self.choices or (self.key == "hz" and valid_hz(value))
or (self.key == "output_res" and parse_res(value) is not None))
def applies_to(self, values: dict) -> bool:
"""Whether this setting is used with these values (e.g. VFG quality only while NVIDIA VFG is picked)."""
@@ -64,6 +72,20 @@ class Spec:
return self.elsewhere.get(source) or self.elsewhere.get("") or "Not used with this source."
OUTPUT_SIZES = ("screen", "1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160")
OUTPUT_NAMES = {"screen": "Same as the screen", "1280x720": "720p", "1600x900": "900p", "1920x1080": "1080p",
"2560x1440": "1440p", "3200x1800": "1800p", "3840x2160": "4K"}
def parse_res(value) -> tuple[int, int] | None:
""" "2560x1440" -> (2560, 1440); None for "screen" or anything that isn't a sensible size."""
m = re.fullmatch(r"\s*(\d{3,5})\s*[xX×]\s*(\d{3,5})\s*", value) if isinstance(value, str) else None
if not m:
return None
w, h = int(m.group(1)), int(m.group(2))
return (w, h) if 320 <= w <= 7680 and 240 <= h <= 4320 else None
HZ_MIN, HZ_MAX = 60, 300 # Frame multiplier 2x .. 10x (of a 30 fps game)
@@ -88,14 +110,15 @@ SPECS: tuple[Spec, ...] = (
hints={False: "No new frames: the stream exactly as the game sends it, with the least delay."},
impact={"picture": "Smoother motion. Small, fast details can wobble a little.",
"speed": "Adds delay: about 20 ms at 60 fps, about 40 ms at 90 or 120 fps."},
help="Draws new frames between the ones the game sends, so a 30 fps game moves like 60, 90 or 120 fps. "
help="Draws new frames between the ones the game sends: a 30 fps game moves like 60 fps or more, a 60 fps "
"game like 120 or more (Frame multiplier). "
"Off shows the stream exactly as it arrives. In the video window, I turns it off and on for this "
"session only, to compare."),
# Frame generation's multiplier: N frames shown for each real frame of a 30 fps game, so N x 30 fps out (the value
# is that rate). Any multiple of 30 from 60 to 300 works (HZ_MIN..HZ_MAX: `--hz`, a game's Summit profile); the
# menu steps through these.
Spec("hz", "Frame multiplier", (60, 90, 120, 150, 180, 240), 60,
{hz: f"{hz // 30}x ({hz} fps)" for hz in (60, 90, 120, 150, 180, 240)},
{hz: f"{hz // 30}x" for hz in (60, 90, 120, 150, 180, 240)},
group="Smoothness", quick=True,
hints={60: "One new frame for each real one. Any supported graphics card, any display. Adds about 20\u00a0ms of delay.",
90: "Two new frames for each real one. Needs a 90\u00a0Hz or faster display. Adds about 40\u00a0ms of "
@@ -105,7 +128,8 @@ SPECS: tuple[Spec, ...] = (
150: "Four for each real one. Needs a 144\u00a0Hz or faster display and a fast card.",
180: "Five for each real one. Needs a 180\u00a0Hz or faster display and a very fast card.",
240: "Seven for each real one. Needs a 240\u00a0Hz display and a very fast card."},
help="How many frames you see for each one the game draws (of a 30 fps game: 2x is 60 fps, 4x is 120). "
help="How many frames you see for each one the game draws: 2x makes a 30 fps game 60 fps and a 60 fps game "
"120 fps; 4x makes them 120 and 240. "
"Higher is smoother, but needs a faster graphics card and a display that runs at least that fast "
"(G-Sync or FreeSync helps). When the card can't keep up, the extra frames are left out for a moment."),
# framegen/cadence.py FrameTimeline. Tried on simulated 40-55 fps games (tests/test_timeline.py), not a real one yet.
@@ -119,14 +143,17 @@ SPECS: tuple[Spec, ...] = (
"speed": "About one frame (17 ms) more delay than showing their frames as they come."}),
# framegen/cadence.py RhythmLock. Auto reads the game's frame rate from the stream (sizes, the picture), which a
# still or dark scene can fool (Gotham Knights, locked at 30, read as 38-47 fps on PS5 Remote Play).
Spec("game_fps", "Game frame rate", ("auto", "30"), "auto", {"auto": "Auto", "30": "30 fps"}, group="Smoothness",
Spec("game_fps", "Game frame rate", ("auto", "30", "60"), "auto", {"auto": "Auto", "30": "30 fps", "60": "60 fps"},
group="Frame generation", sub="Basics", quick=True,
applies=("interp", (True,)),
hints={"auto": "SmoovPlay works out the game's frame rate as it plays. The default.",
"30": "For a game locked at 30\u00a0fps. Every other frame is taken as new, so nothing can misread it."},
help="Auto works out the game's frame rate from the stream as it plays. A still or dark scene can fool it "
"into reading a 30 fps game as 40 or more, which makes motion uneven. If you know the game is locked "
"at 30 fps (most console quality modes), pick 30 fps: every other frame is taken as new, so motion "
"stays even. Menus that run at 60 fps look a little less smooth with it.",
hints={"auto": "Summit works out the game's frame rate as it plays. The default.",
"30": "For a game locked at 30\u00a0fps. Every other frame is taken as new, so nothing can misread it.",
"60": "For a game locked at 60\u00a0fps: the multiplier works from 60, so 2x is 120\u00a0fps."},
help="Auto works out the game's frame rate from the stream as it plays (a game at about 60 fps is taken as one "
"after a second there). A still or dark scene can fool it into reading a 30 fps game as 40 or more, "
"which makes motion uneven. If you know the game is locked at 30 fps (most console quality modes), pick "
"30 fps: every other frame is taken as new. A game locked at 60 fps: pick 60 fps, and the multiplier "
"works from 60 (2x is 120 fps, 3x 180), with very little extra delay.",
impact={"picture": "Even motion in a game locked at 30 fps, whatever the scene.",
"speed": "None. At most one frame (17 ms) later for a moment after the game stutters."}),
# framegen/cadence.py DipWatch + FrameTimeline.at_arrival. Tried on simulated 30 fps games that hold frames for 3 or
@@ -221,6 +248,19 @@ SPECS: tuple[Spec, ...] = (
"speed": "Each step up asks more of the GPU."}),
# framegen/hdr.py. Off by default, and then nothing changes: an HDR stream comes out washed out, and SmoovPlay says
# so. "hdr10" needs the DXGI presentation (NVIDIA) and Windows' HDR; without them run.py uses "sdr" for the session.
# framegen/io.py: the picture is upscaled to this size, then fitted to the window or screen (Fill the screen)
Spec("output_res", "Output resolution", OUTPUT_SIZES, "screen", OUTPUT_NAMES, group="Upscaling", sub="Output", quick=True,
hints={"screen": "The upscaler works straight to the screen's (or window's) size. The default.",
"1920x1080": "Upscaled to 1080p, then shown on the screen. Lighter on a 1440p or 4K screen.",
"2560x1440": "Upscaled to 1440p, then shown on the screen.",
"3840x2160": "Upscaled to 4K, then shown on the screen: on a smaller screen this sharpens (supersampling)."},
help="The size the upscaler makes the picture, whatever the screen's size. Same as the screen: it upscales "
"straight to it. A smaller size is lighter for the graphics card (RTX VSR especially) and is then "
"stretched to the screen; a bigger one is supersampling, shrunk to the screen afterwards, which looks "
"sharper. The picture keeps its shape either way. Any size can be given on the command line "
"(--output-res 2560x1080) or in Summit's game profile.",
impact={"picture": "Smaller: softer. Bigger than the screen: sharper (supersampling).",
"speed": "The upscaler's cost grows with the size: RTX VSR at 4K costs about 4x what it does at 1080p."}),
Spec("hdr", "HDR", ("off", "sdr", "hdr10"), "off",
{"off": "Off", "sdr": "On, shown in SDR", "hdr10": "On, HDR output"}, live=False,
group="Picture", experimental=True,
@@ -401,6 +441,39 @@ SPECS: tuple[Spec, ...] = (
"60 and 120 fps each AI frame is also scored against the real frame it replaced. This session "
"only."),
)
# Where each setting goes: (tab, heading, keys in order). The in-game overlay draws a tab for each, with the
# headings inside; the launcher's Settings page uses the tabs as its sections. A setting not listed keeps its own.
LAYOUT: tuple[tuple[str, str, tuple[str, ...]], ...] = (
("Frame generation", "Basics", ("interp", "hz", "game_fps")),
("Frame generation", "AI model", ("model", "vfg_quality", "motion", "engine")),
("Frame generation", "Smoothing", ("even_out", "even_dips", "steady_hud")),
("Upscaling", "Upscaler", ("scaler", "fsr_sharpness", "vsr_quality")),
("Upscaling", "Output", ("output_res", "fill")),
("Display", "Window", ("fullscreen", "vsync", "present")),
("Display", "Colour and look", ("hdr", "look_on", "look")),
("Overlay", "Stats", ("overlay", "overlay_style", "overlay_corner", "overlay_scale", "overlay_opacity")),
("Overlay", "Graphs", ("graph_frametime", "graph_pipeline", "graph_delay", "graph_gpu")),
("Overlay", "This menu", ("ui_scale", "ui_opacity")),
("Overlay", "Branding", ("watermark",)),
("Clips", "Instant replay", ("replay", "replay_clip")),
("Clips", "Saved clips", ("replay_save", "replay_layout", "look_clips")),
("Sources", "Capture card", ("capture_size",)),
("Sources", "PS5 Remote Play", ("minimize_chiaki", "audio_sync")),
("Sources", "Testing", ("simulate_30",)),
)
def _laid_out(specs: tuple[Spec, ...]) -> tuple[Spec, ...]:
from dataclasses import replace
by = {s.key: s for s in specs}
out: list[Spec] = []
for group, sub, keys in LAYOUT:
out.extend(replace(by[k], group=group, sub=sub) for k in keys if k in by)
placed = {s.key for s in out}
return tuple(out) + tuple(s for s in specs if s.key not in placed)
SPECS = _laid_out(SPECS)
BY_KEY = {s.key: s for s in SPECS}
+12 -3
View File
@@ -63,7 +63,7 @@ from framegen.interpolator import MODELS, RifeInterpolator
from framegen.io import (TICK, CaptureSource, FileSink, FileSource, GLWindowSink, MultiSink, Ps5SimSource,
WindowSink)
from framegen.pipeline import Pipeline
from framegen.settings import BY_KEY, DEFAULT_PATH, SPECS, Settings, valid_hz
from framegen.settings import BY_KEY, DEFAULT_PATH, SPECS, Settings, parse_res, valid_hz
from framegen.sources import TestMode, make_detector
from framegen.vfg import vfg_unavailable
@@ -292,6 +292,7 @@ def main() -> int:
ap.add_argument("--realtime", action="store_true", help="pace file input at 60 Hz like a capture card")
ap.add_argument("--max-ticks", type=int)
ap.add_argument("--hitch", type=float, default=0.0, help="[sim] probability a game frame is held 3 ticks")
ap.add_argument("--sim60", action="store_true", help="[sim] play a 60 fps file as a 60 fps game (testing)")
ap.add_argument("--noise", type=float, default=0.0, help="[sim] gaussian noise sigma added per tick")
ap.add_argument("--model", default=None, choices=list(MODELS) + ["vfg"],
help="RIFE version, or vfg for NVIDIA VFG (default: the saved setting, 4.22.lite). The other "
@@ -345,6 +346,12 @@ def main() -> int:
help="output rate, the frame multiplier for a 30 fps game: 60 (2x), 90 (3x), 120 (4x) ... 300 "
"(10x), any multiple of 30. Above 60 needs --display; the extra frames are left out for a "
"moment whenever it can't keep up")
ap.add_argument("--game-fps", default=None, choices=["auto", "30", "60"],
help="the game's frame rate: auto (worked out as it plays), 30 or 60 (then the frame multiplier "
"works from 60: 2x is 120 fps)")
ap.add_argument("--output-res", default=None, metavar="WxH",
help="output resolution: the upscaler makes the picture at this size (e.g. 2560x1440), then it is "
"fitted to the window or screen; 'screen' (the default) upscales straight to the screen")
ap.add_argument("--display-cv", action="store_true", help="use the (slow) OpenCV window instead of OpenGL")
ap.add_argument("--out", help="write output video")
ap.add_argument("--score", action="store_true", help="[sim] PSNR of interpolated frames vs real dropped frames")
@@ -356,6 +363,8 @@ def main() -> int:
help="when test mode (a simulated 30 fps game) or --score was used, write a plain-language report "
"of performance and quality here: every 10 s while playing, and at the end")
a = ap.parse_args()
if a.output_res is not None and a.output_res != "screen" and parse_res(a.output_res) is None:
ap.error(f"--output-res {a.output_res}: a size like 2560x1440 (320x240 to 7680x4320), or 'screen'")
if a.hz is not None and not valid_hz(a.hz):
ap.error(f"--hz {a.hz}: a multiple of 30 from 60 to 300 (the frame multiplier 2x to 10x)")
if a.monitor:
@@ -439,13 +448,13 @@ def main() -> int:
return 1
elif kind == "file" and a.video:
src = (FileSource(a.video, a.realtime, a.max_ticks, test=test) if a.raw else
Ps5SimSource(a.video, a.realtime, a.hitch, a.noise, a.max_ticks))
Ps5SimSource(a.video, a.realtime, a.hitch, a.noise, a.max_ticks, game60=a.sim60))
else:
ap.error("give a video file, --capture N or --chiaki")
print(f"[run] source: {src.info.name}")
settings = Settings() if a.settings.lower() == "none" else Settings.load(Path(a.settings))
for key, value in (("hz", a.hz), ("scaler", a.scaler), ("vsr_quality", a.vsr_quality),
for key, value in (("hz", a.hz), ("game_fps", a.game_fps), ("output_res", a.output_res), ("scaler", a.scaler), ("vsr_quality", a.vsr_quality),
("fsr_sharpness", a.fsr_sharpness), ("engine", "trt" if a.trt else a.engine),
("interp", False if a.off else None), ("vsync", a.vsync), ("fullscreen", a.fullscreen),
("minimize_chiaki", a.minimize_chiaki), ("simulate_30", True if a.test_mode else None),
+21 -2
View File
@@ -32,8 +32,27 @@ def test_settings_take_any_multiple_of_30_from_2x_to_10x():
assert not any(valid_hz(h) for h in (30, 100, 330, True, "120", 120.0))
s = Settings()
s.override("hz", 210) # 7x, not a menu choice
assert s.hz == 210 and BY_KEY["hz"].name(210) == "7x (210 fps)"
assert s.hz == 210 and BY_KEY["hz"].name(210) == "7x"
with pytest.raises(ValueError):
s.override("hz", 100)
assert s.step("hz", 1) == 240 and s.step("hz", -1) == 180 # from a custom value, to the menu's neighbours
assert BY_KEY["hz"].name(120) == "4x (120 fps)"
assert BY_KEY["hz"].name(120) == "4x"
def test_a_steady_60_fps_game_is_found_and_left_again():
from framegen.cadence import UNEVEN_DWELL, FrameTimeline
t = FrameTimeline()
for _ in range(60 + UNEVEN_DWELL + 1): # a second to count, then a second there
t.tick(True)
assert t.full and t.delay <= 1.1 # at most about a frame of delay (steady frames need next to none)
for k in range(60 + UNEVEN_DWELL + 1): # 30 fps: new every other tick
t.tick(k % 2 == 0)
assert not t.full
def test_a_short_60_fps_burst_isnt_a_60_fps_game():
from framegen.cadence import FrameTimeline
t = FrameTimeline()
for n in range(240): # a 30 fps game with a 60 fps menu for half a second
t.tick(n % 2 == 0 or 100 <= n < 130)
assert not t.full
+43 -18
View File
@@ -87,7 +87,7 @@ def test_quit_is_a_row_and_asks_twice():
def test_home_has_the_big_choices_and_the_performance_overlay():
m = menu()
keys = [r.key for r in m.rows()]
assert keys[:3] == ["interp", "hz", "scaler"] and PERF in keys and "clip" not in keys
assert keys[:5] == ["interp", "hz", "game_fps", "scaler", "output_res"] and PERF in keys and "clip" not in keys
m.settings.override("replay", 60)
assert "clip" in [r.key for r in m.rows()]
m.index = [r.key for r in m.rows()].index("clip")
@@ -96,7 +96,7 @@ def test_home_has_the_big_choices_and_the_performance_overlay():
def test_arrows_tabs_and_values():
m = menu()
assert m.tabs()[0] is None and "Smoothness" in m.tabs() and "Picture" in m.tabs()
assert m.tabs()[0] is None and "Frame generation" in m.tabs() and "Upscaling" in m.tabs()
assert m.key("right") is None and m.settings.interp is False # Left and Right change the value
m.key("left")
assert m.settings.interp is True
@@ -122,19 +122,42 @@ def test_arrows_tabs_and_values():
def test_each_tab_keeps_its_row_and_long_tabs_scroll():
m = menu()
m.show("Display")
m.show("Frame generation")
n = len(m.rows())
assert n > VISIBLE
assert m.rows()[0].kind == "header" and m.index == 1 # a tab opens on its first setting, under its heading
for _ in range(n + 3):
m.key("down")
assert m.index == n - 1 and m._scroll == n - VISIBLE # stops at the end, scrolled to it
assert all(m.rows()[i].kind != "header" for i in [m.index])
left = m.rows()[m.index].key
m.show("Picture")
assert m.index == 0
m.show("Display")
m.show("Upscaling")
assert m.index == 1
m.show("Frame generation")
assert m.rows()[m.index].key == left
def test_headings_are_skipped_by_the_keys_and_the_mouse():
m = menu()
m.show("Frame generation")
rows = m.rows()
seen = []
for _ in range(len(rows)):
seen.append(m.index)
m.key("down")
assert all(rows[i].kind != "header" for i in seen)
while m.focus == "rows":
m.key("up")
assert m.focus == "tabs" # Up from the first setting (past its heading) goes to the tabs
m.focus = "rows"
m.render(1.0)
h = next(i for i, r in enumerate(m.rows()) if r.kind == "header" and i >= m._scroll)
y = m._hit["rows"][1] + (h - m._scroll + 0.5) * m._hit["row_h"]
before = m.index
m.hover(200, y)
assert m.index == before and m.click(200, y) is None and m.index == before
def test_performance_overlay_row_sets_both_settings():
m = menu()
row = next(r for r in m.rows() if r.kind == PERF)
@@ -162,7 +185,7 @@ def test_rows_that_cant_be_used_stay_put():
def test_over_a_game_the_help_names_no_one_letter_keys():
row = lambda m: next(r for r in m.tab_rows("Picture") if r.key == "scaler") # noqa: E731
row = lambda m: next(r for r in m.tab_rows("Upscaling") if r.key == "scaler") # noqa: E731
video, game = Menu(Settings()), Menu(Settings(), window_keys=False)
assert "Key: U." in video._help(row(video))[0]
text = game._help(row(game))[0]
@@ -197,11 +220,11 @@ def test_render_is_a_rounded_see_through_panel():
m.status = ("good", "118 fps", "game 60")
img = m.render(1.0, 0.8)
h, w = img.shape[:2]
assert img.shape[2] == 4 and w == 880 and 600 < h < 900
assert img.shape[2] == 4 and w == 1100 and 600 < h < 900
assert img[0, 0, 3] == 0 and img[-1, -1, 3] == 0 # outside the rounded corners
assert img[h // 2, 3, 3] > 0 and img[..., 3].max() == 255 # the panel, and solid text on it
assert 190 < img[h - 30, w // 2, 3] < 255 # its background lets some of the game through
assert m.render(0.5, 1.0).shape[1] == 440
assert m.render(0.5, 1.0).shape[1] == 550
assert m.render(1.0, 1.0)[h - 30, w // 2, 3] == 255
@@ -219,8 +242,8 @@ def test_clicks_pick_tabs_choices_and_close():
m = menu()
m.render(1.0)
hit = m._hit
box = hit["tabs"][m.tabs().index("Picture")]
assert m.click(box[0] + 5, box[1] + 5) is None and m.tab == "Picture"
box = hit["tabs"][m.tabs().index("Upscaling")]
assert m.click(box[0] + 5, box[1] + 5) is None and m.tab == "Upscaling"
m.show(None)
m.render(1.0)
hz_row = [r.key for r in m.rows()].index("hz")
@@ -239,9 +262,9 @@ def test_clicks_pick_tabs_choices_and_close():
assert m.settings.interp is True
c = m._hit["close"]
assert m.click(c[0] + 2, c[1] + 2) == "close"
tab_box = m._hit["tabs"][m.tabs().index("Picture")]
tab_box = m._hit["tabs"][m.tabs().index("Upscaling")]
m.hover(tab_box[0] + 5, tab_box[1] + 5)
assert m._hover == ("tab", m.tabs().index("Picture"))
assert m._hover == ("tab", m.tabs().index("Upscaling"))
def test_stats_toast_and_graphs_draw():
@@ -265,7 +288,8 @@ def test_stats_toast_and_graphs_draw():
# ---- a window for the mouse ---------------------------------------------------------------------------------------
def long_tab(m: Menu) -> str:
"""A tab with more rows than fit, so it scrolls."""
"""A tab with more rows than fit, so it scrolls (Overlay, with the graph settings showing)."""
m.settings.override("overlay_style", "graphs")
for tab in sorted(m.sections(), key=lambda t: -len(m.tab_rows(t))):
if len(m.tab_rows(tab)) > VISIBLE + 2:
return tab
@@ -276,9 +300,10 @@ def test_the_wheel_scrolls_the_page_not_the_highlight():
m = menu()
m.show(long_tab(m))
m.render(1.0)
m.index = 0
m._select(0, reveal=False) # (row 0 is a heading: the first setting under it)
first = m.index
m.scroll(-1)
assert m._scroll == 1 and m.index == 0 # the page moved; the highlighted row is the same one
assert m._scroll == 1 and m.index == first # the page moved; the highlighted row is the same one
m.scroll(-0.4)
m.scroll(-0.4)
assert m._scroll == 1 # a touchpad's small steps wait until they make a row...
@@ -287,7 +312,7 @@ def test_the_wheel_scrolls_the_page_not_the_highlight():
m.scroll(+50)
assert m._scroll == 0 # ...and the page stops at its ends
m.key("down")
assert m.index == 1
assert m.index == first + 1
def test_the_scrollbar_drags_and_the_title_bar_moves_the_window():
@@ -349,7 +374,7 @@ def test_sliders_drag_and_long_lists_drop_down():
def test_slider_keys_go_the_way_the_slider_does():
m = menu()
m.show("Display")
m.show("Overlay")
rows = m.rows()
op = next(r for r in rows if r.key == "ui_opacity") # stored 100% .. 30%, drawn 30% .. 100%
assert m.kind_of(op) == "slider" and m.ordered(op) == sorted(m.choices(op))