Repository navigation
d3d12: the last choice wins between the command line and the F1 menu (D3D12-MENU-LAST-CHOICE-WINS) - #2880
Conversation
KelboLive
left a comment
There was a problem hiding this comment.
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_choice is 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:
- Re-typing the identical flag never wins.
-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. - A missing key in that baseline is destructive. With a last file that lacks
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.
|
I exercised the full launcher with #2761 and this PR ( A separate write-failure case loses a saved choice. After a successful first launch, make MEASURED with PowerShell 7.4.21 on Linux using temporary files and a synthetic runtime stub. AI-assisted (Codex). |
|
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
And a second start with the same command line behaves identically — because the launch file now holds The obvious fix does not work: pre-seeding the launch file with the CLI values before the merge still yields |
…(D3D12-MENU-LAST-CHOICE-WINS) play-nvidia.ps1 applied leonida-settings.txt (what F1 saved) over the command line at every start. An empty value there removed what the command line set, so a later -Resolution, -Dlss or -SeriesS was lost without a word. Now leonida-launch.txt (git-ignored) keeps what the last start's command line made: - A setting this command line makes otherwise than that start's did wins. The menu file drops its value, so F1 shows and saves the new one. - A setting it makes as before keeps the menu's value, the newer choice. - Each start says which values came from the menu and which the command line replaced. - A dry run writes neither file. The F1 menu gets the native render scale (1, which -Resolution makes at the output's height) and the dynamic resolution's lowest scale (LEONIDA_RENDER_SCALE_MIN, from -Lowest). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (D3D12-MENU-LAST-CHOICE-WINS) Review of the first version: a value that differs from the last start's command line was taken for the user's new choice. That lost an explicit flag on the first start after an upgrade, never let the same flag typed again win, and dropped a menu value the command line never mentioned when leonida-launch.txt lacked the key. The menu file was also rewritten before the history, so a failed history write had already lost a saved choice. Now the rule follows what the user typed: - A switch typed for this start wins over the menu's saved value of each setting it makes. The menu file drops that value, so F1 shows the command line's. scripts\play-d3d12.ps1 passes the switches typed there as -Typed, so its Series X default and -Lowest 1080 leave the menu's choice standing. A start by hand counts its own switches, and -More wins like a typed switch. - Every other setting keeps the menu's value. - The menu's SAVE AND RESTART adds -MenuRestart to the switches it replays (LEONIDA_MENU_ARGS), so there the menu's values, saved after those switches, win. leonida-launch.txt is gone. The menu file is written to a temporary file and moved over the old one, and only when a value leaves it. If that fails, the start runs with the command line's values and the file stays whole. Tests: 10 cases, among them the same switch typed again, an untyped default, a setting no switch makes, the restart, a start by hand, -More and a menu file that cannot be written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c066c04 to
cf15c2c
Compare
|
@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.
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). |
|
Verified independently on native Windows 10 Pro 22H2 (build 19045, Ryzen 9 5950X 16C/32T, Windows PowerShell
MEASURED (synthetic launcher/unit tests, no game files). AI-assisted: Antigravity. |
|
Full-launcher frame-generation follow-up at cf15c2c + 0ff8a53. 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.
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). |
…start replays -NoFrameGen Review of cf15c2c (merzleckeier, full launcher with the final start mocked): - A saved LEONIDA_FSR_FRAMEGEN=1 undid a typed -FrameGen 2. The launcher keeps FSR 3's frame generation when both are set and drops DLSS's. The two are one choice, so -FrameGen now also sets LEONIDA_FSR_FRAMEGEN and -FsrFrameGen also sets LEONIDA_FRAME_GEN in $switchSettings. A typed one replaces the menu's other. - LEONIDA_MENU_ARGS left -NoFrameGen out, as main does, so SAVE AND RESTART turned frame generation on. It is replayed now. Tests: 12 (two new). With the launcher of cf15c2c, the two new ones fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@merzleckeier both confirmed and fixed in
Two new tests. One runs the block for both directions of the frame-generation choice. The other runs the whole launcher with @lixonik thanks for the independent run on Windows 10. AI-assisted (Claude Code, Claude Opus 5.5). |
aslan2142
left a comment
There was a problem hiding this comment.
AI-assisted review (Antigravity).
CI failure diagnosis
The two failing checks on 3a3f38325 (check and linux-python-and-viewer in run 46688205991) are not caused by this PR. They are pre-existing regressions currently failing on main (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 in check), d3d12 (windows-latest), no-game-data, change-scope, semantic-tests, windows, and linux-gpu-tools.
Code review findings
The typed-switch design ($switchSettings + -Typed + -MenuRestart) is clean and well-scoped, and the host/menu.rs additions (1 NATIVE (SERIES X) and LOWEST SCALE (DYNAMIC RES)) both fit the 60-column menu box (55 chars each with *) using existing glyphs in host/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.- When
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). - Similarly, overriding an empty menu entry (
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"]).- Fix: overlay
$Moreonto$fromLineright after line 566:and assertforeach ($k in $More.Keys) { $fromLine[$k] = "$($More[$k])" }
"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.- On Series S,
-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). - Fix: add
'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'.- Passing
play-d3d12.ps1 -SmoothMotionover a savedLEONIDA_MENU_SMOOTH_MOTION=0printsLEONIDA_MENU_SMOOTH_MOTION 0 -> 1 (-NoSmoothMotion). - Fix: handle
'NoSmoothMotion' { '-SmoothMotion/-NoSmoothMotion' }alongside'SeriesX'.
-
Minor cleanup (
d3d12/scripts/play-nvidia.ps1:586, 591-596):- Line 586 re-reads
$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. - In
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.
- Line 586 re-reads
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 passed- PowerShell tests (
tests/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.
…cale, a tidier menu file write Review of 3a3f383 (aslan2142): - The values -More sets were not in what the menu was compared with. A replaced value printed "-> (unset)", a value equal to the menu's was reported as replaced, and an empty menu value set by -More was not reported. They are overlaid now. - -Dlss now also sets LEONIDA_RENDER_SCALE_MIN and LEONIDA_OUTPUT in $switchSettings, as -Resolution and -Lowest do, so a typed DLSS mode replaces a saved lowest scale. - play-d3d12.ps1's -SmoothMotion is named -SmoothMotion/-NoSmoothMotion in the report, as -SeriesS is. - The menu file is not read again to tell whether a value left it. After a failed write, only a temporary file this start wrote is removed; whatever already stood at that name is left alone. Tests: 14. With the launcher of 3a3f383, 4 fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@aslan2142 thanks. All four are confirmed and fixed in
Tests: 14, OK on Windows PowerShell 5.1. With the launcher of AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: D3D12-MENU-LAST-CHOICE-WINS (#2570 (comment))
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