d3d12: lists' scratch stays in the PC's memory by default for now (D3D12-SCRATCH-CARD-OFF-BY-DEFAULT) #2819
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2819"
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 TheGeogeo on 2026-12-01T01:40:47Z.
Claimed in the coordination issue as: D3D12-SCRATCH-CARD-OFF-BY-DEFAULT (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7297701069), part of enlighted's D3D12-REAPER-BOUNDED-QUEUE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7293629499), agreed with them.
What and why
Lists' scratch memory goes into the card's own memory, where the CPU maps it, on cards whose budget is 9 GiB or more at the first ask and that have a GPU upload heap (resizable BAR). This came with
7b907de52. On those cards it churns chunks:SPARE_CARDkeeps 256 MiB in all and gives back an exact size only (Spare::take/give).MakeResident.Measured by enlighted on an RTX 3090 24 GB with a resizable BAR, standing 600 s, with
LEONIDA_ABon this switch over 23 pairs:MakeResidentper frameThis turns it off by default for now, until enlighted's pool that keeps the card's spare chunks by size lands. That pool will turn it back on.
LEONIDA_SCRATCH_CARD=1still puts the scratch in the card, andLEONIDA_ABstill switches it.d3d12/docs/switches.mdis regenerated. Only that switch's row changes.Tested
On Windows 11 Pro 10.0, Rust 1.98.1 pinned:
cargo test -p leonida-gpu --lib --locked scratch_card:host::scratch_card_tests::card_scratch_is_off_unless_asked_forpasses. It checks that nothing,0or another value means off, and that1means on.main: the test needs the newscratch_card_chosen, so it does not build there. The behaviour it pins is the default flip, read inscratch_card(). The behavioural proof is enlighted's gate on the 3090, which they will run on this head.cargo clippy -p leonida-gpu --all-targets --lockedadds no warning in the changed lines; the existing warnings elsewhere are as onmain.tools/d3d12_switches.py --check d3d12/docs/switches.md, the docs tests andscripts/check_no_game_data.pyare clean. It merges cleanly with currentmain.GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140: build and unit test only. This card has no GPU upload heap, so the change has no effect on it in game.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T01:42:18Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, head
f8ad7e245, maind920d850d. This is a type-check plus a code read:leonida-gpudoes not build natively on macOS, so the Mac can't run the new unit test or a gate.MEASURED
git merge-treeonto main gives no conflicts.cargo check --target x86_64-pc-windows-msvc(no MSVC; theccbuild steps are replaced with stand-ins), main vs main + this PR, exit 0 on both sides. The sorted warning lists are byte-identical: 19 / 19 default, 11 / 11diagnostics, 24 / 24--tests(this compilesscratch_card_tests), and 19 / 19 forleonida-hle --tests.READ IN CODE
LEONIDA_ABpick stays first inscratch_card()underdiagnostics, so A/B by turns still works both ways.scratch_card_chosen()is a pure function: on only withSome("1"); unset,0and any other value give off. Before,0was off,1on, and anything else meant "by budget". Now anything else means off. The new test pins all four cases.tracing::info!fires only where the old default would have been on: a budget of at least 9 GiB, andhost.mapped_card_memory()(it exists on main, athost.rs:13734). That matches the real old behavior, where without a GPU upload heap the scratch fell back to PC memory anyway (thegeogeo's analysis, seq 2217).switches.mdrow say the new default and why, with enlighted's SC-1 figures, and note that the7b907de52gain is given up for now.ASSUMED
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T02:13:27Z.
Verified on Windows, for a merge (not the author). AI-assisted (Claude Code agent
oreofr-agent). RTX 4070 Laptop 8 GB, NVIDIA 621.40, Core Ultra 7 155H, Windows 11 Pro, Rust 1.98.1 pinned.Head
f8ad7e245merged intomaind920d850dwithgit merge --no-ffin a scratch worktree (clean, 2 files:host.rs,switches.md).check_no_game_data.pyon both: exit 0.Tests (
cargo test --locked -p leonida-gpu, fromd3d12/):only_what_differs_goes_up, already failing on plain main at the time (582 passed, same 1) and fixed since by #2820. No new failure; +1 is the newcard_scratch_is_off_unless_asked_for.scratch_card_chosenput back to the old default (on unless0), the new test fails (host.rs:2494). Reverted, tree clean.In-game run on the merged build (
diagnostics,mimalloc, no DLSS), fresh copy of our gate data,-SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, walking: the keys file (LEONIDA_KEYS_FILE) held W with turns (L/J) in a 14 s loop; the game logged 100 scripted key changes.Limits: this card's budget is under 9 GiB, so it already had the scratch in the PC's memory before this change: the run shows no regression, not the gain. The gain is enlighted's measured A/B on this switch (RTX 3090, 23 pairs), cited in the description; their 3090 gate on this head was announced.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T02:14:49Z.
Verified on Windows: the new test passes, and the crate is one test greener with nothing else moved. The one failure in the crate is
main's, not this pull request's.maind920d850d, cherry-picked (the branch is atmain,merge-base=d920d850d),cargo 1.98.1, warm target:That one failure is red on
mainbefore this diff, and #2820 fixes it - I checked it on a cleanmainearlier today, so it is not yours.mainhas 582 passed and this has 583, which is exactly the one test this adds.What the change is, from the code and the doc line together:
scratch_card_chosen(switch)and a test for it, andLEONIDA_SCRATCH_CARDbecomes "off unless asked for" indocs/switches.md. A default flipping is the kind of change that needs the test that arrives with it, and it is here.What I did not run: the title path itself - lists' scratch actually staying in the PC's memory needs a title with lists to allocate, which needs the game. The switch's decision function and its test are what I can measure, and they are green.
One thing worth checking before merge: #2820 makes the crate green, and this one adds a test to it. Whichever lands second will need the other's context to look green in CI -
host::refresh_tests::only_what_differs_goes_upis red onmaintoday, so this branch will show that red until #2820 lands.AI-assisted: yes - DeepSeek v4.1 (flash), which ran both the new test and the crate.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T02:26:18Z.
RUN (independent run on Windows, #2819 head
f8ad7e245, merged locally into maind920d850dwithgit merge --no-ff, no conflicts. The head still merges cleanly into mainbf19719ab. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.)Commands, in
d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1, all with--locked, at low priority:cargo test -p leonida-gpu --no-fail-fast: main 582 passed / 1 failed / 53 ignored; merge 583 / 1 / 53.card_scratch_is_off_unless_asked_forpasses.cargo test -p leonida-gpu --no-fail-fast --features diagnostics: main 663 / 1 / 54; merge 664 / 1 / 54.host::refresh_tests::only_what_differs_goes_up(assertion, left[]). It fails on main and on the merge alike, in both builds, so it has nothing to do with this PR.scratch_card_chosennot found). That proves only that the function is new.scratch_card_chosenput back to main's default rule (1on,0off, otherwise on where the card's budget is 9 GiB or more, given this card's 24 GiB).cargo test -p leonida-gpu --lib scratch_cardthen fails on!scratch_card_chosen(None). So the test pins the new default, and main's rule fails it on a card like the RTX 3090 here.cargo clippy -p leonida-gpu --all-targets(without-D warnings, which already fails on main in leonida-shader and leonida-lua), on main and on the merge:host.rshas the same 5 warnings on both sides, all outside the changed lines. None is new.d3d12/docs/switches.md:python -I tools/d3d12_switches.py --check d3d12/docs/switches.mdis clean on the merge. A fresh--outto a scratch file is byte-identical to the committed page, on the merge and on main (each against its own sources). Only theLEONIDA_SCRATCH_CARDrow changes.MakeResident, the reaper, frame times). That needs the in-game gate below.In-game gate on the RTX 3090 (24 GB, NVIDIA 621.40, Windows 11), leonida.exe built from this head (
f8ad7e245;d3d12/scripts/build-nvidia.ps1, diag profile, no DLSS files),scripts/play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGenat the launcher's defaults otherwise (noLEONIDA_REAPER=0, no other override), the same save restored, standing still, withLEONIDA_NO_WATCHDOG=1and a stall-mode timeline; warm-up and a throwaway run first. PASS: 600 s, world at 73 s (527 s in the world), no device loss, no gap over 10 s between frames. The log says scratch stays in the PC's memory by default.8f41d7d01on this machine gave 18.0 fps (p5 12.9) and 12.1 fps (p5 5.2, piled up: line 398,312, mapped scratch 10.9 GB, 112.7 GB private). Caveat: this gate ran beside a cargo build (total CPU 92-100 %), so its frame rate is if anything pessimistic; a measured in-run A/B ofLEONIDA_SCRATCH_CARDon this card (23 pairs, standalone) gave 33.3 ms against 64.6 ms per frame.Not checked: Series X, walking, picture; cards between 9 and 16 GB.
No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T02:28:55Z.
Merging. Head
f8ad7e245merges cleanly with maind921489d1(merge commit90c514437).Claim: D3D12-SCRATCH-CARD-OFF-BY-DEFAULT, https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7297701069 (author TheGeogeo), part of enlighted's D3D12-REAPER-BOUNDED-QUEUE, agreed by them.
Red/green: by oreofr-agent (not the author), RTX 4070 Laptop, Windows 11: red by mutation (old default put back, the new test fails), green on this head. I ran
cargo test --locked -p leonida-gpuon this head merged into the current maind921489d1: 589 passed, 0 failed.In-game run: RTX 4070 Laptop 8 GB, NVIDIA 621.40, 330 s in the world walking, 0 device loss (comment above). This card already had the PC scratch before the change, so it shows no regression, not the gain. The gain is enlighted's measured A/B on this switch (RTX 3090, 23 pairs); OreoFR chose in writing not to wait for their 3090 gate on this head.
CI: green on the head (all 5 checks) and on main (CI, No Game Data; Runtime last green on
cd9fe51a9, not triggered since).AI-assisted: yes, Claude Code agent
oreofr-agent, merged on OreoFR's (maintainer) written instruction.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T02:32:25Z.
Correction to my merge comment above: enlighted's RTX 3090 gate on this head was posted two minutes before the merge (https://github.com/ProjectLeonida/mandy/pull/2819#issuecomment-7298614145): PASS, 527 s in the world, 0 device loss, at the default settings; the reaper pile-up gone (queue max 140, private memory flat at 28.9 GB), median 23.3 fps against 18.0 and 12.1 on main. So the change was also run on a card where it takes effect. AI-assisted (Claude Code agent
oreofr-agent).