GPU: less copying back and forth: hot title buffers kept in video memory (opt-in, stacked on #2112) #2734
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2734
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2734"
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?
@sirrus98 on GitHub · 2026-11-25 19:22 UTC · original
sirrus98:perf/up-hot-vram→main· +2254 −15 · 7 files · 24 commits · draftStacked on #2112 (title memory in place,
VICTORY_IN_PLACE=1). Everything up to14d9119is #2112; the new commits are the last two here. Thanks to #2112 for the groundwork: this builds directly on its buffers in place.Change
With #2112, a title buffer in place is the title's own pages, and shaders read and write it across the bus. With
VICTORY_IN_PLACE_VRAM=1as well, a buffer in place from 1 MiB up gets a copy in video memory (newcrates/victory-gpu/src/resident.rs). Views and the memory page table point at that copy, and the card alone keeps it in step with title memory, inside the submission:MEM_WRITE_WATCH) are copied by the GPU from the buffer in place into the video-memory copy, and from there into a twin.InterlockedAnd/InterlockedOr, so bytes the CPU wrote meanwhile in the same dword stay. A row is 64 dwords side by side, so the stores cross the bus as runs of whole bytes.Nothing is copied, snapshotted, compared or hashed on the CPU for these buffers. Budget: 60% of the card's (
VICTORY_IN_PLACE_VRAM_MB), and none past 80% of the budget in use. Minimum size:VICTORY_IN_PLACE_VRAM_MIN_MB. A log line every 5 s counts the copies and what went up and back. Unset, nothing changes.The first commit fixes a gap in #2112 that this needs. For a buffer in place,
Shadow::gpu_writesreturned before the write was noted with the list. Solanded()never marked the pages that shaders wrote through root and table views, and other copies over those pages never saw them; only writes through the memory page table were marked. The write is now declared as for any copy. Nothing is snapshotted or copied back for it, since the in-place paths still return early.This is the "hot memory in video memory" stage of fxceless/victory-gta6#772, ported to this tree's synchronous submissions.
Related drafts, none of which writes back from the GPU: #2130 (written buffers in a GPU upload heap plus a CPU mirror), #693 (shadows in DEFAULT video memory), #2494 (
SEC_COMMITin place).Not measured / limits
mainloses the device before the world with every switch off, so #2112 and this PR do too. It isn't caused by either. The debug layer and DRED name three NVIDIA-only causes inmain:B5G5R5A1/B4G4R4A4render targets and typed UAVs, which NVIDIA refuses.I have fixes for the first two locally, and with them
mainreaches the world. I'll send those separately.GetWriteWatchwith reset); nothing else in the tree resets it.Tested
a_buffer_in_video_memory_takes_the_titles_writes_and_gives_back_the_cards. It runs on the host GPU (verified on the RTX 4090): the title's writes go up, the card's come back, and a CPU byte beside a byte the card wrote in the same dword stays. Also new:pages_go_up_in_runs,ranges_join_where_they_touch,writes_declared_in_place_reach_the_copy_back.a_list_keeps_the_in_place_buffers_it_usesnow counts the declared write's reference.descriptor::hostdynamic slots,memorylists share a table). They fail the same on #2112 without these commits.cargo clippy -D warnings, with and without--all-features: clean.cargo run -p xtask -- policy: ok.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@kotekompotek on GitHub · 2026-11-25 20:36 UTC · original
Read the resident.rs design + the watch/shadow integration. The R/B twin-diff approach is coherent: prepare() uploads title-written pages before the submission, MERGE runs after the lists but before the fence signal so host-visible memory is consistent once waited, and the InterlockedAnd/Or partial-dword path correctly preserves CPU bytes in a shared dword (the hard case for any card-side merge). written_beside handles the aliasing leak I was looking for. Opt-in + stacked on #2112 makes the risk acceptable. What reading can't confirm: whether the submit-ordering (our lists before/after in separate ExecuteCommandLists) is airtight against a title list that both reads R and signals early - worth a soak test once #2112 lands.
@Marvisak on GitHub · 2026-11-26 00:15 UTC · original
Automated triage for the maintainers.
This pull request conflicts with
main(conflicting files:crates/victory-gpu/src/host.rs,crates/victory-gpu/src/shadow.rs). It will be reviewed once it is rebased ontomain.Generated by Claude Code
@potatoe0100 on GitHub · 2026-11-26 14:48 UTC · original
Hardware run on a second NVIDIA card: RTX 4060 8 GB (Ada, PCIe 4.0 x8, Resizable BAR on), driver 621.14, Windows 11 Pro 26300. I tested at the PR head
4d28d6das it is (its base is67e8ae1), because it conflicts with currentmain.cargo test -p victory-gpu --lib --locked -- --test-threads=1. No game files.a_buffer_in_video_memory_takes_the_titles_writes_and_gives_back_the_cardspasses on this card, as dopages_go_up_in_runs,ranges_join_where_they_touchandwrites_declared_in_place_reach_the_copy_back.For context on why this stage matters on narrow-link cards: on the same 4060, #3102's synthetic benchmark puts title memory in place at 113-122 ms per submission, against 53-106 ms with copies in video memory (numbers). I'm happy to re-run this once it's rebased onto
main.AI-assisted (Claude)
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.