"""User settings: one registry (SPECS) that the in-video menu, the launcher's Settings page, the command line and the saved file all share. To add a setting: add a Spec here, then read `settings.` where it matters (or `settings.watch(fn)` to hear about changes). `live=False` settings are saved at once but take effect at the next in-app restart; the menu offers "Restart now" when any are pending. `python -m framegen.settings` prints the registry as JSON for the launcher (specs_json()), so it never keeps a copy. """ from __future__ import annotations import re import json import os from dataclasses import dataclass, field from pathlib import Path from typing import Any, Callable from . import aa, compare, fill, looks, oslayer, stats DEFAULT_PATH = oslayer.config_dir() / "settings.json" # %APPDATA%\\framegen (Windows), ~/.config/smoovplay (Linux) @dataclass(frozen=True) class Spec: key: str label: str choices: tuple default: Any names: dict = field(default_factory=dict) # value -> text shown; missing values are shown as str(value) 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 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` also: tuple = () # (key, values): a second such condition (both must hold) later: str = "" # a note at the end of the launcher's dropdown, about choices that aren't offered yet hints: dict = field(default_factory=dict) # value -> a line under that choice in the launcher's dropdown (only # there, so no-break spaces keep "90 Hz" together; the in-video menu's font can't draw them, so help has none) impact: dict = field(default_factory=dict) # "picture" and/or "speed": a rough line on what it does to the picture # and to speed or delay, shown in the launcher and the in-video menu (plain ASCII). Numbers are measured (IMPACT_PC). experimental: bool = False # built without the hardware (or a real game) to test it: tagged as Experimental in the # launcher (with Send feedback) and in the in-video menu sources: tuple = () # only used with these sources (framegen/sources.py kinds; () = all). With another one, the # launcher (for the source picked on its Play page) and the in-video menu (run.py) grey it out, with its note: elsewhere: dict = field(default_factory=dict) # source kind -> why it isn't used there ("": any other source) 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" 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)) 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).""" return ((not self.applies or values.get(self.applies[0]) in self.applies[1]) and (not self.also or values.get(self.also[0]) in self.also[1])) def unused_with(self, source: str) -> str | None: """Why this setting isn't used with frames from `source` (a framegen/sources.py kind), or None if it is.""" if not self.sources or source in self.sources: return None 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) def valid_hz(value: Any) -> bool: """An output rate the pipeline can show: a whole multiplier (2x to 10x) of a 30 fps game.""" return isinstance(value, int) and not isinstance(value, bool) and HZ_MIN <= value <= HZ_MAX and value % 30 == 0 def parse_set(text: str) -> tuple[str, Any]: """ "KEY=VALUE" from `run.py --set` (Summit's per-game profile): any setting of the registry by its key, with the value as JSON (true, 90, 0.5, "fsr"; a bare word is taken as a string). Raises ValueError with the reason when the key is unknown or the value is not one the setting accepts.""" key, sep, raw = text.partition("=") key = key.strip() if not sep or key not in BY_KEY: raise ValueError(f"{text!r}: KEY=VALUE with a setting's key (python -m framegen.settings lists them)") spec = BY_KEY[key] try: tries = [json.loads(raw), raw.strip()] except ValueError: tries = [raw.strip()] for value in tries: if isinstance(value, bool) != isinstance(spec.default, bool): # JSON true is not the number 1 here continue if isinstance(value, int) and isinstance(spec.default, float): value = float(value) if spec.accepts(value): return key, value raise ValueError(f"{key}: {raw.strip()!r} is not one of {spec.choices}") ON_OFF = {True: "On", False: "Off"} def _compare_specs() -> tuple: """The Compare tab (framegen/compare.py): Compare itself starts off each session; the rest is saved.""" strips = [] for d in compare.DIMENSIONS: for i in range(1, compare.MAX_STRIPS[d] + 1): where = ("left", "right") if i <= 2 else ("",) strips.append(Spec( compare.strip_key(d, i), f"Strip {i}", compare.VARIANTS[d], compare.DEFAULTS[d][i - 1], compare.NAMES[d], group="Compare", applies=("compare_dim", (d,)), also=("compare_strips", tuple(n for n in (2, 3, 4) if n >= i)), help=f"What strip {i} shows ({'from the ' + where[i - 1] if i <= 2 else 'counting from the left'}, " "or from the top when stacked). A choice this PC can't show gets a black strip saying why.")) return ( Spec("compare", "Compare", (False, True), False, ON_OFF, saved=False, group="Compare", help="Cuts the picture into strips, each drawn with a different choice of one setting, with its name " "and its measured cost per frame. Key: C (Shift+C: the next thing to compare; A: Same area; Space: " "Freeze; hold V: Flip). Starts off each session."), Spec("compare_dim", "What to compare", compare.DIMENSIONS, "aa", compare.DIM_NAMES, group="Compare", help="Anti-aliasing, the upscaler, frame generation (the game's own frames against generated ones, " "live, to see the smoothness) or the look."), Spec("compare_strips", "Strips", (2, 3, 4), 4, group="Compare", help="How many choices side by side. Look has two (off and on); a 2-strip divider can be dragged with " "the mouse."), *strips, Spec("compare_layout", "Layout", compare.LAYOUTS, "columns", compare.LAYOUT_NAMES, group="Compare", help="Side by side: vertical strips of one picture. Stacked: horizontal strips. Same area: the picture " "in one cell per strip (halves, thirds or 2x2); pick one, and every cell shows that area, each " "with its own choice, to look closely. Key: A."), Spec("compare_cell", "Area", compare.CELLS, "pick", compare.CELL_NAMES, saved=False, group="Compare", applies=("compare_layout", ("grid",)), help="The area every cell shows: a cell's number (left to right, then down), Free (a box moved with the " "mouse, or by clicking this map), or Pick to choose again on the picture. Key: Enter (click, or " "the arrows and Enter, to pick)."), Spec("compare_zoom", "Zoom", compare.ZOOMS, 1, {z: compare.zoom_name(z) for z in compare.ZOOMS}, saved=False, group="Compare", applies=("compare_layout", ("grid",)), help="How much the area is enlarged, 1x (pixel for pixel) to 8x, by whole pixels (nearest neighbour: " "no smoothing that would hide a difference). Keys: the mouse wheel, + and -."), Spec("compare_split", "Divider", compare.SPLITS, 0.5, {v: f"{round(v * 100)}%" for v in compare.SPLITS}, saved=False, group="Compare", applies=("compare_strips", (2,)), also=("compare_layout", ("columns", "rows")), help="Where the line between two strips is. The mouse can drag it too."), Spec("compare_freeze", "Freeze", (False, True), False, ON_OFF, saved=False, group="Compare", help="Holds one game frame, so anti-aliasing, the upscaler or the look can be studied on the same still " "(the game goes on underneath). Frame generation can't be frozen: its strips differ only in " "motion. Key: Space."), Spec("compare_flip", "Flip", compare.FLIPS, "off", compare.FLIP_NAMES, saved=False, group="Compare", help="With two strips: the whole picture with strip 1 (A) or strip 2 (B), to flip between them. Key: " "hold V for A, let go for B; Esc goes back to the split."), Spec("compare_labels", "Labels", (True, False), True, ON_OFF, group="Compare", help="Each strip's name at its top (or bottom)."), Spec("compare_labels_at", "Labels at", compare.LABEL_PLACES, "top", {"top": "Top", "bottom": "Bottom"}, group="Compare", applies=("compare_labels", (True,)), help="Where the labels go: at the bottom when the game's own HUD is at the top."), Spec("compare_timings", "Timings", (True, False), True, ON_OFF, group="Compare", help="Under each name: its measured cost per frame, average / worst over the last 120 frames, in ms."), Spec("compare_clips", "Compare in clips", (False, True), False, ON_OFF, group="Compare", help="Saved clips with the strips, labels and dividers burned in. Anti-aliasing and frame generation " "only: clips are saved at the game's size, before the upscaler and the look."), ) OPACITY = (1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3) # menu and stats opacity choices PCT = {v: f"{round(v * 100)}%" for v in OPACITY} PCT_SIZE = {v: f"{round(v * 100)}%" for v in (0.6, 0.75, 0.9, 1.0, 1.25, 1.5, 2.0)} CAPTURE_SIZES = {"1080p": (1920, 1080), "1440p": (2560, 1440), "2160p": (3840, 2160)} # Capture card resolution IMPACT_PC = "an RTX 4070 Ti SUPER" # where the numbers in `impact` and the hints were measured # scripts/looks_timing.py: GPU time of the built-in looks on a 1440p window (0.02 to 0.34 ms) and at 1080p for clips # (0.01 to 0.19 ms), measured while chiaki-ng streamed. LOOK_SPEED = "About 0.02 to 0.35 ms a frame of graphics card time for SmoovPlay's looks (1440p)." LOOK_CLIPS_SPEED = "Up to about 0.2 ms more a frame of graphics card time, to draw it again at 1080p." STAT_CHOICES = ("auto", "on", "off") STAT_NAMES = {"auto": "Style's own", "on": "Show", "off": "Hide"} # One row per number the stats overlay can show (framegen/stats.py ITEMS): the style's own list, or always, or never. STAT_SPECS = tuple( Spec("stat_" + k, label, STAT_CHOICES, "auto", STAT_NAMES, group="Display", applies=("overlay_style", ("minimal", "detailed", "bar")), help=text + " Style's own: shown or not as the style decides; Show and Hide override it.") for k, (label, text) in stats.ITEMS.items()) SPECS: tuple[Spec, ...] = ( Spec("interp", "Frame generation", (True, False), True, ON_OFF, group="Smoothness", quick=True, 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: 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" 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 " "delay.", 120: "Three for each real one. Needs a 120\u00a0Hz display and a fast card. Adds about 40\u00a0ms of " "delay.", 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: 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. Spec("even_out", "Even out 40-60 fps", (True, False), True, ON_OFF, group="Smoothness", applies=("interp", (True,)), help="For games that run between about 40 and 60 fps, like unlocked performance modes. Their frames " "arrive unevenly, some staying on screen twice as long as others, so motion stutters. SmoovPlay " "times each one and draws evenly spaced frames from them at 60, 90 or 120 fps. 30 fps and 60 fps " "games aren't affected. Experimental: not tried with a real game yet.", impact={"picture": "Even motion in 40-60 fps games, instead of stutter.", "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", "60"), "auto", {"auto": "Auto", "30": "30 fps", "60": "60 fps"}, group="Frame generation", sub="Basics", quick=True, applies=("interp", (True,)), 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 # 4 ticks (tests/test_dips.py, scratchpad numbers in notes/backlog.md), not a real one yet. Off by default: it adds # delay while the game dips. Spec("even_dips", "Dip smoothing", (False, True), False, ON_OFF, group="Smoothness", applies=("interp", (True,)), experimental=True, help="For 30 fps games that sometimes drop below 30, as some big open-world games do on a base console. " "At each dip a frame stays up longer and the next one jumps. With this on, SmoovPlay spaces the " "frames it draws by when the game's frames arrived, so a dip looks like a brief slow-down instead. " "It's only on while the game dips, and adds delay then.", impact={"picture": "A dip below 30 fps looks like a brief slow-down, not a freeze and a jump.", "speed": "While it dips: 17 to 50 ms more delay, and more graphics card work."}), # RIFE: only the model SmoovPlay is tuned and tested with (setup prepares it). interpolator.MODELS has more, for # testing with run.py --model; one becomes a choice here once it's tested in real time and setup prepares it. # NVIDIA VFG (framegen/vfg.py): offered once the user has set it up on the launcher's Settings page. Its licence # forbids publishing benchmark results, so nothing here compares its speed or quality with RIFE's. Spec("model", "Interpolation model", ("4.22.lite", "vfg"), "4.22.lite", {"4.22.lite": "RIFE 4.22 lite", "vfg": "NVIDIA VFG"}, live=False, group="Smoothness", quick=True, later="Support for other interpolation models may come in a later version.", hints={"4.22.lite": "Fast and tested. The default.", "vfg": "NVIDIA's own frame generation, for RTX 40 and 50 series cards. A separate download " "from NVIDIA."}, help="The AI model that draws the in-between frames. RIFE 4.22 lite is the one SmoovPlay is tuned and " "tested with, fast enough for 90 and 120 fps. NVIDIA VFG (Video Frame Generation) is NVIDIA's own, " "for RTX 40 and 50 series cards: SmoovPlay's Settings page downloads it from NVIDIA once you accept " "NVIDIA's licence."), Spec("vfg_quality", "VFG quality", ("low", "medium", "high"), "medium", {"low": "Low", "medium": "Medium", "high": "High"}, live=False, group="Smoothness", applies=("model", ("vfg",)), hints={"low": "The lightest on your graphics card.", "medium": "Balanced. The default.", "high": "The most careful, and the heaviest."}, help="How much work NVIDIA VFG puts into each in-between frame. Higher takes more of your graphics " "card's time, which can cost in-between frames at 90 and 120 fps. Only used with NVIDIA VFG."), # v2 (near edges only, interpolator._steady): on eight 60 fps gameplay clips (scripts/steady_hud_eval.py) it fixes # 96% of the visibly wobbling HUD pixels for 0.06 dB over the whole frame, at about 0.5 ms per real frame plus # 0.15 per AI frame. On three sections of PS5 GTA V it cost 0.1 to 1.2 dB over the whole frame. Off by default: # judged by eye (scripts/steady_hud_compare.py), RIFE alone looked as good. # framegen/steady.py, after RIFE or NVIDIA VFG alike (with VFG, each in-between frame is also converted to apply it). Spec("steady_hud", "Steady HUD", (False, True), False, ON_OFF, group="Smoothness", applies=("model", ("4.22.lite", "vfg")), help="Keeps the parts of the picture that don't move, like the map, health bar and subtitles, exactly as " "the game drew them, so they don't wobble when the scene behind them moves. Results vary by game, and " "often there's no visible difference. If a small, fast object ever flickers, turn it off.", impact={"picture": "Steadier HUD in some games; in others, slightly worse elsewhere.", "speed": "About 0.5 ms more work per real frame, and a little more delay."}), Spec("engine", "AI engine", ("auto", "trt", "torch"), "auto", {"auto": "Auto", "trt": "TensorRT", "torch": "PyTorch"}, live=False, group="Smoothness", applies=("model", ("4.22.lite",)), hints={"auto": "The faster one for your settings. Recommended.", "trt": "Fastest at full motion detail. Its first start on a graphics card takes a minute or two.", "torch": "Starts at once. Fastest at half motion detail."}, help="The software that runs the AI model on your graphics card. Both draw the same frames; only the " "speed differs. Auto uses TensorRT at full motion detail, where it's about 12% faster, and PyTorch " "at half, where PyTorch is faster. Only used with RIFE.", impact={"picture": "None: both draw the same frames.", "speed": "TensorRT is about 12% faster at full motion detail, PyTorch at half."}), Spec("motion", "Motion detail", ("auto", "full", "half"), "auto", {"auto": "Auto", "full": "Full", "half": "Half"}, live=False, group="Smoothness", applies=("model", ("4.22.lite",)), hints={"auto": "Full; Half at 120 fps or a 1440p capture at 90; less for 4K. Recommended.", "full": "Sharpest on fast motion. The slowest.", "half": "About 40% faster. A little softer on fast detail."}, help="How finely RIFE tracks movement. Full follows small, fast details best, like railings or distant " "cars; Half takes about 40% less time but softens them a little. Auto uses Half at 120 fps or for a " "1440p capture at 90, a quarter for a 4K capture, and Full otherwise. Only used with RIFE.", impact={"picture": "Half is a little softer on small, fast details.", "speed": "Half takes about 40% less time per AI frame."}), Spec("scaler", "Upscaler", ("off", "fsr", "vsr", "bilinear"), "fsr", {"off": "Off", "fsr": "AMD FSR 1", "vsr": "NVIDIA RTX VSR", "bilinear": "Bilinear"}, group="Picture", quick=True, later="Support for other upscalers may come in a later version.", hints={"fsr": "Sharp and almost free: about 0.1\u00a0ms a frame. Recommended.", "vsr": "NVIDIA's AI upscaler, Experimental. It comes with NVIDIA VFG's download (RTX 40 and 50 " "series); without it, FSR\u00a01 is used. Heavier.", "bilinear": "Plain resizing, the softest. For comparison.", "off": "No upscaling: the picture at its own size, in the middle of the screen. Never enlarged."}, help="Enlarges the picture from the game (usually 1080p) to fill your window or screen, so it only " "matters when that's bigger than 1080p, like a 1440p or 4K display. Key: U.", impact={"picture": "Only matters on a display bigger than the stream, like 1440p or 4K.", "speed": "About 0.1 ms a frame for FSR 1. RTX VSR runs an AI model on every frame, which can " "cost in-between frames at 90 and 120 fps."}), Spec("fsr_sharpness", "FSR sharpening", (0.0, 0.25, 0.5, 1.0, 2.0), 0.5, {0.0: "Max", 0.25: "High", 0.5: "Medium", 1.0: "Low", 2.0: "Minimal"}, group="Picture", applies=("scaler", ("fsr",)), hints={0.0: "Crispest. Can make compression blocks stand out.", 0.5: "Balanced. The default.", 2.0: "Softest. Best for a blocky, low-quality stream."}, help="How strongly FSR 1 sharpens the enlarged picture. More looks crisper; less keeps the blocky patches " "of a weak Wi-Fi stream from standing out. Only used with AMD FSR 1.", impact={"picture": "More is crisper; less keeps a blocky stream calmer.", "speed": "No difference."}), Spec("vsr_quality", "RTX VSR quality", (1, 2, 3, 4), 2, {1: "Low", 2: "Medium", 3: "High", 4: "Ultra"}, group="Picture", applies=("scaler", ("vsr",)), experimental=True, help="How hard RTX VSR works to clean up and sharpen the picture. Higher looks cleaner but asks more of the " "GPU, which can cost in-between frames at 90 and 120 fps. Only used with RTX VSR, which comes with " "NVIDIA VFG's download from NVIDIA. On a capture card's uncompressed picture it uses NVIDIA's models " "for clean video.", impact={"picture": "Higher is cleaner and sharper.", "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, hints={"off": "For a stream without HDR. The default.", "sdr": "Plays an HDR stream on any display, with its colours and brightness fitted to it.", "hdr10": "Keeps it HDR on an HDR display, with Use HDR on in Windows' display settings. Not yet " "tried on an HDR screen."}, help="Experimental: not yet tried with a real PS5 HDR stream, or on an HDR screen. For Remote Play in HDR, " "pick the H.265 HDR codec in chiaki-ng, then turn this on. Shown in SDR fits HDR to any display. HDR " "output keeps it HDR on a display with Use HDR on in Windows (without one, it's shown in SDR). A " "stream without HDR isn't changed. Applies the next time you press Play.", impact={"picture": "An HDR stream's true colours, instead of a washed-out picture.", "speed": "About 0.7 ms of graphics card time for each frame from the game."}), # run.py asks the card for this size (framegen/capture.py pick_mode: else the largest it has under it). Every new # frame is drawn at the size captured, so the cost grows with it: notes in the hints, measured by scripts/benchmark.py. Spec("capture_size", "Capture card resolution", tuple(CAPTURE_SIZES), "1080p", {"1080p": "1080p", "1440p": "1440p", "2160p": "4K"}, live=False, group="Picture", experimental=True, hints={"1080p": "The lightest: 60, 90 or 120 fps on a fast card. Recommended. The default.", "1440p": "About twice the work of 1080p: fine at 60 fps on most cards, but 90 can run sluggish. " "Sharper on a 1440p or 4K screen.", "2160p": "About four times the work of 1080p: likely to run sluggish, even at 60 fps on a fast card. " "Only for a 4K screen."}, help="Capture cards only (Remote Play is 1080p at most). Higher is sharper on a bigger screen, but every new " "frame is drawn at this size, so it can run quite sluggish. A capture bigger than your screen gains " "nothing. The console must send it too. Experimental; applies the next time you press Play.", impact={"picture": "Sharper on a 1440p or 4K screen; no gain on a 1080p one.", "speed": "1440p: about twice the work of 1080p. 4K: about four times. Both can run sluggish."}, sources=("capture",), elsewhere={"chiaki": "Only used with a capture card. PS5 Remote Play streams 1080p at most.", "window": "Only used with a capture card. App window capture is scaled to 1080p.", "tap": "Only used with a capture card. The app sends its frames at its own size.", "": "Only used with a capture card."}), # framegen/looks.py (the looks; "Which look" lists the built-in ones, then the user's, from looks.CHOICES, which # the looks library keeps up to date) and framegen/looks_gl.py (drawing them, after the upscaler). Spec("look_on", "Look", (False, True), False, ON_OFF, group="Looks", help="Effects on top of the picture, like a color grade, film grain or bloom: one of SmoovPlay's looks, or " "your own, made on SmoovPlay's Looks page. K turns the look on and off, J goes to the next one. Saved " "clips stay as the game looked unless Looks in clips is on.", impact={"picture": "Changes the colors and style of the picture, the way you choose.", "speed": LOOK_SPEED}), Spec("look", "Which look", looks.CHOICES, looks.DEFAULT_LOOK, looks.NAMES, group="Looks", applies=("look_on", (True,)), help="The look to use: SmoovPlay's own, then the ones you made or pasted on the Looks page. J goes to the " "next one, Shift+J back."), Spec("fullscreen", "Fullscreen", (False, True), False, ON_OFF, group="Display", help="Fills the whole screen. It also skips the Windows desktop compositor, which removes about 12 ms " "of delay, so it's the best way to play. Key: F.", impact={"speed": "About 12 ms less delay than a window, and G-Sync or FreeSync works."}), # framegen/fill.py. Consoles send 16:9 only, so on an ultrawide these are ways of laying out the same 16:9 picture, # never more of the game: the names, hints and help say so. Spec("fill", "Fill the screen", fill.FILLS, "fit", {"fit": "Fit", "zoom": "Zoom", "stretch": "Stretch", "panorama": "Panorama"}, group="Display", hints={"fit": "All of the picture, true to shape, with black bars on an ultrawide. The default.", "zoom": "Fills the screen by cutting off the top and bottom of the picture, which can cut the HUD.", "stretch": "Fills the screen by making everything wider.", "panorama": "The middle stays close to true shape and the sides take the stretch, like a TV's wide " "zoom. Ultrawide only."}, help="For an ultrawide screen. Consoles send 16:9 only, so none of these is real ultrawide: there's no more " "of the game to show. They crop or stretch the same 16:9 picture. Key: Z.", impact={"picture": "The same 16:9 picture, cropped or stretched: consoles send 16:9 only.", "speed": "No real difference. Panorama adds one pass over the screen: about 0.02 ms."}), Spec("vsync", "VSync", (False, True), False, ON_OFF, group="Display", help="Off: the lowest delay, but fast camera turns can show a tear line across the picture. On: no " "tearing, with a little more delay. With a G-Sync or FreeSync display, On gives you both: no tearing " "and low delay.", impact={"picture": "On: no tear lines.", "speed": "On can add up to one refresh of delay: 8 ms at 120 Hz, 17 at 60."}), # framegen/dxgi_present.py. Standard stays the default until Low delay has been measured on more PCs. Spec("present", "Window presentation", ("gl", "dxgi"), "gl", {"gl": "Standard", "dxgi": "Low delay (Experimental)"}, live=False, group="Display", applies=("fullscreen", (False,)), hints={"gl": "OpenGL's own way. Tested. In a window, Windows adds a copy of each frame.", "dxgi": "Hands frames over the way games do, so a window is about as quick as fullscreen and G-Sync " "works. Experimental."}, help="How the video reaches the screen. In a window, Standard goes through the Windows compositor, which " "adds about 12 ms and keeps G-Sync and FreeSync from working. Low delay hands frames over the way games " "do, for playing in a window; fullscreen uses Standard, as quick there. With Windows' HDR on, it's always " "Low delay, so fullscreen keeps HDR on. Experimental; applies the next time you press Play.", impact={"speed": "Low delay should save the 12 ms a window adds. Still being measured."}), Spec("overlay", "Stats overlay", (True, False), True, ON_OFF, group="Display", help="Numbers over the video: the frames a second on screen, the game's own frame rate, how your PC keeps up, " "and more if you pick it (Items, below). Key: S (Off, Minimal, Detailed, Graphs, Bar)."), Spec("overlay_style", "Stats overlay style", ("minimal", "detailed", "graphs", "bar"), "minimal", {"minimal": "Minimal", "detailed": "Detailed", "graphs": "Graphs", "bar": "Bar"}, group="Display", applies=("overlay", (True,)), hints={"minimal": "A small line: frames on screen, the game's frame rate, the delay, and a dot for how well " "your PC keeps up.", "detailed": "A card with a row for everything: frametime and lows, dropped and late frames, the time " "of each stage, the graphics card, and the settings in words.", "graphs": "Like MangoHud: live graphs of frametime, the pipeline's time against its budget, delay and " "the graphics card's load, with 1% lows.", "bar": "One thin line across the top or bottom edge with the numbers that matter, green, yellow or " "red."}, help="Minimal: frames on screen, the game's frame rate (amber when it isn't 30 fps) and the delay, with a " "dot: green, your PC keeps up; amber, it's tight; red, it's falling behind, so try a lower frame rate. " "Detailed: a card with all the numbers. Graphs: live graphs. Bar: one line along the top or bottom " "edge. Which numbers each shows is yours to change under Items."), Spec("bar_position", "Bar position", ("top", "bottom"), "top", {"top": "Top edge", "bottom": "Bottom edge"}, group="Display", applies=("overlay_style", ("bar",)), help="Which edge of the picture the bar goes along."), Spec("overlay_corner", "Stats overlay corner", ("top-left", "top-right", "bottom-left", "bottom-right"), "top-left", {"top-left": "Top left", "top-right": "Top right", "bottom-left": "Bottom left", "bottom-right": "Bottom right"}, group="Display", applies=("overlay", (True,)), help="Which corner of the picture the stats go in."), Spec("overlay_scale", "Stats overlay size", (0.75, 1.0, 1.25, 1.5, 2.0), 1.0, PCT_SIZE, group="Display", applies=("overlay", (True,)), help="How big the stats are, as a share of their normal size."), Spec("overlay_opacity", "Stats overlay opacity", OPACITY, 0.8, PCT, group="Display", applies=("overlay", (True,)), help="How see-through the stats' background is. Text and graph lines stay solid; lower shows more of the " "game behind."), Spec("graph_frametime", "Graph: frametime", (True, False), True, ON_OFF, group="Display", applies=("overlay_style", ("graphs",)), help="Graphs style: the time between frames on screen, with 1% lows."), Spec("graph_pipeline", "Graph: pipeline", (True, False), True, ON_OFF, group="Display", applies=("overlay_style", ("graphs",)), help="Graphs style: SmoovPlay's time for each tick against its budget."), Spec("graph_delay", "Graph: delay", (True, False), True, ON_OFF, group="Display", applies=("overlay_style", ("graphs",)), help="Graphs style: how long each real frame takes to reach the screen."), Spec("graph_gpu", "Graph: graphics card", (True, False), True, ON_OFF, group="Display", applies=("overlay_style", ("graphs",)), help="Graphs style: the graphics card's load, power, temperature, clock and memory (needs nvidia-smi)."), Spec("overlay_colours", "Colour by threshold", (True, False), True, ON_OFF, group="Display", applies=("overlay", (True,)), help="Colours the numbers: green when all is well, yellow when it is tight, red when it is bad. Frame rates " "and lows are judged against the output rate, frametimes against its frame time, the graphics card " "against its load and temperature. Off draws every number in white."), Spec("stats_window", "Averaging window", (10, 30, 60), 30, {10: "10 seconds", 30: "30 seconds", 60: "1 minute"}, group="Display", applies=("overlay", (True,)), help="How far back averages, lows, jitter and worst frametime look. A longer window is steadier and has " "enough frames for the 0.1% low (it needs 1000); a shorter one follows a change sooner."), *STAT_SPECS, Spec("session_summary", "Save a summary when Summit stops", (True, False), True, ON_OFF, group="Display", help="When Summit's picture closes, writes the session's numbers (averages, lows, the time of each stage, the " "settings used and what changed during it) as a .json and a .txt file in Summit's data folder " "(~/.local/share/smoovplay/sessions on Linux). Key P writes one at any time."), Spec("frametime_log", "Log every frame (CSV)", (False, True), False, ON_OFF, group="Display", help="Writes a line for every frame shown to a .csv in the sessions folder, with MangoHud's columns, so you " "can graph a session elsewhere."), Spec("watermark", "Summit watermark", (True, False), True, ON_OFF, group="Display", help="A small line in a corner of the video: summit - git.molberg.cloud/alex/summit. It moves out of the " "stats overlay's way. Only in the video window, never in saved clips or files."), Spec("ui_opacity", "Menu opacity", OPACITY, 0.9, PCT, group="Display", help="How see-through the settings menu and its messages are. Text stays solid."), Spec("ui_scale", "Menu size", (0.6, 0.75, 0.9, 1.0), 1.0, PCT_SIZE, group="Display", help="How big the settings menu and its messages are (100% is as big as the window allows)."), # framegen/replay.py. Memory in the hints: replay.memory_mb() for 1080p at 90 fps (tests/test_replay.py checks). Spec("replay", "Instant replay", (0, 15, 30, 60, 180, 300, 600), 0, {0: "Off", 15: "Last 15 seconds", 30: "Last 30 seconds", 60: "Last minute", 180: "Last 3 minutes", 300: "Last 5 minutes", 600: "Last 10 minutes"}, group="Instant replay", hints={0: "Nothing is kept.", 15: "Keeps about 90 MB in memory (1080p at 90 fps).", 30: "Keeps about 160 MB in memory (1080p at 90 fps).", 60: "Keeps about 310 MB in memory (1080p at 90 fps).", 180: "Keeps about 910 MB in memory (1080p at 90 fps).", 300: "Keeps about 1.5 GB in memory (1080p at 90 fps).", 600: "Keeps about 3 GB in memory (1080p at 90 fps)."}, help="Keeps the last stretch of what you played, like the PS5's Share button. Press R in the video window " "to save the default length, or Ctrl+1..6 to pick 15 s, 30 s, 1 m, 3 m, 5 m or 10 m (never more than " "the buffer holds). Ctrl+Alt+R saves from anywhere. B saves a before & after video instead.", impact={"picture": "None.", "speed": "About 0.3 ms of graphics card time a frame; the encoding is on its video encoder, not " "the AI's part."}), Spec("replay_clip", "Default clip length", (15, 30, 60, 180, 300, 600), 30, {15: "15 seconds", 30: "30 seconds", 60: "1 minute", 180: "3 minutes", 300: "5 minutes", 600: "10 minutes"}, group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), help="How much R saves. It is capped at the buffer length above."), Spec("replay_save", "Saved clip", ("smoovplay", "compare", "both"), "smoovplay", {"smoovplay": "SmoovPlay video", "compare": "Before & after", "both": "Both"}, group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), hints={"smoovplay": "What you saw, with the game's sound. Saved in a second or two.", "compare": "The game's own frames next to SmoovPlay's, in one video. Made in the background, in " "about as long as the clip.", "both": "Both videos."}, help="What R saves. SmoovPlay video is what you saw, at 60, 90 or 120 fps. Before & after puts the game's " "own frames next to SmoovPlay's in one video, to show the difference; it's made in the background " "and takes about as long as the clip. B always saves a before & after video."), Spec("replay_layout", "Before & after layout", ("split", "side"), "split", {"split": "Split screen", "side": "Side by side"}, group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), hints={"split": "One picture: the left half as the game sent it, the right half from SmoovPlay.", "side": "Both whole pictures next to each other, in a video twice as wide."}, help="How a before & after video is laid out. Split screen is one picture: the left half as the game sent " "it, the right half from SmoovPlay, with a line between. Side by side shows both whole pictures, in " "a video twice as wide."), Spec("look_clips", "Looks in clips", (False, True), False, ON_OFF, group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), help="Puts the look you're using into saved clips too. Off keeps clips as the game looked, whatever look " "you play with. In a before & after video, only the SmoovPlay side gets the look.", impact={"picture": "Clips look like what you see, look included.", "speed": LOOK_CLIPS_SPEED}), Spec("minimize_chiaki", "Minimise chiaki-ng", (True, False), True, ON_OFF, group="PS5 Remote Play", help="Minimises chiaki-ng's own window while SmoovPlay's video is open, so your graphics card doesn't " "spend time drawing a copy nobody sees. chiaki-ng keeps streaming, playing sound and reading your " "controller, and its window comes back when you stop.", impact={"speed": "Saves the time your graphics card spends drawing chiaki-ng's window."}, sources=("chiaki",), elsewhere={"": "Only used with PS5 Remote Play."}), Spec("audio_sync", "Sound in sync", (True, False), True, ON_OFF, group="PS5 Remote Play", help="The sound (chiaki-ng's, or a capture card's, which SmoovPlay plays) would come as it arrives, while " "the picture spends a little longer in SmoovPlay. On holds the sound back by that time (about 30 ms " "at 90 fps, measured as you play), so they line up. Press L in the video window for a delay test: it " "times the whole trip, from a button press to SmoovPlay's screen (PS5 Remote Play).", impact={"speed": "None: only the sound waits, by as long as the picture does."}), Spec("simulate_30", "Simulate a 30 fps game", (False, True), False, ON_OFF, saved=False, group="PS5 Remote Play", help="For testing with a 60 fps game: every other frame is left out, so it plays like a 30 fps game. At " "60 and 120 fps each AI frame is also scored against the real frame it replaced. This session " "only."), # framegen/aa.py: at the game's size, before the upscaler; the pipeline applies it to every frame shown Spec("aa", "Anti-aliasing", aa.MODES, "off", aa.NAMES, group="Upscaling", hints={"off": "The game's picture as it comes. The default.", "fxaa": "Softens jagged edges: light and quick.", "smaa": "Smooths jagged edges by their shape, keeping more detail than FXAA.", "cas": "Not anti-aliasing: sharpens, more where the picture is soft."}, help="Smooths jagged edges in the game's picture, before it is upscaled: FXAA (light), SMAA-style (keeps " "more detail) or CAS sharpening. Mostly for games and streams that come without anti-aliasing. Saved " "clips stay as the game sent them. Compare them side by side with the C key (Compare tab).", impact={"picture": "Softer, smoother edges (CAS: sharper).", "speed": "Runs on the graphics card for every frame shown; the Compare view measures it."}), ) + _compare_specs() # 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", "Anti-aliasing", ("aa",)), ("Upscaling", "Output", ("output_res", "fill")), ("Display", "Window", ("fullscreen", "vsync", "present")), ("Display", "Colour and look", ("hdr", "look_on", "look")), ("Overlay", "Stats", ("overlay", "overlay_style", "bar_position", "overlay_corner", "overlay_scale", "overlay_opacity", "overlay_colours", "stats_window")), ("Overlay", "Items", tuple("stat_" + k for k in stats.ITEMS)), ("Overlay", "Graphs", ("graph_frametime", "graph_pipeline", "graph_delay", "graph_gpu")), ("Overlay", "Session", ("session_summary", "frametime_log")), ("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",)), ("Compare", "Setup", ("compare", "compare_dim", "compare_strips", *(compare.strip_key(d, i) for d in compare.DIMENSIONS for i in range(1, 5)))), ("Compare", "Show", ("compare_layout", "compare_cell", "compare_zoom", "compare_split", "compare_freeze", "compare_flip")), ("Compare", "Labels", ("compare_labels", "compare_labels_at", "compare_timings", "compare_clips")), ) 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) # framegen/optimize.py: what the overlay's Optimize tab asks for (its run itself is the "Find my settings" row). Kept # in specs_json too (the launcher may start a run with them); the --optimize grammar is under "optimize" there. OPTIMIZE_SPECS = ( Spec("opt_min_res", "Minimum resolution", ("1280x720", "1600x900", "1920x1080", "2560x1440", "3840x2160"), "1920x1080", OUTPUT_NAMES, group="Optimize", sub="Your minimums", help="The smallest output Optimize may pick. It never goes below this, whatever your priority."), Spec("opt_min_fps", "Minimum frame rate", (30, 60, 90, 120, 144, 165, 240), 60, {v: f"{v} fps" for v in (30, 60, 90, 120, 144, 165, 240)}, group="Optimize", sub="Your minimums", help="Frames a second on screen that Optimize must hold, judged by the 1% low (the slowest frames) with " "about 10% to spare, not the average. More than your display's refresh rate can't be shown."), Spec("opt_max_delay", "Most added delay", (0, 30, 40, 50, 70, 100), 0, {0: "No limit", **{v: f"{v} ms" for v in (30, 40, 50, 70, 100)}}, group="Optimize", sub="Your minimums", help="The most delay Summit itself may add (frame generation adds some). No limit: not checked."), Spec("opt_priority", "Priority", ("fps", "resolution", "quality", "delay"), "quality", {"fps": "Frame rate", "resolution": "Resolution", "quality": "Quality", "delay": "Lowest delay"}, group="Optimize", sub="Then improve", help="Once your minimums hold, what Optimize raises as far as it goes. Quality follows a fixed ranking: the " "display's own resolution, then RTX VSR over FSR 1, then Full motion detail, then anti-aliasing. Only " "Summit's settings are tried: Summit can't change the game's own graphics options."), Spec("opt_budget", "Time to spend", (60, 120, 180, 300), 120, {60: "1 minute", 120: "2 minutes", 180: "3 minutes", 300: "5 minutes"}, group="Optimize", sub="Then improve", help="How long Optimize may take. Each try takes about 7 seconds, one that restarts the pipeline about 20."), ) SPECS = SPECS + OPTIMIZE_SPECS SPECS = _laid_out(SPECS) BY_KEY = {s.key: s for s in SPECS} class Settings: """Current values, saved to JSON on every change. Values given on the command line (`override`) apply to this run only and aren't saved unless changed in the menu.""" def __init__(self, values: dict | None = None, path: Path | None = None) -> None: self.path = path self._listeners: list[Callable[[str], None]] = [] self._v = {s.key: s.default for s in SPECS} self._saved = dict(self._v) # what the file holds (or would) for k, v in (values or {}).items(): if k in BY_KEY and BY_KEY[k].saved and BY_KEY[k].accepts(v): self._v[k] = self._saved[k] = v @classmethod def load(cls, path: Path = DEFAULT_PATH) -> "Settings": try: values = json.loads(Path(path).read_text(encoding="utf-8")) except (OSError, ValueError): values = {} return cls(values if isinstance(values, dict) else {}, path) def __getattr__(self, key: str) -> Any: try: return self.__dict__["_v"][key] except KeyError: raise AttributeError(key) from None def values(self) -> dict: return dict(self._v) def watch(self, fn: Callable[[str], None]) -> Callable[[], None]: """fn(key) is called after any value changes. Returns a function that stops it.""" self._listeners.append(fn) return lambda: self._listeners.remove(fn) if fn in self._listeners else None def override(self, key: str, value: Any) -> None: """This run only (command-line flags, the I key).""" self._put(key, value, save=False) def set(self, key: str, value: Any) -> None: self._put(key, value, save=True) def _put(self, key: str, value: Any, save: bool) -> None: if not BY_KEY[key].accepts(value): raise ValueError(f"{key}: {value!r} is not one of {BY_KEY[key].choices}") changed = self._v[key] != value self._v[key] = value if save and BY_KEY[key].saved: self._saved[key] = value self.save() if changed: for fn in list(self._listeners): fn(key) def step(self, key: str, delta: int, allowed=None) -> Any: """Move to the next/previous choice (wrapping), skipping values `allowed(key, value)` rejects.""" choices = BY_KEY[key].choices cur = self._v[key] if cur in choices: i = choices.index(cur) else: # a custom value (Frame multiplier): step from where it falls among the choices below = [j for j, c in enumerate(choices) if c < cur] i = (below[-1] + (1 if delta < 0 else 0)) if below else (len(choices) if delta < 0 else -1) for _ in range(len(choices)): i = (i + delta) % len(choices) if allowed is None or allowed(key, choices[i]): self.set(key, choices[i]) break return self._v[key] def save(self) -> None: if self.path is None: return try: self.path.parent.mkdir(parents=True, exist_ok=True) self.path.write_text(json.dumps(self._saved, indent=2), encoding="utf-8") except OSError as e: print(f"[settings] couldn't save {self.path}: {e}") def _optimize_registry() -> dict: from . import optimize return optimize.registry() def specs_json(specs: tuple[Spec, ...] = SPECS) -> dict: """The registry for the launcher's Settings page: every setting with its choices in display order, and where the saved file is. Values are JSON types; the launcher sends a choice back exactly as given here.""" return { "path": str(DEFAULT_PATH), "impact_pc": IMPACT_PC, "specs": [{"key": s.key, "label": s.label, "group": s.group, "help": s.help, "default": s.default, "sub": s.sub, "live": s.live, "saved": s.saved, "later": s.later, "quick": s.quick, "impact": s.impact, "experimental": s.experimental, "sources": list(s.sources) or None, "elsewhere": s.elsewhere or None, "applies": {"key": s.applies[0], "values": list(s.applies[1])} if s.applies else None, "choices": [{"value": v, "name": s.name(v), "hint": s.hints.get(v, "")} for v in s.choices]} for s in specs], "compare": compare.registry(), # --compare's dimensions and choices (framegen/compare.py) "optimize": _optimize_registry(), # --optimize's grammar and where its results go (framegen/optimize.py) } if __name__ == "__main__": print(json.dumps(specs_json()))