Repository navigation
GPU: depth twins share their scratch buffers (~280 MB video memory) - #2162
Conversation
Each writable depth twin made a scratch buffer of its planes' size for its copies and held it as long as the twin: about 325 MB of video memory for Grand Theft Auto VI's 315 twins in the menu. The twins now take one shared buffer per power-of-two size, at most twice the largest in all. Every copy through a scratch buffer starts in the common state and returns it there, so copies in one list are ordered by those transitions, and lists run one after another on the host's single queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Depth twins share scratch buffers (~280 MB video memory saved) — scratch-memory dedup; big win if correct, check aliasing between twin formats.
|
Automated triage for the maintainers. Merge candidate. Depth twins in I checked that sharing is safe in CI Generated by Claude Code |
The previous main (old upstream base) is the first parent; the second is upstream main with the current heads of our pull requests merged in: Marvisak#2143, Marvisak#1849 (carried onto main's per-region runtime_pages), Marvisak#259, Marvisak#491, Marvisak#2153, Marvisak#2099, Marvisak#2071 (main covers it), Marvisak#2162, Marvisak#2218, Marvisak#2088, Marvisak#2389, Marvisak#177's element-type key on main's three handle maps, and the README. Marvisak#2112 (opt-in, in place) stays in the renderer branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…80 MB video memory)
…erged) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # README.md # crates/victory-gpu/src/descriptor.rs # crates/victory-gpu/src/pipeline.rs # crates/victory-gpu/src/pipeline/library.rs # crates/victory-hle/src/modules/gameinput.rs
Upstream main merged Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906 and Marvisak#1152 and took up what Marvisak#1769 (LDS bounds, Marvisak#1949) and Marvisak#1763 (typed UAV formats, Marvisak#2462) did; main's code is kept for those. - emit/lower.rs: ds_bpermute within each half (main's Marvisak#573, same as Marvisak#439's); LDS bounds as main's Marvisak#1949 (Marvisak#1769's test-only counter kept, its and_guard dropped); title-memory marks: main's straddling-write lookup (Marvisak#2484) with Marvisak#2167's current head (3cb308d, rebased on 63bcca4): guarded dirty atomics, raw_dword2, memory_null, synthetic_mark_dxil in lower/mark_tests.rs; the old Marvisak#2167 head taken out first. - emit/host.rs: main's shared WARP device and lock (Marvisak#244) with Marvisak#439's adapter list and Host::on (create_device takes an optional adapter). - descriptor/host.rs: main's Marvisak#2462 format checks; Marvisak#1763's tests kept. - gpu host.rs: main's multi-plane present with Marvisak#2310's crumbed copy. - pipeline.rs: Marvisak#2118/Marvisak#2311's builder and BVH checks with main's skip hashes (Marvisak#1320); draw.rs, shadow.rs, main.rs: both sides. - Tests main added since get Marvisak#439's Parts fields and emit's Target. - README: base 63bcca4; rows of PRs merged upstream, superseded or closed taken out, with a note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous renderer (old upstream base 940d32f) is the first parent and is also kept as the branch renderer-2026-11-25-oldbase; the second parent is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with the renderer stack merged on it: Marvisak#439 (on main: update/439-main's resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292, Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes. Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by main: Marvisak#1769, Marvisak#1763, Marvisak#2366. The picture on this base still shows the overlay that plain upstream main shows too; that is being looked into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Every writable depth twin (
twin.rs: a depth texture the title also writes through unordered views) makes a scratch buffer for its copies between the depth texture and the twin. The buffer is the size of the twin's planes and lives as long as the twin. Grand Theft Auto VI makes 315 twins in the menu already, so that's about 325 MB of video memory in scratch buffers that only matter during a copy.Change
The twins share scratch buffers: one per power-of-two size class (64 KiB minimum), made the first time a twin of that class needs one (
shared_scratch). Together they hold at most twice the largest.Sharing is safe because:
Twin::copystarts every use of the scratch buffer from the common state and ends with a transition back to it, so two copies through the same buffer in one list are ordered by that transition;Nothing else changes: same routes, same copies, same conversion shader.
Measured
Grand Theft Auto VI (Series X 1.0.2.1), RTX 5080, Linux, proton-cachyos 11.0. Live video memory by creation site, tracked with private data on each resource (diagnostics, not part of this PR):
mainThe twin textures themselves (318, 314 MB) are unchanged. No visible change to depth, shadows or lights in the world.
Tested
cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.victory-gputests on the RTX 5080 under Proton: 129 passed, 13 failed, the same asmainon this setup.twin::tests::copies_follow_the_side_each_use_needspasses.twin.rs(GPU: support 24-bit depth twins and per-plane active UAV tracking #1964, GPU: our compute shaders compiled by the build on Windows #2093).AI-assisted (Claude Code).
🤖 Generated with Claude Code