Card copies: a census, and an opt-in switch that leaves write-combining memory on the card (−11…−20 % frame, 3 GPUs) #868
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!868
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-868"
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?
@Chipsraine on GitHub · 2026-11-25 11:10 UTC · original
Chipsraine:pr/wc-copyback-census→main· +504 −3 · 7 files · 4 commits · openSummary
Two opt-in additions about the card copies of title buffers (
crate::shadow::cards). Nothing changes without the switches. Rebased on0b0074e.VICTORY_CENSUS=1(logging only): every 10 s (VICTORY_CENSUS_SECONDS) a census of those copies: theXMemVirtualAllocreservation each lies in with the flags the title asked for (the runtime drops write-combining, uncached and the GPU access bits; the census keeps them), how much of it is physical-page views and how much shows a page at more than one address, and per frame the bytes sent up, pieces compared and bytes fetched back; plus host resources made per frame by kind.VICTORY_SKIP_WC_BACK=1(experiment): what shaders wrote to copies of write-combining title memory is not fetched back into title memory. Declared ranges that cross a reservation boundary or touch ordinary memory still take the normal path (fix by @iGoldenNinja,f9c43fa).VICTORY_SKIP_WC_COMPARE=1(implies it; marked UNSAFE): those copies are not hashed or compared on the card either. One device removal was reported with it (see below); kept only for measurement.Why
The census found ~100 copies (~1 GB) on the card, and per frame ~100 MB fetched back of which 97–99 % comes from memory the title reserved write-combining, i.e. memory the console's CPU writes but does not read back. About half of the uploads were an echo: a fetched piece makes title memory differ from the CPU side, and the next submission sends it up again.
Results for
VICTORY_SKIP_WC_BACK=1(independent testers)All on
0b0074e-era trees with the author's speed set (ASYNC_SUBMIT QUEUE2 INDIRECT_WINDOW TEXTURE_NO_WAIT COPY_PLAIN), warm caches, Series X profile.SKIP_WC_COMPARE)Uploads to the card fall by about half in every report (e.g. 161 → 77 MB/frame here, 140 → 27 MB/frame for @iGoldenNinja).
Known issues and caveats
VICTORY_SKIP_WC_COMPARE=1: one device removal ~75 s into the world on a 5080 (@Ym1r1710); none in other runs. Cause unknown; do not use for play.Verification
cargo build --release -p victory;cargo clippy -p victory-gpu -p victory-hle --all-targets(no new warnings);cargo test --release -p victory-gpu --lib(census, shadow, inplace; @iGoldenNinja's reservation tests included);cargo xtask policy(180 files ok). Numbers only; no game data, captures or screenshots.🤖 Generated with Claude Code
@Ym1r1710 on GitHub · 2026-11-25 11:24 UTC · original
Tried this on a 5080 (16 GB, Win11, Series X profile), on top of
f85101bwithVICTORY_RELAY=2,VICTORY_ASYNC_SUBMIT=1andVICTORY_QUEUE2=1.With
VICTORY_SKIP_WC_COMPARE=1I got a device removed about 75 s into the world (first cell). Breadcrumbs say it died in the middle of a list, 247 of 516 done, and the next one 0/1. The driver recovered by itself, no black screen. My tree without this PR has done several runs on the same settings with no removals (~6 fps).Only one run, so I can't say for sure it's the switch. But your caveat about the CPU writing part of a 64 KiB piece the card wrote would fit. I haven't tried
SKIP_WC_BACK=1on its own.FYI there's a small conflict in host.rs against current main, next to the
VICTORY_CARD_WHOLE_MBloop. I kept both blocks, whole-compare first and then your WC filter.@MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
4e34eb0intomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort; PR #841 fixes them), also with--all-features; this PR adds none.cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)) (mainalone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
@Chipsraine on GitHub · 2026-11-25 12:52 UTC · original
Thanks both for testing. @Ym1r1710: a device removal is exactly the failure the caveat predicts (stale bytes sent up over a piece the card wrote, e.g. indirect arguments), so I'd treat
SKIP_WC_COMPAREas unsafe until shown otherwise. My own 12-min run on a 5080 had no removal, but that was on9376fd6withoutASYNC_SUBMIT/QUEUE2/windows. If you have time, a run withVICTORY_SKIP_WC_BACK=1alone would tell whether the compare skip is the trigger. I'll rebase onto0b0074e(resolving theVICTORY_CARD_WHOLE_MBconflict), re-measure againstVICTORY_QUEUE2=1, which attacks the same copy-back wait without the assumption, and report back. Converting to draft meanwhile; the census part (VICTORY_CENSUS) is logging only and safe. @MamaLeVrai: thanks for the build/test check.@Chipsraine on GitHub · 2026-11-25 13:34 UTC · original
Rebased onto
0b0074e(no conflicts there; new head7e64279) and re-measured on the RTX 5080 (Ryzen 5 5600, Win11, Series X profile), same room, release build, with the author's speed set:VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_TEXTURE_NO_WAIT=1 VICTORY_COPY_PLAIN=1(+VICTORY_TEXTURE_CATCHUP=0).Steady world frames (≥3,000 draws, no pipelines being made), p50:
VICTORY_SKIP_WC_BACK=1So
QUEUE2and this switch add up:QUEUE2removes the wait for the fetch, this removes the fetch itself and the echo upload that follows it.SKIP_WC_BACK=1alone (noSKIP_WC_COMPARE) ran ~8.5 min on top of windows/async/queue2 with no device removal and no display-driver events in the System log. One run each (55 and 65 steady samples), so treat as indicative.SKIP_WC_COMPAREI still consider unsafe after @Ym1r1710's report; staying in draft until the lazy (first-touch) form exists.@Chipsraine on GitHub · 2026-11-25 13:56 UTC · original
@iGoldenNinja thanks — both fixes are right and I've taken your two commits as they are (
b57479c,f9c43fa, authorship kept): the in-flight path was simply not credited per copy, and classifying by the copy's start address was wrong for windows spanning two reservations (on my runs all ~100 copies sat inside one reservation, so my numbers are unaffected, but the experiment must not depend on that). Your 5080 pair matches mine in direction (fetch −93 MB, uploads −110 MB/frame, copy-back halved) — thanks for the independent check.On the P99 / composed-flip regression: from one 30 s WPR trace of my
SKIP_WC_BACK=1run (author's speed set on0b0074e) I classified each of the title's 202 presents by whether an MMIO overlay flip from the process followed it before the next present: 67 independent, 134 composed, interval p50 150 / 155 ms, p99 234 / 241 ms, no interval over 500 ms in either mode. So it does not reproduce here in that window; I'll keep logging every frame (VICTORY_FRAME_LOG=1) and the flip mode in the next runs.@xunbreakablex on GitHub · 2026-11-25 15:37 UTC · original
Second machine with the same CPU class, for
VICTORY_SKIP_WC_BACK=1only (AI-assisted, Claude; runs on my machine): RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz, Windows 11, driver 621.01, Series X profile, diagnostics build of this PR's headf9c43fa(on0b0074e), warm cache. Both arms use the same binary and the setASYNC_SUBMIT=1 QUEUE2=1 INDIRECT_WINDOW=1 MERGE_GAP=64 MERGE_RUNS=4096 COPY_PLAIN=1 TEXTURE_NO_WAIT=1; 480 s runs in A-B-A-B order, steady window world +300..+480 s.SKIP_WC_COMPAREwas not used.SKIP_WC_BACK=1SKIP_WC_BACK=1@Chipsraine on GitHub · 2026-11-25 15:41 UTC · original
Long runs on the RTX 5080 (Ryzen 5 5600), from the prologue to the start of chapter 1, on
0b0074e+ this PR (with @iGoldenNinja's fixes) + #911 #916 #834, author's speed set (ASYNC_SUBMIT QUEUE2 INDIRECT_WINDOW TEXTURE_NO_WAIT COPY_PLAIN), warm caches:VICTORY_SKIP_WC_BACK=1: 22.6 min, no device removal, no display-driver events;Draw-matched comparison (the scenes differ a lot in draws, so frames are binned by draws per frame; steady world frames, no pipelines being made), p50:
SKIP_WC_BACK=1So on top of the author's set the gain is ~11–13 %, smaller than the 22 % of my earlier short pair: with
ASYNC_SUBMIT/QUEUE2much of the copy-back already overlaps other work (−43 ms of copy-back gave ~−20 ms of frame).Game logic: in the switch run the story broke twice (control returned to Lucia in the police car after the cutscene, a scene that does not exist on console; later a switch to Jason in a barely streamed world). The control run without the switch broke at the same two places, so these are not caused by
SKIP_WC_BACK; most likely the mission scripts advance on time while streaming/cutscenes lag at 3–7 fps.Present timing from WPR (flip mode per present, ~30 s windows in the cell): with the switch p50 130 ms, p99 223 ms, no interval over 500 ms in either independent or composed flip, so the P99 regression reported above did not reproduce here.
@xunbreakablex on GitHub · 2026-11-25 15:56 UTC · original
Correction to my comment above, after looking at the captures properly (AI-assisted, Claude; same RTX 4070 / Ryzen 5 5600 machine).
Picture: I wrote that I found no difference that stands out. That was wrong. In the cell-window shot (world +300, +600, +900), two of the three
SKIP_WC_BACK=1runs show light-grey rectangular patches with stair-stepped edges in the lower part of the frame (to the sides of and below the character, roughly the bottom fifth of the screen), and one of them also small cyan specks at the right edge. Neither of the two runs without the switch has them (same binary, same set, same capture method). A simple measure of strong 8-pixel-aligned edges in that region: without the switch 0.001 and 0.051; with it 0.163, 0.089 and 0.174. That looks like the failure your caveat predicts (bytes the card wrote into write-combining memory not coming back, and something later reading the stale copy), but I have not proven the mechanism; it is 3 vs 2 runs on one machine.Speed: the third
SKIP_WC_BACKrun (withVICTORY_CENSUS=1) gave 156.1 ms, so B is 140.2 / 155.8 / 156.1 ms (mean 150.7) against 195.8 / 172.1 ms without the switch. An earlier run of the same set on plain0b0074egave 159.0 ms, so against that the gain is only ~5%; against the two A runs of this binary it is ~18%. The direction is consistent (every B run faster than every A-type run), the size is not: please read it as 5-18%, not 20%.Census in the B run, world part: per frame about 22-24 MB sent up and 5.5-5.9 MB fetched back, of which 0.0 MB from write-combining memory (as expected with the switch on). I have not run the census with the switch off yet, so I cannot say yet how much write-combining read-back the switch skips; that run is queued.
@Chipsraine on GitHub · 2026-11-25 15:59 UTC · original
@xunbreakablex thank you — A-B-A-B at 480 s on a 4070 with the same CPU class is the cleanest measurement in this thread; I've put it at the top of the summary table in the description, next to the other reports.
VICTORY_SKIP_WC_COMPAREis now marked unsafe in its comment and log line (fef9592), and with four independentSKIP_WC_BACKreports and no device loss I'm taking this out of draft for review, as an opt-in switch, off by default.@iGoldenNinja on GitHub · 2026-11-25 13:04 UTC · original · edited 2026-11-25 16:06 UTC
Chipsraine, we reproduced a separate census accounting gap on PR head
4e34eb042e781bc046ca4f06858da1ee0302fe2d. WithVICTORY_CENSUS=1,relay_card_inflightadds usable landed bytes to the global in-flight total but omits them from the per-copy fetched counters. The correction credits each accepted span to its shadow copy after duplicate and superseded ranges have been excluded.The CPU-only regression on Windows 11 25H2 (26200.9974) exercises the production landing loop with synthetic slot buffers and a stub merge. On the parent, copy A records 0 fetched bytes despite 17 bytes landing. On the correction, A records 17 bytes across two spans and B records 14 bytes in one span, matching the global 31 bytes. The stub reports zero title bytes changed. The rejected batch records zero on both revisions. Both regression cases pass with the correction.
Correction commit · Reproduction fixture
Reservation-range correctness
Two CPU regressions expose a separate classification defect on the same PR head. In a synthetic 4 MiB card window spanning two adjacent 2 MiB reservations, the parent classified a 64 KiB write in the ordinary reservation using the write-combining flag at the start of the window. The correction classifies each declared guest interval. Declarations that cross a reservation boundary or include ordinary memory use the normal comparison and readback paths. Writes entirely inside a write-combining reservation still qualify for the experiment. Both regressions pass, covering exact end boundaries, adjacent reservations and integer overflow. Synthetic checks also exercised the direct, relay and compare gates.
The separate local RTX 5080 control used default card-window settings. All 99 recorded exact buffer extents fit inside individual observed reservations. The synthetic tests establish the classifier defect, and its effect on the rendered scene remains unmeasured.
Reservation-range correction and CPU tests
Live RTX 5080 back-only comparison
Following Chipsraine’s back-only request, we ran one control-first pair at the same 2542 × 1396 prison window, about 90 seconds per arm, with no replay input during measurement. Both used
dc3c191953f0c8e4adfad5260331ddbc6ec21910(early-depth integration plus4e34eb0), a warm cache, Series X profile, ASUS ROG Astral RTX 5080 16 GB / 617.14, Ryzen 9 5900X, 32 GB, Windows 11 Pro 25H2 build 26200.9974. The census and comparisons were on, in-flight fetch was off, and onlyVICTORY_SKIP_WC_BACKchanged from 0 to 1. Median draws were 4,985 and 4,996.Sampled geometry and lighting looked similar and dark areas remained. We stopped both runs deliberately without a logged device removal. This pair measures traffic and display timing in one stationary scene. Guest CPU reads of skipped GPU-written data and later gameplay remain untested.
Pinned comparison report
November 25 follow-up. A retrospective check of four matched-view bottom-fifth crops per arm from our single 90-second RTX 5080 pair on
dc3c191found zero pixels meeting our light-grey or cyan definitions, with a different metric, shorter observation window and earlier build than the RTX 4070 comparison. Pinned report@xunbreakablex on GitHub · 2026-11-25 16:28 UTC · original
One more caveat on the speed numbers above (AI-assisted, Claude): on this machine the first game run after each new build looks systematically slow. In two separate chains the first run of the default arm came out at 195.8 and 195.4 ms, while the later default runs of the same binaries were 172.1, 160.1 and 159.0 ms. Both of my comparisons started with such a first run, so the "about 18%" is inflated; against the later default runs the
SKIP_WC_BACK=1gain is closer to 5%. The picture finding (grey stepped patches in 2 of 3 runs with the switch, none without) is unaffected by this.@xunbreakablex on GitHub · 2026-11-25 17:08 UTC · original
@Chipsraine thanks. Before it goes in on my numbers, please see my two follow-ups just above yours: (1) two of my three
SKIP_WC_BACK=1runs showed light-grey stepped rectangular patches in the lower part of the cell-window shot (one also cyan specks at the right edge), and neither run without the switch did — same binary, same capture method; (2) my first default run was a first-run-after-build outlier, so against the later default runs the gain here is nearer 5% than 18%. Your draw-binned 11-13% from long runs is the better speed number. The patches are 3 vs 2 runs on one machine, so not proof, but it is the failure your caveat describes, so it may be worth a look in your own captures of that shot (around the bottom fifth of the screen, beside and below the character) before review. (AI-assisted, Claude.)@xunbreakablex on GitHub · 2026-11-25 17:29 UTC · original
@Chipsraine a further correction, in your favour: I can no longer attribute the grey stepped patches to
SKIP_WC_BACK. On465b94f(no #868 in that binary at all) I ran five more captures of the same cell-window shot with the default speed set and withJOIN_PARTS/BACK_OWN_VIEW/INDIRECT_GATHER, and the same kind of light-grey stepped blocks with cyan specks in the lower part of the frame show up in a run without any of these switches (and in some of the others), at random. So my earlier "2 of 3 with the switch, 0 of 2 without" split was most likely the run-to-run randomness the README mentions, not this PR. Sorry for the noise; the speed numbers in my last note stand (gain nearer 5% than 18% on my machine, your long-run 11-13% is the better figure). (AI-assisted, Claude.)@Ym1r1710 on GitHub · 2026-11-25 18:16 UTC · original
Did the run you asked for, SKIP_WC_BACK=1 alone (no COMPARE), on the current head merged into my tree (
ca8829f+ #1043), RTX 5080 + 7800X3D, Win11. Base switches RELAY=2, QUEUE2, ASYNC_SUBMIT, INDIRECT_WINDOW, TEXTURE_NO_WAIT, COPY_PLAIN.Three runs to world+800 on the same binary: one with DRED armed (no removal, no warnings), then without DRED with and without the switch. With it: 105 ms median, copy-back ~11 ms. Without: 116.8 ms, copy-back ~49 ms. So about 10% here, close to your draw-binned number.
Looked at the captures at world+250, +400 and +800 next to the control run: same picture, no grey blocks or specks. Only the first cell scene though, I haven't played further with it yet. Keeping it on in my build for now.
@Exopus-0x65f7ad0 on GitHub · 2026-11-25 19:43 UTC · original
Tested on RTX 5060 Ti 8 GB, 16 GB RAM, Windows 11. The base was fork
maind510ee4plus #911/#1006/#1014/#1043/#1058/#1059/#1067/#1007/#188, Series S, withVICTORY_SKIP_WC_BACK=1only (notSKIP_WC_COMPARE). Copy-back fell from 63 to 5 MB per frame and the frame line's "copying back" from ~100 to ~20 ms. No visible defect in the first room or the cutscenes, and no device loss over 4 runs of 8-10 min. First room, standing: median 8.6 fps.🤖 Generated with Claude Code
@HLVM04 on GitHub · 2026-11-25 20:57 UTC · original · edited 2026-11-26 01:55 UTC
A Series S data point on an RTX 5070 Ti (Ryzen 7 9800X3D, Windows 11 build 26200), first gameplay scene, on our own stack: an older fork main plus several open PRs and local changes, including the 2 MiB section patch from #1089.
VICTORY_SKIP_WC_BACK=1only, notSKIP_WC_COMPARE:SKIP_WC_BACK=1and nothing visibly broken compared with the run without it(see the correction below).It's few runs in one scene, so read the frame-time difference as small, not as measured exactly.
Edit (2026-11-26), correction: on our stack
VICTORY_SKIP_WC_BACK=1does break the picture: the room's lamp light goes missing and rooms render dark. Our earlier runs were judged only by the character, not by the room lighting, so the "nothing visibly broken" above was wrong.@milesah3ad on GitHub · 2026-11-26 05:03 UTC · original
@Chipsraine a data point from a setup that isn't in this thread yet: RTX 5080 without
ASYNC_SUBMIT/QUEUE2(every 5080 report above has them on), and the PR on current main.Tree. This PR (
fef9592) merged ontomain988aa41: milesah3ad:pr868-on-988aa41 (c686ab8). The only conflict was inhost.rs, against main's three-step send-and-hash: I kept main's version and added this PR'scensus::sent(...)call beforesynced.push. Builds;cargo test -p victory-gpu206 passed; clippy clean. Feel free to take the merge if it saves you a rebase.Machine. RTX 5080 16 GB (driver 621.24, 32-lane), Ryzen 7 9800X3D, 64 GB, Windows 11 26300, Series X profile, release build with
diagnostics. Settings in every run:RELAY=1 TEXTURE_BACK=1 TEXTURE_NO_WAIT=1 COPY_PLAIN=1 JOIN_COPIES=1 CARD_REHASH_RUNS=1 LEVELS_ON_DEMAND=1 D3D12_DRED=faults. The only difference between arms isVICTORY_SKIP_WC_BACK=1(notSKIP_WC_COMPARE).Runs. A-B-A-B, same binary, 10 minutes each from launch, scripted Enter from the same prologue save (world after 60-120 s). Steady world frames only (≥1,000 draws, no pipelines being made), medians:
SKIP_WC_BACK=1SKIP_WC_BACK=1So on this machine: copy-back about −45 %, the usual frame −9 to −22 %, about +22 % fps at 4-6k draws. No device removal in any of the four runs. In two screenshots from run 4 (the cell door with the guard, the common room) there are no grey stepped blocks or specks; the scripted input carried the runs to different scenes, so I don't have same-frame comparisons. Two pairs on one machine, so take the size of the gain as approximate.
AI-assisted (Claude Code); the numbers are from the run logs.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.