Card copies without a CPU mirror until shaders write them (VICTORY_CARD_NO_MIRROR=1, off by default) #4860
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4860"
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 mcozcan on 2026-12-01T11:54:03Z.
Refs #4462
What it changes
Every title buffer with a copy in the card's memory is held three times: the title's own pages, the copy's CPU mirror (
Card::staging, whichShadow::datapoints into) and the card's side. The mirror is the copy's full size in the PC's memory. It does two jobs:Shadow::copy→send::take).safecopy::mergeviacard_merge,land_card). The card keeps only a 16-byte hash per 64 KiB piece.A copy that no shader was ever declared to write needs only the first job, and title memory can do that itself. The aim is RAM and commit: for those copies, the PC's memory holds the bytes once instead of twice.
With
VICTORY_CARD_NO_MIRROR=1(off by default):MEM_RESERVE), not committed, so it costs neither RAM nor commit (LazyMirror). The copy's pointer stays the same; nothing reads or writes the pages while they are missing.Shadow::copy).copy_mappedas the refresh does. The reads run on the wide pool (send::copy_from_title), so the work does not move onto the submitting thread. The bytes are copied once (title → submission memory) instead of twice (title → mirror → submission memory).Shadow::ensure_mirror). The first time means any of the eightwrittensites,writing,placed_copy,keep_stores,card_make_before,takeortake_landed. The card then holds what the mirror holds before any submission that writes it runs, and the copy goes on as today.Step::Placed) writes title memory, copies over its destination that have no mirror get one, filled with the bytes from before. Draws ahead of the copy in the list keep seeing those bytes (the orderplace.rskeeps).card_merge,card_merge_relay,land_card) leave a copy without a mirror out and warn once (... on a copy without a mirror, left out (please report)). They should never meet one, because declaring shader writes makes the mirror first.host::fail). The copy could not be landed without it.VICTORY_SEND_OWN=0,VICTORY_UPCOPY_CHECK=1orVICTORY_SEND_CHANGED=1, which read every copy's mirror. Arenas by address (by_address,changes_only) and windows promoted later (card_late_windows) keep their mirrors.VICTORY_MIRROR_STATS=1(counting only, and also on withVICTORY_CARD_NO_MIRROR=1) adds one line to the frame-rate lines:The last two size a possible next step: dropping the mirrors of written copies too, with copy-on-write of the pages the title writes under a flight. That is not in this PR.
How much it saves depends on how much of the carded memory shaders never write, and nothing in the repository splits that yet; the new line does. For scale, the mirrors are as large as the carded copies:
shadow.rscomment);victory play, whoseVICTORY_CARD_ALL=1gives every copy a second side.How it was tested
VICTORY_MIRROR_STATS=1alone againstVICTORY_MIRROR_STATS=1 VICTORY_CARD_NO_MIRROR=1;victory play. The two runs above, with theCPU mirrors of card copiesline and commit from each, would show what it saves and whether anything breaks.cargo test: the newtitle_pieces_cover_every_byte_once_in_order(the split of the sends across the pool) passes, run on Linux in a crate of its own. Built on Windows: the same change (with other opt-in work on top) passed both clippy steps of this repository's CI workflow in my own repository (run), since CI here waits for approval; that run was stopped before its test step.Checked for overlap
I searched the open pull requests for the same issue and for the files this touches. Related:
VICTORY_CARD_CPU_FILE: the mirrors in files instead of the page file; this drops them where they are not needed);shadow.rs);None removes the mirror of card copies.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:30:27Z.
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