Skip to content

d3d12 launcher: 16 GB PCs keep title memory windows on the card up to 95 % of its budget (D3D12-16GB-WINDOWS-BAR-LINE) - #3002

Open
valenciana-nc wants to merge 2 commits into
ProjectLeonida:mainfrom
valenciana-nc:d3d12-16gb-windows-bar-line
Open

valenciana-nc wants to merge 2 commits into
ProjectLeonida:mainfrom
valenciana-nc:d3d12-16gb-windows-bar-line

Conversation

@valenciana-nc

Copy link
Copy Markdown

Claimed in the coordination issue as: D3D12-16GB-WINDOWS-BAR-LINE (#2570 (comment))

Depends on: none

Related: draft #2658 (8 GB over-budget guard, measured on an RTX 3060 Ti 8 GB with 16 GB RAM) deals with the same 8 GB card / 16 GB RAM case from the card's side. This PR only changes the launcher's windows line and does not depend on it.

What and why

When a windows cap is set (the launcher's own LEONIDA_WINDOWS_BAR_MB=3072, or -WindowsBarMB other than 0), d3d12/scripts/play-nvidia.ps1 now also sets LEONIDA_WINDOWS_BAR_LINE=95 on PCs with 16 GB of RAM or less (under 20 GB as Windows counts it; this PC reads 15.6 GB) and a card known to have 8 GB or more. The card check is 7 GB and up by the driver's HardwareInformation.qwMemorySize, because the RTX 4060 Laptop GPU reads 8,188 MiB.

The runtime's default line is 80 (clamped to 50-97, shadow.rs window_mapped_line()). Title memory windows go to the card's CPU-mapped GPU_UPLOAD memory only while the card's memory in use plus the window stays under that share of its budget; otherwise they stay in the PC's memory. On a 16 GB PC the PC's memory runs out before the card's: at 80 the refused windows stay in RAM, free memory drops to tens or a few hundred MB, and frames stall.

  • PCs of 20 GB and more, 6 GB cards and cards of unknown size keep 80 (not measured).
  • -More @{LEONIDA_WINDOWS_BAR_LINE='80'} keeps 80, because -More is applied after the launcher's settings and the F1 menu's.
  • Also updated: the 16 GB note in d3d12/README.md, a new section in d3d12/docs/findings.md ("The windows' line on a 16 GB PC"), and the one switches.md row, written as tools/d3d12_switches.py generates it.

Setup:

  • PC: i7-13650HX, RTX 4060 Laptop GPU 8 GB, resizable BAR on (BAR1 8192 MiB), PCIe 4.0 x8, 16 GB RAM.
  • Start: scripts\play-d3d12.ps1 -SeriesS -Resolution 540 -NoDlss -NoFrameGen, diagnostics build of main 1fff691, the same save restored before each start.
  • Measured: 200 s from reaching the world, the first 20 s left out, a frame line about every 5 s.
  • Separate runs, because the runtime reads the line once (OnceLock), so LEONIDA_AB cannot switch it during a run.
  • Sides: A = launcher default (line 80), B = LEONIDA_WINDOWS_BAR_LINE=95, run in the order A B B A A B B A.
Run Side Median ms p90 ms Worst ms Frame lines > 100 ms
1 A 42.5 82.3 944.5 1 of 29
2 B 39.4 59.0 94.2 0 of 28
3 B 39.6 79.6 1057.7 2 of 28
4 A 47.1 628.0 750.0 6 of 28
5 A 52.9 607.9 2775.9 7 of 27
6 B 42.6 60.6 79.1 0 of 28
7 B 40.6 96.9 235.2 2 of 28
8 A 43.0 79.3 486.2 2 of 32

Frame times:

  • Pairs (A minus B, median): +3.1, +7.5, +10.3 and +2.4 ms. On average B's median was 5.8 ms lower (±1.9 standard error), and B was lower in all four pairs.
  • Frame lines over 100 ms: A 16 of 116, B 4 of 112.

Memory:

A (line 80) B (line 95)
PC free physical memory, lowest 39-278 MB 150-304 MB
Card memory shared with the PC, highest 4.27-4.53 GB 3.88-3.92 GB
Card's own memory in use, highest (budget about 7.1 GB) 6.80-6.90 GB 6.97-7.14 GB

With 95 the card runs at about 100 % of its budget.

Textures (counted at each run's end, runs 2-8):

A (line 80) B (line 95)
Host copies let go 91,800-92,558 93,430-96,511
Host copies made again 22,597-22,893 23,867-26,430
Host copies alive 9,025-9,109 (676-716 MB) 9,273-11,699 (698-771 MB)

So B let go about 3 % more texture copies and made about 10 % more again, with slightly more alive. The picture was not compared between the two settings.

LEONIDA_CARD_BUFFERS_MB=512 instead of 1536 (one run) was far worse: median 115.9 ms, with the card 95 % busy.

Not measured: PCs under 16 GB or of 20-47 GB, other cards, AMD.

Tested

  • python -I tests/test_win_launchers.py, new test test_nvidia_windows_bar_line_on_16_gb_pcs_with_8_gb_cards. RAM and card memory are mocked at what this PC reads (16,003 and 8,188 MiB). Cases:
    • 16 GB RAM, 8 GB card: line 95, cap 3072
    • the same with -More line 80: line 80
    • 32 GB RAM: cap 3072, no line
    • 6 GB card: cap 3072, no line
    • explicit -WindowsBarMB 3072: line 95
    • -WindowsBarMB 0: no line
    • RAM unknown: no line
    • card size unknown: no line
  • The shared PowerShell setup is now a helper, which the motion-blur test uses too.
  • Red/green: the new test fails with only d3d12/scripts/play-nvidia.ps1 taken from main (None != '95') and passes with the change. Done by hand: scripts/red_green.py would have put its worktree inside the user's play checkout.
  • python -m unittest discover -s tests -p "test_docs_*.py" passes. python -I tests/test_d3d12_switches.py passes (20 tests). python -I scripts/check_no_game_data.py on the changed files is clean.
  • The A/B runs above, in the game.
  • Tested under Windows PowerShell 5.1 only; pwsh 7 is not installed on this PC.

GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU 8 GB, driver 610.62, Windows 11 Home, i7-13650HX, 16 GB RAM

AI-assisted: yes. Claude Opus 5.5 led and implemented the change. A separate read-only reviewer agent, also Claude Opus 5.5, audited the diff twice; everything it marked as a blocker or should-fix was addressed.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

… 95 % of its budget (D3D12-16GB-WINDOWS-BAR-LINE)

With a windows cap set (the launcher's 3072 or -WindowsBarMB, not 0), play-nvidia.ps1 now sets
LEONIDA_WINDOWS_BAR_LINE=95 on PCs with under 20 GB of RAM (16 GB class) and a card known to have
8 GB or more (7 GB and up by the driver's key; an RTX 4060 Laptop reads 8,188 MiB). There the PC's
memory runs out before the card's: windows refused at the runtime's line of 80 stay in RAM and frames
stall. RTX 4060 Laptop 8 GB, 16 GB PC, four ABBA pairs: medians 5.8 ms (+-1.9 SE) lower on average,
frame lines over 100 ms 16/116 -> 4/112, the card at about 100 % of its budget.
20 GB and more, 6 GB cards and unknown card sizes keep 80; -More @{LEONIDA_WINDOWS_BAR_LINE='80'}
keeps 80.
@andrew-ai

Copy link
Copy Markdown

The new line default is calculated before the final window cap is known. Using this PR's launcher dry-run fixture (16003 MiB RAM, 8188 MiB VRAM) at f777fd4:

-WindowsBarMB Cap from -More Final cap (MiB) Final line
3072 absent 3072 95
0 3072 3072 unset (runtime 80)
0 absent 0 unset
3072 0 0 95

The second invocation enables the same 3072 MiB cap as the first through the documented higher-priority option, yet misses the new 95 percent default. Computing that default after the cap overrides have been applied, only if the line itself is still unset, would preserve an explicit line override. These were synthetic settings checks without a game or a performance measurement. Codex-assisted.

@merzleckeier

Copy link
Copy Markdown
Contributor

Saved F1 values and actual restart arguments show two more ways to miss the intended limit.

I used the PR’s PowerShell dry-run fixture at f777fd432 on 913b88b90 with 16,003 MiB RAM and 8,188 MiB VRAM, and repeated it with #2761 layered in. The results match in both trees.

Invocation or saved setting Final cap Final line
Defaults 3072 MiB 95
leonida-settings.txt sets LEONIDA_WINDOWS_BAR_MB=0 0 MiB 95 (inactive)
-MenuRestart -WindowsBarMB 0 with LEONIDA_WINDOWS_BAR_MB=3072 in the saved file 3072 MiB unset (runtime 80)
Saved explicit LEONIDA_WINDOWS_BAR_LINE=80 3072 MiB 80

I also replayed the exact LEONIDA_MENU_ARGS emitted for -More @{LEONIDA_WINDOWS_BAR_LINE="80"}. With no saved line, the first dry run gives 80 and the replay gives 95 at the same cap. The existing restart argument builder omits -More. On the #2761-only control the same replay falls back to the runtime’s 80, so the new default makes that existing omission visible. The real launcher clears inherited LEONIDA_* settings apart from its path allowlist before setting the new values. The saved-cap path needs the final cap to be known, and preserving an explicit line across restart is a separate issue. Synthetic configuration only. AI-assisted with OpenAI Codex and independent raw-result verification.

…12-16GB-WINDOWS-BAR-LINE)

The 95 line was decided before the F1 menu file's values and -More were merged, so a cap set or
cleared there got the wrong line (review on ProjectLeonida#3002: -WindowsBarMB 0 with -More cap 3072 -> no line;
-More or menu-file cap 0 -> 95; -MenuRestart -WindowsBarMB 0 with saved cap 3072 -> no line).
It is now decided after the merge, from the final LEONIDA_WINDOWS_BAR_MB (a whole number > 0, as
shadow.rs reads it), and only when neither -More nor the menu file names LEONIDA_WINDOWS_BAR_LINE
(an empty value there unsets it, as for any setting). It is never written to the menu file.
Tests cover each row of both review tables.
@valenciana-nc

valenciana-nc commented Dec 2, 2026 •

Copy link
Copy Markdown
Author

Thanks @andrew-ai and @merzleckeier, both right: the line was decided before the final cap was known. Fixed in 09c9e9b.

The 95 line is now decided after the launcher's settings, the F1 menu file and -More are merged. It is set only when the final LEONIDA_WINDOWS_BAR_MB is a whole number above 0 (as shadow.rs reads it) and neither -More nor the menu file names LEONIDA_WINDOWS_BAR_LINE. An empty value there unsets it to the runtime's 80, as for any setting. The decided line is never written to leonida-settings.txt: the launcher writes that file only from the file's own values, and the runtime's menu saves only its own items.

New test rows in tests/test_win_launchers.py (16,003 MiB RAM, 8,188 MiB card; cap / line):

Invocation or saved setting f777fd4 now
-WindowsBarMB 0 -More @{LEONIDA_WINDOWS_BAR_MB='3072'} 3072 / unset 3072 / 95
-WindowsBarMB 3072 -More @{LEONIDA_WINDOWS_BAR_MB='0'} 0 / 95 0 / unset
saved LEONIDA_WINDOWS_BAR_MB=0 0 / 95 0 / unset
-MenuRestart -WindowsBarMB 0, saved LEONIDA_WINDOWS_BAR_MB=3072 3072 / unset 3072 / 95
saved LEONIDA_WINDOWS_BAR_LINE=80 3072 / 80 3072 / 80
saved LEONIDA_WINDOWS_BAR_LINE= (empty) 3072 / unset 3072 / unset
-More @{LEONIDA_WINDOWS_BAR_LINE='80'} 3072 / 80 3072 / 80

The restart replay dropping -More affects every -More setting and was there before this PR, so it is left out of this one and filed as a finding: #2570 (comment). The README now says the line in leonida-settings.txt is the opt-out that lasts across restarts; -More holds for one start.

Tested: python -I tests/test_win_launchers.py (the test fails on f777fd4 and on main, passes now), test_docs_*, test_d3d12_switches.py, check_no_game_data.py. Synthetic settings only, no game run.

AI-assisted: Claude Opus 5.5; reviewed by a separate read-only Claude Opus 5.5 agent.

@andrew-ai

Copy link
Copy Markdown

Rechecked 09c9e9b on Windows. The 14-case launcher test passes. I also supplied conflicting menu-file and -More values in the same dry run using the 16003 MiB RAM / 8188 MiB VRAM fixture. A saved cap of 0 overridden to 3072 produced line 95. A saved cap of 3072 overridden to 0 left the line unset. A saved line of 82 overridden to 87 produced 87. This resolves my cap-precedence finding for a single launch. These checks exercised settings only. Codex-assisted.

@Krashgamer

Copy link
Copy Markdown
Contributor

Heads-up from #3035 (no action needed now): it changes the same launcher block for the other end - PCs of 20 GB or more with a card under 12 GB keep the title memory windows off the card (measured on an RTX 3080 10 GB / 32 GB, numbers there). The two rules never overlap (yours: under 20 GB), but the files conflict textually, and your test's 32 GB / 8 GB case (32,606 / 8,188 MiB) expecting the 3072 cap would flip with mine. If yours lands first I'll rebase mine onto your Case harness and flip that assertion.

@valenciana-nc

Copy link
Copy Markdown
Author

Thanks @Krashgamer, agreed. The two rules don't overlap, so whichever lands second just merges main: if #3035 goes first, I'll merge it into this branch and turn the 32 GB / 8 GB case into your expectation, with the cap off for a card under 12 GB.

AI-assisted: yes (Claude Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants