diff --git a/d3d12/README.md b/d3d12/README.md index d730b36e59..c45ee2fd66 100644 --- a/d3d12/README.md +++ b/d3d12/README.md @@ -545,8 +545,18 @@ What to expect: the card share half the RAM), unless the card has under 6 GB, and leaves it off otherwise. It only takes effect where the card has GPU upload heaps (resizable BAR, and a Windows and driver that offer it): without them the - runtime logs once that the cap does nothing. Pass a cap in - MiB to `play-nvidia.ps1` or any resolution wrapper to choose for yourself: + runtime logs once that the cap does nothing. With a cap set in the end (by the + launcher, `-WindowsBarMB`, the F1 menu file or `-More`), PCs of 16 GB or less + (under 20 GB) with a card of 8 GB or more also get + `LEONIDA_WINDOWS_BAR_LINE=95` (the runtime's default is 80): windows go to the + card until it is at 95 % of its budget instead of 80, as there the PC's memory + runs out before the card's (measured on an 8 GB RTX 4060 Laptop: fewer frames + over 100 ms, [docs/findings.md](docs/findings.md)). PCs of 20 GB and more, + 6 GB cards and cards of unknown size keep 80, and + `LEONIDA_WINDOWS_BAR_LINE=80` in `leonida-settings.txt` keeps 80 + (`-More @{LEONIDA_WINDOWS_BAR_LINE='80'}` keeps it for that start only: the + F1 menu's restart does not repeat `-More`). Pass a cap in MiB to + `play-nvidia.ps1` or any resolution wrapper to choose for yourself: `-WindowsBarMB 0` disables it, and `-More @{LEONIDA_WINDOWS_BAR_MB='...'}` takes precedence. diff --git a/d3d12/docs/findings.md b/d3d12/docs/findings.md index 4bb292e357..afff9a0dff 100644 --- a/d3d12/docs/findings.md +++ b/d3d12/docs/findings.md @@ -1731,6 +1731,49 @@ either a rendered one (mean grey difference 0.05 to 0.3 of 255 against its own r a later flight was at them and fetched again whole), 61,000: the pieces caught in between are a small part of it, and what else puts card bytes there that never come back is not found yet. +## The windows' line on a 16 GB PC (2026-12-01) + +Core i7-13650HX (14 cores, 20 threads), GeForce RTX 4060 Laptop GPU 8 GB (driver 610.62, resizable BAR on: BAR1 +8192 MiB, PCIe 4.0 x8), 16 GB of RAM, Windows 11 Home. `play-d3d12.ps1 -SeriesS -Resolution 540 -NoDlss -NoFrameGen` +(diagnostics build of 1fff691), the same save put back before each start, 200 s measured from the world (the first +20 s left out), a frame line about every 5 s. A is the launcher as it was (`LEONIDA_WINDOWS_BAR_MB=3072`, the line +at the runtime's 80), B the same with `LEONIDA_WINDOWS_BAR_LINE=95`, in the order A B B A A B B A: + +| Run | Side | Median ms | p90 ms | Worst ms | Frame lines over 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 | 1,057.7 | 2 of 28 | +| 4 | A | 47.1 | 628.0 | 750.0 | 6 of 28 | +| 5 | A | 52.9 | 607.9 | 2,775.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 | + +Separate runs, not `LEONIDA_AB`: the runtime reads the line once (`window_mapped_line`), so it cannot be turned while +the title runs. The pairs' medians (A - B): +3.1, +7.5, +10.3, +2.4 ms, so medians 5.8 ms (+-1.9 SE) lower on average +over the four ABBA pairs, B lower in all four. Frame lines over 100 ms: A 16 of 116, B 4 of 112. Here the PC's memory +runs out before the card's: with 80 the windows the line refuses stay in the PC's memory, and by the runtime's own +lines the PC had 39 to 278 MB of physical memory free at the least with A and 150 to 304 MB with B; the card's memory +shared with the PC was 4.27 to 4.53 GB at the most with A and 3.88 to 3.92 GB with B. With 95 the card ran at about +100 % of its budget: its own memory in use 6.97 to 7.14 GB at the most of about 7.1 GB, against 6.80 to 6.90 GB with +80. Starts with the launcher as it was had multi-second stalls before these runs too (one run: 18 of 38 frame lines +over 100 ms, frames of up to 2.5 s, the PC at 74 MB free). + +The textures, by the runtime's `memory of textures` line at each run's end (runs 2 to 8; run 1's log was lost): host +copies of textures the title fills let go since the start, A 91,800, 91,992, 92,558 against B 93,430, 94,449, 95,185, +96,511; made again, A 22,597, 22,876, 22,893 against B 23,867, 24,783, 25,025, 26,430; alive at the end, A 9,025 to +9,109 (676 to 716 MB) against B 9,273 to 11,699 (698 to 771 MB); title textures with no host copy yet, A 74,043 to +75,003 against B 75,027 to 76,280; passes that made none for lack of room, A 12, 0, 20 against B 21, 30, 0, 29. So +with 95 about 3 % more copies were let go (1 to 5 %) and about 10 % more made again (4 to 17 %), slightly more +alive. The picture was not compared. + +The launcher sets 95 since, where the start ends with a cap (its own 3072, `-WindowsBarMB`, the F1 menu file's or +`-More`'s) and no line, on PCs under 20 GB (this one reads 16,003 MiB) with a card known to have 8 GB or more (7 GB +and up by its driver's key: this one reads 8,188 MiB). PCs of 20 GB and more, 6 GB cards and cards of unknown size +keep 80. Fewer buffer copies on the card (`LEONIDA_CARD_BUFFERS_MB=512` against the launcher's 1536, one run) were far +worse here: 115.9 ms median, the card 95 % busy. Not measured: PCs under 16 GB and of 20 to 47 GB, other cards, AMD. + ## Mesh programs on 32-lane waves, and their own output counts (2026-11-28) The indirect mesh draws (ExecuteIndirect kind 10) are 26 to 35 ms of a timing run's 53 to 65 ms frame on the diff --git a/d3d12/docs/switches.md b/d3d12/docs/switches.md index 33bc9b3cc9..deb3967a88 100644 --- a/d3d12/docs/switches.md +++ b/d3d12/docs/switches.md @@ -615,7 +615,7 @@ and [how to measure frame rates](../../docs/measuring_fps.md) before trying one. | `LEONIDA_WIDE_SPIN` | see the code | | | | `leonida-gpu/shadow.rs` +1 | Waits awake until `there` says so, `LEONIDA_WIDE_SPIN` microseconds at most (0, the default: not at all): asleep, a thread is woken in 50 us and more, 95 times a frame. | | `LEONIDA_WIDE_TEXTURES` | see the code | | | | `leonida-gpu/host.rs` | Whether a submission's textures are brought up to date on several threads (`LEONIDA_WIDE_TEXTURES=0`: one after the other, where the lists name them, as before). | | `LEONIDA_WIDE_THREADS` | see the code | | | | `leonida-gpu/shadow.rs` | `LEONIDA_WIDE_THREADS=<n>`: that many helper threads, whatever the PC has. | -| `LEONIDA_WINDOWS_BAR_LINE` | see the code | | | | `leonida-gpu/shadow.rs` | `LEONIDA_WINDOWS_BAR_LINE`, 80 unless set (to 50 to 97). | +| `LEONIDA_WINDOWS_BAR_LINE` | see the code | | yes | yes | `leonida-gpu/shadow.rs` +1 | `LEONIDA_WINDOWS_BAR_LINE`, 80 unless set (to 50 to 97). | | `LEONIDA_WINDOWS_BAR_MB` | see the code | | yes | yes | `leonida-gpu/shadow.rs` +1 | The most bytes of windows outside buffers that lie in the card's memory and are filled by the CPU through the bus (`LEONIDA_WINDOWS_BAR_MB`; 0, the default, none): one buffer (`D3D12_HEAP_TYPE_GPU_UPLOAD`), no CPU's side... | | `LEONIDA_WINDOWS_OWN` | see the code | | | | `leonida-gpu/shadow.rs` | Whether windows outside buffers have two sides too, so that submissions in the air read the bytes they were prepared with (`LEONIDA_WINDOWS_OWN=1`; off by default: it takes the windows' bytes again, 3.3 GB in capture rep... | | `LEONIDA_WINDOW_KB` | see the code | | | | `leonida-gpu/shadow.rs` | The grid the windows of asks with a length are cut on, in bytes: 4 MiB unless `LEONIDA_WINDOW_KB` names a smaller power of two (64 at least). | diff --git a/d3d12/scripts/play-nvidia.ps1 b/d3d12/scripts/play-nvidia.ps1 index 26862777f5..d53527eaea 100644 --- a/d3d12/scripts/play-nvidia.ps1 +++ b/d3d12/scripts/play-nvidia.ps1 @@ -56,6 +56,7 @@ # -Capture F9 in the game saves that frame and the pictures it drew, in %LOCALAPPDATA%\Leonida\captures # -WindowsBarMB maximum MiB of title memory windows in CPU-mapped VRAM, which needs resizable BAR (by default # 3072 on PCs with under 48 GB of RAM, unless the card has under 6 GB, else 0; -WindowsBarMB 0 turns it off). +# With a cap, PCs of 16 GB or less with a card of 8 GB or more get LEONIDA_WINDOWS_BAR_LINE 95 (the runtime's 80). # -More other settings: -More @{LEONIDA_PANEL='1'} # -PcGlyphs a folder of your own pictures for the keyboard-and-mouse button prompts (docs/prompt_glyphs.md) # instead of the built-in key caps @@ -495,6 +496,7 @@ if (-not $MotionBlur) { $settings.LEONIDA_SKIP_PIPELINES = if ($settings.LEONIDA_SKIP_PIPELINES) { "$($settings.LEONIDA_SKIP_PIPELINES),$mb" } else { $mb } } if ($Adapter) { $settings.LEONIDA_ADAPTER = $Adapter } +$ram = try { (Get-CimInstance Win32_ComputerSystem -ErrorAction Stop).TotalPhysicalMemory } catch { 0 } if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { $settings.LEONIDA_WINDOWS_BAR_MB = $WindowsBarMB.ToString([Globalization.CultureInfo]::InvariantCulture) } else { @@ -504,7 +506,6 @@ if ($PSBoundParameters.ContainsKey('WindowsBarMB')) { # Under 48 GB since 2026-11-27: on a 32 GB PC the layer held 28 GB (19 of it in memory), the PC had 745 MB # free and read 100-200 pages a second from the page file; with the windows in the card's memory it held 24.7 # GB and the PC had 3 GB free. The frame took as long either way. - $ram = try { (Get-CimInstance Win32_ComputerSystem -ErrorAction Stop).TotalPhysicalMemory } catch { 0 } if ($ram -gt 0 -and $ram -lt 48GB -and -not $smallCard) { $settings.LEONIDA_WINDOWS_BAR_MB = '3072' # Only a card with GPU upload heaps (resizable BAR, and a Windows and driver that offer it) has that memory; @@ -610,6 +611,27 @@ if (-not $DryRun -and $menu.Count -ne $menuRead) { # Leonida: the runs write down the pipelines the title creates (pipeline/known.rs), for the precompile below. if (-not $NoPrecompile) { $settings.LEONIDA_PIPELINE_BOOK = '1' } foreach ($k in $More.Keys) { $settings[$k] = $More[$k] } +# With a cap in the end (the launcher's, -WindowsBarMB, the F1 menu file's or -More's: decided here, after all of +# them), PCs of 16 GB or less (under 20 GB: a 16 GB PC reads 15.6) with a card of 8 GB (7 GB and up: an RTX 4060 +# Laptop's reads 4 MiB under 8) or more get the windows' line at 95 (LEONIDA_WINDOWS_BAR_LINE: windows go to the card +# while its memory in use and the window stay under that many hundredths of its budget; the runtime's 80 unless set): +# there the PC's memory runs out before the card's. RTX 4060 Laptop 8 GB, 16 GB PC, Series S at 540 lines, four ABBA +# pairs of 200 s runs from one save (2026-12-01): with 80 the windows refused stayed in the PC's memory (4.3 to 4.5 GB +# shared with the card at the most), the PC had 39 to 278 MB free at the least and 16 of 116 frame lines were over 100 +# ms (up to 2.8 s a frame); with 95 3.9 GB shared, 150 to 304 MB free, 4 of 112, and the card at about 100 % of its +# budget (6.97 to 7.14 GB in use of about 7.1, against 6.80 to 6.90 with 80). Medians 5.8 ms (+-1.9 SE) lower on +# average, lower in every pair. 20 GB and more, cards of 6 GB and cards of unknown size keep 80 (not measured). A line +# -More or the menu file sets is kept, and their empty value unsets it as any other setting (the runtime's 80). The +# cap is read as the runtime reads it (a whole number of MiB; 0 or none: off). Not saved in the menu file: each start +# decides it again. +[uint64]$barMB = 0 +$barOn = [uint64]::TryParse("$($settings.LEONIDA_WINDOWS_BAR_MB)".Trim(), [Globalization.NumberStyles]::AllowLeadingSign, + [Globalization.CultureInfo]::InvariantCulture, [ref]$barMB) -and $barMB -gt 0 +if ($barOn -and -not $settings.ContainsKey('LEONIDA_WINDOWS_BAR_LINE') -and -not $menu.Contains('LEONIDA_WINDOWS_BAR_LINE') -and + $ram -gt 0 -and $ram -lt 20GB -and $vram -ge 7GB) { + $settings.LEONIDA_WINDOWS_BAR_LINE = '95' + Write-Host "Title memory windows go to the card while it is under 95 % of its budget, not 80 (LEONIDA_WINDOWS_BAR_LINE=80 in leonida-settings.txt, or -More for one start, keeps 80)" +} # DLSS only where it can be: a menu choice of it without the files or the build falls back to the stretch # (Series X: to the title's own upscaler, which is sharper than a stretch to 3840x2160). if ($settings.LEONIDA_UPSCALE -eq 'dlss' -and -not $dlssCan) { diff --git a/tests/test_win_launchers.py b/tests/test_win_launchers.py index 6dd78303dd..f2a1925706 100644 --- a/tests/test_win_launchers.py +++ b/tests/test_win_launchers.py @@ -38,52 +38,147 @@ """ -class WinLaunchersTests(unittest.TestCase): - @unittest.skipUnless(POWERSHELL, "requires PowerShell") - def test_nvidia_menu_restart_preserves_motion_blur_switch(self) -> None: - with tempfile.TemporaryDirectory() as td: - root = Path(td) - scripts = root / "scripts" - scripts.mkdir() - launcher = scripts / NVIDIA_LAUNCHER.name - shutil.copyfile(NVIDIA_LAUNCHER, launcher) - executable = root / "synthetic title.exe" - executable.touch() - - command = r""" +# The calling scope of the NVIDIA launcher's dry runs: Windows' build, and the PC's RAM and the card's memory in MiB +# from $env:TEST_RAM_MB and $env:TEST_VRAM_MB (unset: the query fails, as on a PC that does not say), whatever machine +# runs the test. `Case