List scratch in card memory the CPU maps (VICTORY_SCRATCH_CARD=1, off by default) #4332
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4332"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by mstrmoos on 2026-11-30T18:57:52Z.
[pr-performance]
What it changes
On discrete NVIDIA cards, a list's own scratch lies in the PC's memory:
scratch_wb(837bae72) puts it in write-backL0memory. That scratch holds the constants and small data the list's commands read. So every load a shader makes from it crosses the bus.This adds
VICTORY_SCRATCH_CARD=1, off by default. It puts those chunks in card memory the CPU maps (D3D12_HEAP_TYPE_GPU_UPLOAD, a resizable BAR), when the host has it (mapped_card_memory()). It covers the pooled chunks of up to 4 MiB and the one-off chunks over 4 MiB.Two kinds of chunk stay where they were:
The CPU only writes scratch and never reads it back, which matters: the CPU reads card memory at 0.09 GB/s.
Why, measured on an RTX 5080 with
cargo test -p victory-gpu --release --lib host::bus -- --ignored --nocapture:How I found it: an Nsight GPU Trace of a replayed frame showed the card stalled on memory (Long Scoreboard), with 0–3 warps per SM for most of its busy time. I then used
victory replay --buffers vram --only-buffers seen=Cached --only-buffers min=65537 --only-buffers max=4194304to move only the frame's 196 scratch chunks (162 of 256 KiB, 34 of 4 MiB) into the card's memory. The replay's card time went from 27.52 to 25.19 ms.How it was tested
victory-settings.txt, 90 s bench route, same save, game window in front for the whole run. Built from maine1251c31,--profile diag --features diagnostics.VICTORY_SCRATCH_CARD=1): frame 37.0 ms median (27.0 fps), card 90% busy. The title's lists took 27.9–28.7 ms of card time. Our sync lists were 0.7–1.0 ms before and 1.0–1.1 ms after.mapped_card_memory()is false), and integrated GPUs.cargo testpassed for the crates it touches:cargo test --locked -p victory-gpu --libgives the same result as on main (1131 passed). The 2 failures, and the 2 Clippy errors from--all-targets(shadow.rsranged,host.rs:5116), are on main already; the first two are fixed by #4025.Checked for overlap
CBV_CARD, which copies constants the card writes). None moves list scratch into card memory.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:42:40Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:44:15Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed