d3d12: the last choice wins between the command line and the F1 menu (D3D12-MENU-LAST-CHOICE-WINS) #2880
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2880"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by alpfilho on 2026-12-01T13:56:08Z.
Claimed in the coordination issue as: D3D12-MENU-LAST-CHOICE-WINS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7313240160)
What and why
d3d12/scripts/play-nvidia.ps1appliedleonida-settings.txt(what the F1 menu saved) over the command line at every start. An empty value there also removed what the command line had set. So a-Resolution,-Dlssor-SeriesSgiven after a menu save was lost without a word. Here:LEONIDA_MENU_CONSOLE=series-xran Series X with-SeriesSpassed.LEONIDA_RENDER_SCALE=removed the scale-Resolution 1080asked for.Now the user's last choice wins, one setting at a time, by what was typed:
scripts/play-d3d12.ps1passes the switches typed there as-Typed, so its Series X default and-Lowest 1080, which nobody typed, leave the menu's choice standing.-SeriesScounts as the console's switch.play-nvidia.ps1by hand counts its own switches.-Morewins like a typed switch.$switchSettings);-Dlssreplaces the scales as-Resolutionand-Lowestdo. DLSS's and FSR 3's frame generation are one choice there: a typed-FrameGenreplaces a saved FSR 3, and a typed-FsrFrameGenreplaces a saved DLSS amount.-MenuRestartto the switches it replays (LEONIDA_MENU_ARGS, commented where it is built). On that start the menu's values, saved after those switches, win. The replay now includes-NoFrameGen, which main leaves out.F1 menu settings (leonida-settings.txt, for what the command line did not set): LEONIDA_PANEL=1andCommand line over the F1 menu's saved values: LEONIDA_MENU_CONSOLE series-x -> series-s (-SeriesS/-SeriesX), LEONIDA_RENDER_SCALE 0.6 -> 0.6667 (-Resolution).-DryRunprints the same lines and writes nothing.The F1 menu (
host/menu.rs) also shows two values it could not show before:1 NATIVE (SERIES X), which-Resolutionmakes at the output's own height. Before, it showed as a bare1. The label says Series X because scale 1 on Series S ends the title at its own breakpoint (known,d3d12/README.md).LOWEST SCALE (DYNAMIC RES),LEONIDA_RENDER_SCALE_MIN, which-Lowestsets. Before, it was not shown at all.The README and
docs/mod-menu.mdsay how the two now combine.Tested
tests/test_play_nvidia_menu_choice.py: 14 tests, OK in 8.5 s. Thirteen run the launcher's block in Windows PowerShell against a menu file in a temporary folder; one runs the whole launcher with-DryRunand a stand-in executable. The cases:-Lowest 1080) keeps the menu's value, and a typed-SeriesSwins over a menu's Series X;-Morewins like a typed switch, and the report names its value;-Dlssreplaces the menu's lowest scale;-SmoothMotiontyped in play-d3d12 is named as typed;LEONIDA_MENU_ARGSreplays-NoFrameGen,-FsrFrameGen,-SeriesX,-Lowestand-MenuRestart.cf15c2c6e, the two frame-generation tests fail; with that of3a3f38325, the four that cover the second review fail.cargo test --locked -p leonida-gpu --features diagnostics --lib host::menu: 2 passed. Every menu line, the two new ones included, fits the box and has a glyph for each character.play-nvidia.ps1andplay-d3d12.ps1parse ([System.Management.Automation.Language.Parser]::ParseFile, 0 errors).scripts\play-d3d12.ps1 -Game <copy> ... -DryRunwith a menu file holdingLEONIDA_MENU_CONSOLE=series-x,LEONIDA_RENDER_SCALE=0.6andLEONIDA_PANEL=1:-SeriesS -Resolution 720: Series S at 0.6667, the panel from the menu, the two replaced values listed.tests/test_text_write_line_endings.py: OK.scripts/check_no_game_data.pyon the changed files: clean.GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 621.40, Windows 11 Pro (build 26300); Ryzen 5 5600GT
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T14:10:22Z.
Review: COMMENTED
The two-file split and "the menu file drops what the CLI replaced" are the right shape, and the tests cover the four obvious orders (CLI-only, menu-only, CLI-then-menu, menu-then-CLI).
python -m unittest tests.test_play_nvidia_menu_choiceis 7/7 here, and both hops are guarded — forcing "menu always wins", or removing the$menu.Remove($k), each fails 2–4 tests.But the rule as implemented is "a value that differs from the last start's CLI wins", not "the last choice wins", and that shows up in two cases:
-SeriesS -NoSmoothMotionafter F1 once chose Series X + smooth staysseries-x/smoothforever;-Resolution 1440pafter F1 set scale 1 stays at 1. Each start prints "F1 menu settings (…, newer than the command line)" while the flag was typed now. The cause is the baseline:leonida-launch.txtis the pre-menu snapshot (:535) of the whole merged table — defaults and machine-derived keys included — so "what the command line made" also contains what it didn't make.LEONIDA_CARD_AWAKE(older launcher, different machine, a new default), F1's=1is deleted fromleonida-settings.txtand reported as "Command line over the F1 menu's … 1 -> 0" for a flag the command line never mentioned. I reproduced both cases with temp folders.Suggested shape: record per key which side and when chose it (a source/time stamp alongside the value) instead of inferring it from a value diff; keep the losing menu value rather than deleting it (so an upgrade or machine change can restore it); and add two tests — "same flag repeated after the menu" and "last file missing a seeded key".
Two smaller things:
scripts/game-gate.ps1:97-98copiesleonida-settings.txtinto a run's folder but notleonida-launch.txt, so a gate run's artifacts no longer record the input this rule depends on.LEONIDA_MENU_ARGSreplays the CLI flags, not the effective values (:632-640), which is why the repeated-flag case survives an F1 restart — worth a comment where it is built, since it is now load-bearing for the rule.Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T14:13:42Z.
I exercised the full launcher with #2761 and this PR (
c066c04aon3e7b34a5), withStart-Processstubbed to record the final settings. The dynamic preset with-MotionBlur:$falsestarts at minimum scale 0.75. Replaying the actualLEONIDA_MENU_ARGSafter the menu saves 0.67 uses 0.67. A later explicit-Lowest 720selects 0.5 and preserves the unrelated menu panel setting. Using themainlauncher with the same preset in all three launches gives 0.75 → 0.67 → 0.67. The seven targeted tests also pass with the test runner switched topwshon Linux.A separate write-failure case loses a saved choice. After a successful first launch, make
leonida-launch.txtreadable but not writable and leaveleonida-settings.txtwritable withLEONIDA_RENDER_SCALE_MIN=0.67. Starting with-Lowest 720removes the saved 0.67 from the menu file before updating the history. The history write fails and leaves the old history intact. WithErrorActionPreference=Stopthe process is never dispatched. With the defaultContinuethe process is dispatched with 0.5, but the history remains stale. In both cases the saved choice is already gone. The two file updates need to preserve the menu on a persistence failure.MEASURED with PowerShell 7.4.21 on Linux using temporary files and a synthetic runtime stub. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T14:14:34Z.
Follow-up with the upgrade case measured, since it is worse than "the flag is ignored once".
Block extracted exactly as the test does and run alone at
c066c04af— menu fileLEONIDA_RENDER_SCALE=0.6, noleonida-launch.txt, command lineLEONIDA_RENDER_SCALE=0.5:{"LEONIDA_RENDER_SCALE":"0.6"}— the explicit flag loses;F1 menu settings (leonida-settings.txt, newer than the command line): LEONIDA_RENDER_SCALE=0.6— a claim the code cannot support, since with no launch file it has nothing to compare;0.6;leonida-launch.txtwritten with the CLI value0.5.And a second start with the same command line behaves identically — because the launch file now holds
0.5, the comparison sees "unchanged" and lets the menu win again. So an explicit flag stays shadowed on every start until the user changes or removes it, which contradicts the README's "a setting you change on the command line after saving it in the menu takes the command line's value."The obvious fix does not work: pre-seeding the launch file with the CLI values before the merge still yields
0.6, because last and now are equal (I tried it). What is needed is to treat a non-empty command-line value that differs from the menu's as the newer choice on the first start too — equivalently, use the menu's value as the baseline only for keys the command line actually set, so untouched menu keys survive — plus a neutral "no launch file yet" line instead of "newer than the command line", and a test for the upgrade case (the existing first-start test asserts the current behaviour).Imported from ubiquitarianism/leonida. Originally posted by alpfilho on 2026-12-01T14:23:52Z.
@KelboLive @merzleckeier thanks, both right. The first version inferred the choice from a value that differed from the last start's command line, and every case you found came from that.
cf15c2c6e(rebased on main) decides by what was typed instead, and dropsleonida-launch.txt:play-d3d12.ps1passes its typed switches as-Typed, so its Series X default and-Lowest 1080count as untyped. A start by hand counts its own switches, and-Morewins like a typed switch. Every other setting keeps the menu's value.LEONIDA_CARD_AWAKEand the like) is never taken from the menu.LEONIDA_MENU_ARGS: commented where it is built. SAVE AND RESTART now adds-MenuRestart, and on that start the menu's values win, since they were saved after the switches it replays.game-gate.ps1: no change needed, since there is no second file to copy.On keeping the losing menu value: I drop it on purpose. Dropping it is what makes F1 show the command line's value, which is what the user asked for. Without the baseline, an upgrade or a machine change no longer removes anything the command line did not set.
Tests: 10 cases, among them both of yours ("same switch typed again", "a setting no switch makes"), the restart and the unwritable menu file. With the rule disabled, 7 of the 10 fail.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T15:43:08Z.
Verified independently on native Windows 10 Pro 22H2 (build 19045, Ryzen 9 5950X 16C/32T, Windows PowerShell
5.1.19041.7844) with#2880headcf15c2c6emerged ontomain0ff8a532f:python -I tests/test_play_nvidia_menu_choice.py(with#2880): 10 passed, 0 failed (covers@KelboLive's upgrade case whereleonida-settings.txtholdsLEONIDA_RENDER_SCALE=0.6with no extra state file and a typed-Resolution 1080overrides it and dropsLEONIDA_RENDER_SCALEfromleonida-settings.txt).d3d12/scripts/play-nvidia.ps1andscripts/play-d3d12.ps1checked out fromorigin/main0ff8a532f): 3 passed, 7 failed.cargo test --locked -p leonida-gpu --lib host::menu: 2 passed, 0 failed (default features) and 2 passed, 0 failed (--features diagnostics).python -m unittest discover -s tests -p "test_docs_*.py" -v: 57 passed, 0 failed.MEASURED (synthetic launcher/unit tests, no game files). AI-assisted: Antigravity.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T15:58:27Z.
Full-launcher frame-generation follow-up at
cf15c2c6e+0ff8a532f. This uses the real launcher scripts under PowerShell 7.4.21 with CIM and the final Start-Process mocked. The harness sees the environment handed to the runtime. AMD DLL availability is represented by empty files used only by Test-Path.LEONIDA_FSR_FRAMEGEN=1, bothplay-nvidia.ps1 -FrameGen 2andplay-d3d12.ps1 -FrameGen 2hand off FSR=1 and no DLSS frame-generation value. With a saved DLSS value of 3 instead, the same direct switch correctly hands off 2 and drops that saved entry. The FSR override is left outside the FrameGen switch's settings, then the mutual-exclusion block removes the newly chosen DLSS value.-SeriesX -Lowest 1080 -NoFrameGen, simulated RTX 4070 SUPER and Streamline present, the first start has no frame generation. Replaying its exact LEONIDA_MENU_ARGS with the menu file holding only an unrelated setting enables 2x. The replay omits NoFrameGen on both main and this PR.A local trial treating the two explicit enable switches as mutually exclusive choices and replaying NoFrameGen produced DLSS=2 in both first cases, preserved the reverse FSR choice and kept frame generation off on restart. The independent panel setting stayed saved. The merge with #2761 also kept the MotionBlur true/false distinction and 2560×1440 output.
MEASURED with synthetic inputs. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by alpfilho on 2026-12-01T16:12:09Z.
@merzleckeier both confirmed and fixed in
3a3f38325:-FrameGen. DLSS's and FSR 3's frame generation are one choice, so in$switchSettings-FrameGennow also setsLEONIDA_FSR_FRAMEGEN, and-FsrFrameGenalso setsLEONIDA_FRAME_GEN. A typed one replaces the menu's other one, and the menu file drops it.-NoFrameGenstill sets DLSS's only, as the launcher treats it.-NoFrameGen.LEONIDA_MENU_ARGSnow replays it.Two new tests. One runs the block for both directions of the frame-generation choice. The other runs the whole launcher with
-DryRunand a stand-in executable, and checks that the restart's arguments keep-NoFrameGen,-FsrFrameGen,-SeriesX,-Lowestand-MenuRestart. Both fail with the launcher ofcf15c2c6e, and all 12 pass now.@lixonik thanks for the independent run on Windows 10.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:46:32Z.
Review: COMMENTED
AI-assisted review (Antigravity).
CI failure diagnosis
The two failing checks on
3a3f38325(checkandlinux-python-and-viewerin run 46688205991) are not caused by this PR. They are pre-existing regressions currently failing onmain(7f8bb9037, run 46688812432) on the exact same files:tests/test_wave_diff.py&tests/test_wave_trace.py(TypeError: WaveRef._check_vgpr_dst() missing 1 required positional argument: 'dst')tests/test_x64_recomp.py(test_opcode_90_nop_pause_and_rex_xchg)tests/test_x64_recomp_qemu_runner.py(AssertionError: called run_kernel instead of run_result)tests/test_piecewise_parse.py(3scripts/run_gpu_tests.pyfailures on Linux)These are already fixed in #2895 (currently green on all checks). Everything touched by this PR passed in CI:
tests/test_play_nvidia_menu_choice.py(12/12 OK incheck),d3d12 (windows-latest),no-game-data,change-scope,semantic-tests,windows, andlinux-gpu-tools.Code review findings
The typed-switch design (
$switchSettings+-Typed+-MenuRestart) is clean and well-scoped, and thehost/menu.rsadditions (1 NATIVE (SERIES X)andLOWEST SCALE (DYNAMIC RES)) both fit the 60-column menu box (55 chars each with*) using existing glyphs inhost/font.rs.A few real bugs/edge cases in
d3d12/scripts/play-nvidia.ps1:-Morevalues are missing from$fromLine, so the replacement summary prints(unset)instead of the-Morevalue (d3d12/scripts/play-nvidia.ps1:564-576, 601)$fromLine = @{} + $settingsis captured at line 564, before$Moreis applied to$settingsat line 601.leonida-settings.txthasLEONIDA_PROMPTS=playstationand-More @{LEONIDA_PROMPTS='xbox'}is passed,$fromLine['LEONIDA_PROMPTS']is$null, so line 573 printsLEONIDA_PROMPTS playstation -> (unset) (-More)instead of-> xbox (-More)(while line 601 still runs withxbox).LEONIDA_PANEL=) with-More @{LEONIDA_PANEL='1'}compares"" -ne ""and omits the line from$replaced, while passing the same value (LEONIDA_PANEL=1) falsely logs1 -> (unset) (-More).test_more_wins_over_the_menu_like_a_typed_switchmissed this because it only checksself.assertIn("(-More)", ran["said"]).$Moreonto$fromLineright after line 566: and assert"LEONIDA_PROMPTS playstation -> xbox (-More)"intest_more_wins_over_the_menu_like_a_typed_switch.-DlssomitsLEONIDA_RENDER_SCALE_MINin$switchSettings(d3d12/scripts/play-nvidia.ps1:538)ResolutionandLowestboth include'LEONIDA_RENDER_SCALE_MIN', butDlssdoes not.-Dlss qualityintentionally leavesLEONIDA_RENDER_SCALEunset (line 397) so the title renders at its own 2/3 height. Ifleonida-settings.txtholds a savedLEONIDA_RENDER_SCALE_MIN=0.5, typing-Dlss qualitykeepsLEONIDA_RENDER_SCALE_MIN=0.5from the menu instead of dropping it (and on Series X leaves a stale entry inleonida-settings.txt).'LEONIDA_RENDER_SCALE_MIN'(and'LEONIDA_OUTPUT'if desired for parity withResolution/Lowest) toDlssin$switchSettings.-SmoothMotionviascripts/play-d3d12.ps1reports as(-NoSmoothMotion)(d3d12/scripts/play-nvidia.ps1:556)scripts/play-d3d12.ps1:118maps'SeriesS' -> 'SeriesX'and'SmoothMotion' -> 'NoSmoothMotion', but line 556 only expands'SeriesX'to'-SeriesS/-SeriesX'.play-d3d12.ps1 -SmoothMotionover a savedLEONIDA_MENU_SMOOTH_MOTION=0printsLEONIDA_MENU_SMOOTH_MOTION 0 -> 1 (-NoSmoothMotion).'NoSmoothMotion' { '-SmoothMotion/-NoSmoothMotion' }alongside'SeriesX'.Minor cleanup (
d3d12/scripts/play-nvidia.ps1:586, 591-596):$menuFilefrom disk ($menu.Count -ne (Read-SettingsFile $menuFile).Count); comparing against$menu.Countcaptured before the loop (or a$droppedboolean) avoids a redundant read and TOCTOU window.catch(line 595),Remove-Item -LiteralPath "$menuFile.tmp"runs even whenWriteAllTextfailed before creating$tmp(e.g., if a pre-existing directory exists at$tmp, PowerShell removes it if empty); tracking whetherWriteAllTextsucceeded before removing$tmpavoids deleting something this script didn't create.Local verification (Linux, no PowerShell installed)
python3 -I scripts/check_no_game_data.py— cleangit diff --check b3910e5e3..HEAD— cleanpython3 -m compileall -q make_game.py tools tests— cleanpython3 -I tests/test_text_write_line_endings.py— 3 passedpython3 -m unittest discover -s tests -p "test_docs_*.py" -v— 57 passedtests/test_play_nvidia_menu_choice.py) were not run locally (skipped on Linux; 12/12 passed in Windows CI run46688205991), so no commits were pushed to the PR branch.Imported from ubiquitarianism/leonida. Originally posted by alpfilho on 2026-12-01T16:50:44Z.
@aslan2142 thanks. All four are confirmed and fixed in
8e1d4000a:-Morein the report: its values are now overlaid onto what the menu is compared with. So the report saysLEONIDA_PROMPTS playstation -> xbox (-More), an equal value is not reported, and an empty menu value set by-Moreis.-Dlss: it now also setsLEONIDA_RENDER_SCALE_MINandLEONIDA_OUTPUTin$switchSettings, like-Resolutionand-Lowest.-SmoothMotion: reported as-SmoothMotion/-NoSmoothMotion, as-SeriesSis.Tests: 14, OK on Windows PowerShell 5.1. With the launcher of
3a3f38325, the four that cover these fail.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:37:58Z.
Review: APPROVED
AI-assisted review (Antigravity): verified commit
8e1d4000cleanly resolves all 4 review items with 14/14 PowerShell tests passing in Windows CI; all active checks are green.