GPU: depth twins share their scratch buffers (~280 MB video memory) #2160
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2162"
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 desplmfao on 2026-11-25T06:42:01Z.
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(#1964, #2093).AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T07:17:30Z.
Review: COMMENTED
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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:34:53Z.
Automated triage for the maintainers.
Merge candidate. Depth twins in
crates/victory-gpu/src/twin.rsnow share their scratch buffers, one per power-of-two size class (shared_scratch), instead of each twin holding its own. The PR estimates this saves about 280 MB of video memory.I checked that sharing is safe in
Twin::copy. Every copy through a scratch buffer ends with an explicit transition back to the common state. So a later copy in the same list, which implicitly promotes the buffer toCOPY_DEST, is ordered after the earlier copy's reads. The host executes on one queue (host.rs). The classes are bounded (all together at most twice the largest).CI
checkpasses, and the branch merges cleanly withmain.Generated by Claude Code