victory-gpu: a copy of title memory in video memory, prepared and tested #3295
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3295"
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 Marvisak/VIctory. Originally posted by pes7 on 2026-11-26T16:16:49Z.
What this is
shadow's copies of title memory live in system memory —Host::shared_bufferis aCUSTOMheap buffer withCPU_PAGE_PROPERTY_WRITE_BACKandMEMORY_POOL_L0— because the title's memory is host memory and the copy has to be something the CPU can refresh and compare. The cost is that every shader read of game data crosses PCIe, where on the console the same read is GDDR6.This PR is the mechanism for the other arrangement: the copy a shader reads lives in video memory (
D3D12_HEAP_TYPE_DEFAULT), kept up to date by a copy per changed range and read back through a readback buffer.Why it is not wired in
Deliberately: the integration is a rewrite of
Shadow's write path (Batch::flushstages instead of memcpying,Shadow::copy_back_pagereads throughread), and a rewrite nobody can A/B is worth nothing. Landing the unit first means the next PR is a measured before/after with this underneath it. The module doc lists the four places the integration touches, and#![allow(dead_code)]says so at the top of the file.What the tests are, and what they caught
The six tests are the semantics the integration needs. They run on any host GPU (and skip where there is none or no shader compiler), so CI keeps them honest:
uploaded_bytes_reach_a_shader_and_its_result_reads_backwhat_a_shader_writes_reads_backtwo_ranges_in_one_list_do_not_overwrite_each_otheran_upload_reads_back_without_a_shadera_range_past_the_end_is_refuseda_copy_is_whole_pagesThe first version was wrong, and the tests said why.
upload/readcopied fromCOMMON; the readback came back zeroed — the shader read the buffer before the copy landed. A copy fromCOMMONis not ordered against a shader access on either side of it. Both operations now enter and leave an explicit state:which is the shape
capture.rsalready uses for its readback, and the reason its comment says a title buffer's copy, never transitioned, is only ever read.Verification
No frame-time claim: nothing in the frame path changes.
Where this can go
If it pays, the order that makes it measurable is: (1) this unit, (2)
ShadowwithOption<VramCopy>for copies above a size and within a VRAM budget, behind a switch, (3) the same scene twice. If it does not pay, the switch stays off and the module stays as the documented reason why — which is also worth having, becauseVICTORY_COPIES_IN_VIDEO_MEMORY's result (worse, 3 196 -> 4 289 ms) is easy to misread as "video memory does not help".Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-26T16:29:54Z.
Update: the measure that decides the integration is in, and it says no
The two commits before this one prepared the mechanism; this one answers whether it is worth integrating, on the machine, in seconds, without the title: the same 128 MiB copy read by a compute shader, once from video memory (
VramCopy) and once from the system memoryshadow's copies live in today (Host::shared_buffer), with two access shapes — a stride-1 scan, and a random 16-byte line a thread — one read a thread and no stores, so the timing is the reads.(Earlier, lower-parallelism shapes agreed: 1.21x / 1.04x. Best of three, ten dispatches a list, RX 9070 XT on a shared machine.)
So video memory buys nothing here. Two readings, and both matter:
CUSTOM/L0copies already come back at PCIe speed on this machine (~32 GB/s measured) and there is no headroom for video memory to give.Either way, the number that decided whether to rewrite
Shadow's write path now exists, and it does not justify a week of it. The one in-game datapoint agrees:VICTORY_COPIES_IN_VIDEO_MEMORY(aGPU_UPLOADheap) measured worse, 3 196 → 4 289 ms.What stays useful:
cargo test -p victory-gpu --release the_read_cost -- --nocapture) and is the honest way to decide this on hardware where the answer may differ;cargo test --release -p victory-gpu— 238 passed, 1 ignored; clippy--all-targets -D warningsclean.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:10:44Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
vram.rsmodule cleanly implements and tests VRAM-backed title memory copies (whole-page rounding, out-of-range guards, upload/shader/readback paths, and disjoint ranges in one list).cargo test -p victory-gpu --lib vram:: -- --test-threads=1(RTX 5090): 7 passed, 0 failed.VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib vram:: -- --test-threads=1(WARP): 7 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-27T12:39:12Z.
Closing: measured no gain in the title, so it isn't worth the extra complexity.
Pull request closed