GPU: less copying back and forth: hot title buffers kept in video memory (opt-in, stacked on #2112) #2732
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by sirrus98 on 2026-11-25T19:22:19Z.
Stacked 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
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:36:42Z.
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T00:15:20Z.
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
Imported from Marvisak/VIctory. Originally posted by potatoe0100 on 2026-11-26T14:48:22Z.
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
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.