Unified memory: copy back only the aliased sub-ranges of a write-combined piece (VICTORY_UNIFIED_ALIAS_RANGE) #4776
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4776
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4775"
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?
@henriazz10 on GitHub · 2026-12-01 07:24 UTC · original
henriazz10:perf/copy-back-range1k→main· +677 −52 · 2 files · 4 commits · closed without mergingRefs #4426
What it changes
On the console the CPU and the GPU share one memory; on PC every write the title's shaders make to write-combined memory has to be copied back to system memory in case another copy reads it. Leaving copy-back out for whole classes was fast but broke faces and hair, because some of those pieces are aliased by another copy (#4426). Turning it back on for every piece that touches an alias copied back 9.5–35.8 GB per frame in our logs, because the decision was made per whole piece, and against the whole 4 MiB
LOOSEwindow.This decides it per sub-range:
VICTORY_UNIFIED_ALIAS_STRICT=1: records alias history (EVER_ALIASED) so a piece is never left on the card when another copy has ever overlapped it, also across evictions and re-creation.VICTORY_UNIFIED_ALIAS_RANGE=1: splits each piece[a, b)into the exact sub-ranges that are aliased (copied back) and the rest (left on the card), using exact interval difference. Title buffers always use their full range;LOOSEwindows use only the range actually asked for (asked[0..1]), unless a view without a size was made. Five unit tests check that copied back ∪ left ==[a, b)and copied back ∩ left == ∅, byte for byte.VICTORY_WC_NO_BACK_ALIAS_SAFE=1and theplay.rsdefaults (UNIFIED_BACK=wc,coherent,cpu-only,unknown,WC_PIECES=1,WC_NO_BACK=1,WC_NO_BACK_PC=1,WC_NO_BACK_MIN_BYTES=1024,UNIFIED_STATS=1) put it to use. A piece whose alias appears only after the write is counted aslate hitsin theunified memory:line.How it was tested
v2026.11.30.03(62.9 ms vs 71.9 ms inside the load band). Copy-back fell from 9.5–35.8 GB/frame (whole-piece decision) to about 30 MB/frame, withlate hits 0in every bench run.late hits > 0: no stale or broken image. Those moments come only during scene loads and mission fades (up to 24 hits in one second), so this keeps thelate hitscounter on to show them.ci.yml:cargo build --releasepasses.cargo clippy --workspace --all-targets --locked -- -D warningsgives no new finding (it already fails onmain, in the same 3 files).cargo test --workspace --locked: 2492 pass;modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_itfails on every branch of this set and on none of the files they touch, andhost::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_endonce in the full parallel run, and each passes when run alone (--exact);mainitself failshost::refresh_tests::chunked_nothing_new_with_matches_individualin the same run.cargo fmt --checkalready reports hundreds of hunks per file onmain; the new code follows the style of the code around it.Checked for overlap
WC_BAR=3for small read-only WC buffers), #4143.AI-assisted. Neon (Gemini) wrote the change; Claude Code reviewed it, rebased it on
main, built it, ran the checks, measured it and checked the image in the recordings.🤖 Generated with Claude Code
@trustno1-coder on GitHub · 2026-12-01 18:32 UTC · original
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