d3d12: fewer hitches in dense city scenes (opt-in submission/copy switches + memory pressure), measured on an RTX 5080 #3374

Open
henriazz10 wants to merge 1 commit from upstream-pr/3374 into main
henriazz10 commented 2026-12-03 17:43:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by henriazz10 on 2026-12-03T17:43:55Z.


Claimed in the coordination issue as: D3D12-SERIES-X-DLSS-WORLD (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7334635211). This is its submission and memory part, split out of #3039 (closed) so that each pull request has one topic.

What and why

In dense city scenes with -SeriesX -Dlss quality the frame rate drops and the game hitches: the submitting thread spends 30+ ms a frame outside preparing, and the process sits under 1 GB of free RAM with 6+ GB spilled into shared VRAM. This pull request cuts both. Every change is behind its own LEONIDA_* switch, off in code; only scripts/play-nvidia.ps1 turns them on, so leonida.exe alone behaves as on main.

Submission and copy switches (move work off the submitting thread; its time outside preparing goes from 32-38 ms to 19-21 ms a frame):

  • TEXTURE_FAST_QUEUE, COPIES_FILLS_FAST, WATCH_FAST_JOURNAL, FLUSH_FAST_NOOP(_V2);
  • UNIFIED_ALIAS_RANGE / UNIFIED_ALIAS_TRACK;
  • OFF_LINE, COPY_SUBRESOURCE_FIX, COPY_GUARD, ASK_FIRST, SNAP_BESIDE;
  • AHEAD_BUFFERS_ONLY, SEND_SKIP_LAND, UPSCALE_SYNC, PIPELINE_ASYNC_MESH.

Shader waits. The launcher's LEONIDA_PIPELINE_WAIT_MS goes from 10000 to 50. New mesh pipelines were waited for one by one: in a play session, frames up to 6.2 s and 72 frames over 1 s in 11 minutes.

Memory pressure

In the city the process runs with under 1 GB of free RAM and 6+ GB in shared VRAM. Every change is behind its own switch. play-nvidia.ps1 turns on only the ones that measured with no fps cost:

Switch In play-nvidia.ps1 What it does
LEONIDA_MEM_LINE_10S 1 One memory breakdown line every 10 s (shared/dedicated VRAM, pools, windows, textures).
LEONIDA_ALLOCATOR_TRIM 1 Already in main; turned on.
LEONIDA_SMALL_POOL_SPLIT 1 Splits the small shared buffer pool by size class. Holes in it dropped from about 1 GB to 250-290 MB.
LEONIDA_POOL_PACK 1 New allocations go to the fullest block first, so empty blocks can be released.
LEONIDA_WINDOW_REUSE_MB 128 Reuses retired PC-only loose windows.
LEONIDA_SHARED_VRAM_CAP_MB 5120 Above this much shared VRAM, drains empty small, staging and spare-window blocks and evicts idle textures. Textures are evicted only when local VRAM is also at 90 % or more.
LEONIDA_CARD_BUFFERS_SMALL_CAP_PCT 50 Buffers under 64 KiB may take up to this share of LEONIDA_CARD_BUFFERS_MB; the rest stays for large buffers.
LEONIDA_CARD_BUFFERS_REAL_LEN_KB off Opt-in. Its blanket cutoff sent hot small buffers over PCIe (heap buffers 4.3 -> 8.1 ms/frame).
LEONIDA_TAKE_BLOCK_BYTES off Opt-in. Sub-page block diffing in the shadow copies.

Measured in the city (-SeriesX -Dlss quality, LEONIDA_PIPELINE_WAIT_MS=50, log fps). After the world loads, LEONIDA_GAME_ACTIONS_RUN teleports the player into the city at 150 s and 200 s. Only the last 3 minutes of each 5-minute run count; one warm-up, then alternated runs:

Build Run fps median frame frames >100 ms per min frames >1 s longest frame shared VRAM private RAM
switches only 1 14.2 67 ms 57 0 489 ms 6.3 GB 32.7 GB
switches only 2 14.3 68 ms 61 0 292 ms 6.5 GB 33.0 GB
switches + memory 1 14.7 65 ms 25 0 170 ms 5.8 GB 32.2 GB
switches + memory 2 15.5 63 ms 20 0 242 ms 6.0 GB 32.3 GB

About 6 % more fps, a third of the frames over 100 ms, and about 0.5 GB less shared VRAM and private memory. In the starting area (low pressure, 3 runs each) the two are within noise: 13.5 / 13.8 / 12.4 fps without, 13.0 / 13.7 / 12.3 with, same memory.

An earlier version also turned on CARD_BUFFERS_REAL_LEN_KB=64, CARD_RESERVE_BUDGETS=1, CARD_WINDOWS_MB=1024 and a 4096 MB shared cap, and lost about 25 % fps: hot small buffers went to system RAM, unused budget was counted as used VRAM, and the cap sat below the normal shared floor (3.8-4.4 GB) and evicted textures every 1.5 s with 2.5 GB of dedicated VRAM free. Those are off here, and eviction is gated on local VRAM pressure.

Not tested: the player stands still in the city in every run (no fast driving); only one machine (32 GB RAM); these memory runs were on main a917c54d6; the A/B against current main below has everything.

Tested

Against current main (acb0657e2), #3039 before the split. Same method as above: -SeriesX -Dlss quality -NoFrameGen -NoSmoothMotion -NoPrecompile, LEONIDA_PIPELINE_WAIT_MS=50, each build with its own play-nvidia.ps1, teleport into the city once the world loads, last 120 s measured, builds alternated. Two rounds were run; the first main run of the first round is left out because the title sat in the pause menu while shaders compiled on a cold cache (59.8 fps, 2.9 GB shared VRAM), and the first run of this branch's new build had one 3.2 s frame on the same cold cache.

Build Run fps median frame p99 frames >100 ms per min frames >1 s longest frame shared VRAM private RAM
main acb0657e2 1 13.2 76 ms 157 ms 83 0 487 ms 6.3 GB 32.8 GB
main acb0657e2 2 14.0 70 ms 138 ms 63 0 189 ms 6.0 GB 32.8 GB
main acb0657e2 3 13.9 71 ms 139 ms 66 0 310 ms 6.1 GB 32.8 GB
this branch (cold cache) 0 11.1 74 ms 298 ms 71 2 3212 ms 6.1 GB 32.6 GB
this branch 1 14.7 63 ms 114 ms 37 0 766 ms 6.2 GB 33.1 GB
this branch 2 15.3 62 ms 115 ms 25 0 452 ms 6.1 GB 32.7 GB
this branch 3 15.0 62 ms 191 ms 55 0 898 ms 6.2 GB 32.8 GB

Averages over the warm runs: 15.0 fps against 13.7 (+9.5 %), median frame 62 ms against 72 ms, and 39 frames over 100 ms a minute against 70. Every run of this branch beats every run of main. Memory is the same on both (about 6 GB shared VRAM, 33 GB private). No device loss and no unclosed list.

What #3039 had and this pull request leaves out: LEONIDA_FSR_MODE_FIX (the Series X FidelityFX quality-mode store; main already draws the world with DLSS without it) and the F4 menu item Teleport -> To waypoint. The mode fix was on in the runs above (the waypoint item does nothing unless used); this exact head was not re-run in the title.

On this head (main acb0657e2 + one commit): the diag build finished. leonida-gpu: 756 passed, 0 failed (59 ignored), --test-threads=1. leonida-loader: 91 passed. leonida-menu: 48 passed. leonida: 43 + 2 + 2 + 1 passed. cargo clippy -p leonida-loader -p leonida-gpu -p leonida --all-targets --features dlss -- -D warnings: clean. docs/switches.md regenerated; tests/test_d3d12_switches.py: OK. scripts/check_no_game_data.py on the changed files: clean.

GPUs tested: NVIDIA GeForce RTX 5080 16 GB, driver 616.92, Windows 11 (build 26300), Ryzen 9 5950X, 32 GB RAM.

AI-assisted: yes. Gemini wrote most of the change; Claude Code (Claude Opus 5.5) reviewed it, fixed compile errors, merged main, ran the checks and measured it in the title.

Checklist

  • Based on current main (acb0657e2) and merges cleanly.
  • One topic: fewer hitches in dense scenes, through submission/copy work and memory pressure, all behind opt-in switches.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • No new translator rule.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5631825525 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3374). Originally posted by [henriazz10](https://github.com/henriazz10) on 2026-12-03T17:43:55Z. --- Claimed in the coordination issue as: D3D12-SERIES-X-DLSS-WORLD (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7334635211). This is its submission and memory part, split out of #3039 (closed) so that each pull request has one topic. ### What and why In dense city scenes with `-SeriesX -Dlss quality` the frame rate drops and the game hitches: the submitting thread spends 30+ ms a frame outside preparing, and the process sits under 1 GB of free RAM with 6+ GB spilled into shared VRAM. This pull request cuts both. Every change is behind its own `LEONIDA_*` switch, off in code; only `scripts/play-nvidia.ps1` turns them on, so `leonida.exe` alone behaves as on `main`. **Submission and copy switches** (move work off the submitting thread; its time outside preparing goes from 32-38 ms to 19-21 ms a frame): - `TEXTURE_FAST_QUEUE`, `COPIES_FILLS_FAST`, `WATCH_FAST_JOURNAL`, `FLUSH_FAST_NOOP(_V2)`; - `UNIFIED_ALIAS_RANGE` / `UNIFIED_ALIAS_TRACK`; - `OFF_LINE`, `COPY_SUBRESOURCE_FIX`, `COPY_GUARD`, `ASK_FIRST`, `SNAP_BESIDE`; - `AHEAD_BUFFERS_ONLY`, `SEND_SKIP_LAND`, `UPSCALE_SYNC`, `PIPELINE_ASYNC_MESH`. **Shader waits.** The launcher's `LEONIDA_PIPELINE_WAIT_MS` goes from 10000 to 50. New mesh pipelines were waited for one by one: in a play session, frames up to 6.2 s and 72 frames over 1 s in 11 minutes. ### Memory pressure In the city the process runs with under 1 GB of free RAM and 6+ GB in shared VRAM. Every change is behind its own switch. `play-nvidia.ps1` turns on only the ones that measured with no fps cost: | Switch | In `play-nvidia.ps1` | What it does | |---|---|---| | `LEONIDA_MEM_LINE_10S` | `1` | One memory breakdown line every 10 s (shared/dedicated VRAM, pools, windows, textures). | | `LEONIDA_ALLOCATOR_TRIM` | `1` | Already in main; turned on. | | `LEONIDA_SMALL_POOL_SPLIT` | `1` | Splits the small shared buffer pool by size class. Holes in it dropped from about 1 GB to 250-290 MB. | | `LEONIDA_POOL_PACK` | `1` | New allocations go to the fullest block first, so empty blocks can be released. | | `LEONIDA_WINDOW_REUSE_MB` | `128` | Reuses retired PC-only loose windows. | | `LEONIDA_SHARED_VRAM_CAP_MB` | `5120` | Above this much shared VRAM, drains empty small, staging and spare-window blocks and evicts idle textures. Textures are evicted only when local VRAM is also at 90 % or more. | | `LEONIDA_CARD_BUFFERS_SMALL_CAP_PCT` | `50` | Buffers under 64 KiB may take up to this share of `LEONIDA_CARD_BUFFERS_MB`; the rest stays for large buffers. | | `LEONIDA_CARD_BUFFERS_REAL_LEN_KB` | off | Opt-in. Its blanket cutoff sent hot small buffers over PCIe (`heap buffers` 4.3 -> 8.1 ms/frame). | | `LEONIDA_TAKE_BLOCK_BYTES` | off | Opt-in. Sub-page block diffing in the shadow copies. | **Measured in the city** (`-SeriesX -Dlss quality`, `LEONIDA_PIPELINE_WAIT_MS=50`, log fps). After the world loads, `LEONIDA_GAME_ACTIONS_RUN` teleports the player into the city at 150 s and 200 s. Only the last 3 minutes of each 5-minute run count; one warm-up, then alternated runs: | Build | Run | fps | median frame | frames >100 ms per min | frames >1 s | longest frame | shared VRAM | private RAM | |---|---|---|---|---|---|---|---|---| | switches only | 1 | 14.2 | 67 ms | 57 | 0 | 489 ms | 6.3 GB | 32.7 GB | | switches only | 2 | 14.3 | 68 ms | 61 | 0 | 292 ms | 6.5 GB | 33.0 GB | | **switches + memory** | 1 | **14.7** | **65 ms** | **25** | 0 | **170 ms** | **5.8 GB** | **32.2 GB** | | **switches + memory** | 2 | **15.5** | **63 ms** | **20** | 0 | **242 ms** | **6.0 GB** | **32.3 GB** | About 6 % more fps, a third of the frames over 100 ms, and about 0.5 GB less shared VRAM and private memory. In the starting area (low pressure, 3 runs each) the two are within noise: 13.5 / 13.8 / 12.4 fps without, 13.0 / 13.7 / 12.3 with, same memory. An earlier version also turned on `CARD_BUFFERS_REAL_LEN_KB=64`, `CARD_RESERVE_BUDGETS=1`, `CARD_WINDOWS_MB=1024` and a 4096 MB shared cap, and lost about 25 % fps: hot small buffers went to system RAM, unused budget was counted as used VRAM, and the cap sat below the normal shared floor (3.8-4.4 GB) and evicted textures every 1.5 s with 2.5 GB of dedicated VRAM free. Those are off here, and eviction is gated on local VRAM pressure. Not tested: the player stands still in the city in every run (no fast driving); only one machine (32 GB RAM); these memory runs were on main a917c54d6; the A/B against current main below has everything. ### Tested **Against current `main` (acb0657e2), #3039 before the split.** Same method as above: `-SeriesX -Dlss quality -NoFrameGen -NoSmoothMotion -NoPrecompile`, `LEONIDA_PIPELINE_WAIT_MS=50`, each build with its own `play-nvidia.ps1`, teleport into the city once the world loads, last 120 s measured, builds alternated. Two rounds were run; the first `main` run of the first round is left out because the title sat in the pause menu while shaders compiled on a cold cache (59.8 fps, 2.9 GB shared VRAM), and the first run of this branch's new build had one 3.2 s frame on the same cold cache. | Build | Run | fps | median frame | p99 | frames >100 ms per min | frames >1 s | longest frame | shared VRAM | private RAM | |---|---|---|---|---|---|---|---|---|---| | `main` acb0657e2 | 1 | 13.2 | 76 ms | 157 ms | 83 | 0 | 487 ms | 6.3 GB | 32.8 GB | | `main` acb0657e2 | 2 | 14.0 | 70 ms | 138 ms | 63 | 0 | 189 ms | 6.0 GB | 32.8 GB | | `main` acb0657e2 | 3 | 13.9 | 71 ms | 139 ms | 66 | 0 | 310 ms | 6.1 GB | 32.8 GB | | this branch (cold cache) | 0 | 11.1 | 74 ms | 298 ms | 71 | 2 | 3212 ms | 6.1 GB | 32.6 GB | | **this branch** | 1 | **14.7** | **63 ms** | **114 ms** | **37** | 0 | 766 ms | 6.2 GB | 33.1 GB | | **this branch** | 2 | **15.3** | **62 ms** | **115 ms** | **25** | 0 | 452 ms | 6.1 GB | 32.7 GB | | **this branch** | 3 | **15.0** | **62 ms** | 191 ms | **55** | 0 | 898 ms | 6.2 GB | 32.8 GB | Averages over the warm runs: 15.0 fps against 13.7 (+9.5 %), median frame 62 ms against 72 ms, and 39 frames over 100 ms a minute against 70. Every run of this branch beats every run of `main`. Memory is the same on both (about 6 GB shared VRAM, 33 GB private). No device loss and no unclosed list. What #3039 had and this pull request leaves out: `LEONIDA_FSR_MODE_FIX` (the Series X FidelityFX quality-mode store; `main` already draws the world with DLSS without it) and the F4 menu item *Teleport -> To waypoint*. The mode fix was on in the runs above (the waypoint item does nothing unless used); this exact head was not re-run in the title. On this head (`main` acb0657e2 + one commit): the `diag` build finished. leonida-gpu: 756 passed, 0 failed (59 ignored), `--test-threads=1`. leonida-loader: 91 passed. leonida-menu: 48 passed. leonida: 43 + 2 + 2 + 1 passed. `cargo clippy -p leonida-loader -p leonida-gpu -p leonida --all-targets --features dlss -- -D warnings`: clean. `docs/switches.md` regenerated; `tests/test_d3d12_switches.py`: OK. `scripts/check_no_game_data.py` on the changed files: clean. GPUs tested: NVIDIA GeForce RTX 5080 16 GB, driver 616.92, Windows 11 (build 26300), Ryzen 9 5950X, 32 GB RAM. AI-assisted: yes. Gemini wrote most of the change; Claude Code (Claude Opus 5.5) reviewed it, fixed compile errors, merged `main`, ran the checks and measured it in the title. ### Checklist - [x] Based on current `main` (acb0657e2) and merges cleanly. - [x] One topic: fewer hitches in dense scenes, through submission/copy work and memory pressure, all behind opt-in switches. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [x] No new translator rule. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-03 18:02:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T18:02:39Z.


[P2] Keep the new 50 ms shader wait selectable in F1. play-nvidia.ps1 now starts at 50 ms, but SHADER WAIT MS still cycles through 10000, 30000, 1000 and 0. The value 50 is displayed on a fresh start. The first Right press jumps to 10000, and once a different value is saved there is no way to select 50 from that row. This can restore the long shader waits that the launch profile changes. Launcher default · Menu choices

On 67b6dbe4, PowerShell -DryRun printed 50 for a fresh NVIDIA profile. A source-extracted Rust test starting at that value produced 10000 → 30000 → 1000 → 0. With the first selected value in the settings file, -MenuRestart -DryRun printed 10000. Please include a 50 ms option and cover the launcher default in the menu’s cycle test.

AI-assisted with OpenAI Codex. The check used a placeholder executable and did not launch the game.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387505827 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3374#issuecomment-7387505827). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T18:02:39Z. --- **[P2] Keep the new 50 ms shader wait selectable in F1.** `play-nvidia.ps1` now starts at 50 ms, but `SHADER WAIT MS` still cycles through 10000, 30000, 1000 and 0. The value 50 is displayed on a fresh start. The first Right press jumps to 10000, and once a different value is saved there is no way to select 50 from that row. This can restore the long shader waits that the launch profile changes. [Launcher default](https://github.com/ProjectLeonida/mandy/blob/67b6dbe435cb1e169174ac6029b044af16bb3abe/d3d12/scripts/play-nvidia.ps1#L353-L355) · [Menu choices](https://github.com/ProjectLeonida/mandy/blob/67b6dbe435cb1e169174ac6029b044af16bb3abe/d3d12/crates/leonida-gpu/src/host/menu.rs#L111) On `67b6dbe4`, PowerShell `-DryRun` printed 50 for a fresh NVIDIA profile. A source-extracted Rust test starting at that value produced `10000 → 30000 → 1000 → 0`. With the first selected value in the settings file, `-MenuRestart -DryRun` printed 10000. Please include a 50 ms option and cover the launcher default in the menu’s cycle test. AI-assisted with OpenAI Codex. The check used a placeholder executable and did not launch the game.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3374:upstream-pr/3374'
git switch 'upstream-pr/3374'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3374'
git switch 'upstream-pr/3374'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3374'
git switch 'upstream-pr/3374'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3374'
git switch 'main'
git merge --squash 'upstream-pr/3374'
git switch 'main'
git merge --ff-only 'upstream-pr/3374'
git switch 'main'
git merge 'upstream-pr/3374'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3374
No description provided.