GPU: shrink default loose shadow window to 1 MiB and reuse containing spans #3437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3437"
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 Luislariosss on 2026-11-27T01:44:18Z.
Summary
Reduces host RAM / private commit spent on loose shadow windows (
crates/victory-gpu/src/shadow.rs) in two small, self-contained ways:VICTORY_LOOSE_WINDOW_KB(power of two in64..=16384KiB): cuts rounding slack by up to 4× on scattered small allocations outside buffer objects.LOOSE: previouslyloose()only checkedmap.get(&(start, len)), so accessing a sub-range of an already-allocated multi-window loose shadow allocated a duplicate overlappingshared_buffer.loose()now reuses any existing loose shadow whose[s_start, s_start + s_len)already covers[address, end).Tested
cargo test -p victory-gpu shadow::: all tests pass, including newloose_window_defaults_to_1_mib_and_reuses_containing_spans.cargo clippy -p victory-gpu --tests: 0 warnings.cargo check --workspace: clean.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T01:47:00Z.
Review: APPROVED
LGTM — verified on Windows (RTX 5090):
VICTORY_LOOSE_WINDOW_KB, clamped to power-of-two64..=16384KiB) and reusing containing loose spans is clean and avoids duplicate overlapping host bufferscargo test -p victory-gpu --lib shadow::passed (11/11, includingloose_window_defaults_to_1_mib_and_reuses_containing_spans)cargo clippy -p victory-gpu --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:00:23Z.
Review: APPROVED
Looks good to me — clean, focused reduction in loose shadow rounding slack with solid span-reuse handling.
Review & Verification Notes
crates/victory-gpu/src/shadow.rs:1058-1102: shrinkingDEFAULT_LOOSE_WINDOWto 1 MiB and parsingVICTORY_LOOSE_WINDOW_KBwith clamping to64 KiB..=16 MiBand power-of-two rounding keepsloose_spanalignment andsaturating_sub(start).max(window)sound across all inputs, whilefind_containing_loosecleanly avoids allocating overlapping host buffers when an existing loose span already covers[address, end).9d85a52f:cargo xtask policypasses (191 files ok).cargo clippy -p victory-gpu(--lib,--tests, and--features diagnostics --tests,-D warnings) is clean.victory-gpushadow::testsanddraw::testspass (30/30) on both discrete D3D12 hardware (VICTORY_D3D12_DEBUG=1,VICTORY_D3D12_GBV=1) and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1,VICTORY_D3D12_WARP=1).Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T11:33:53Z.
Ran it on Intel Arc B580 with the game to see whether the RAM claim shows up. Short version: the change is fine and its tests pass here, but the 4 MiB → 1 MiB default is below what this tree can measure, and I would not merge it as a performance claim without a counter. The containment-reuse half is worth having on its own.
Setup.
223ac4b9(=origin/main63bcca43+ #2958, our measured baseline) with this PR's commit alone on top,--profile diag --features diagnostics, title 1.0.2.1--console series-x,VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1, 110 s, 20 frame lines, 0 device removals, 0 title crashes.Tests here:
cargo test -p victory-gpu --lib shadow:: --features diagnostics→ 11 passed, 0 failed.Why I cannot confirm the RAM saving. Process
commitat the end of a 110 s run, same tree changed only by this PR:main-alone-4main-alone-1ctl-with-2The spread between two runs of unmodified baseline is ~170 MB, so a 22 MB difference is not signal. Across all my captures the same-tree spread is ±4 GB, because
committracks how far the world has streamed (16.6 GB at 110 s, 28.6 GB at 200 s), not a fixed budget.The one counter that does see the loose path disagrees in direction, which is why I am not claiming either way: at 110 s the baseline reports
3,543 live in 4 shared buffers (41.6 MB held)while this build reports835 live in 2 shared buffers (20.7 MB held); fewer shared buffers is the containment reuse working, butheld / liveis 24.8 KB here against 11.8 KB on the baseline, and theasked for/framediffer by 3,000× between the two runs, so the scenes are not comparable.What would make this mergeable on evidence: one counter for loose-window bytes (allocated and slack), printed in the same block as
buffer views off their copy's elements: … (MB held), or a unit test that asserts held bytes fall when a second view of a sub-range is taken — the new test proves the reuse happens, not that it saves anything. With that, the 1 MiB default either shows a number or does not, and the decision stops depending on scene variance.For the record on the second half: reuse of a containing loose span is a correctness win regardless of the default — duplicate overlapping
shared_buffers for the same title memory are a bug worth avoiding, and that part needs nothing from the above.Synthetic tests only in the tree; the runs are my own dump. Machine: Windows 11 x64, Ryzen 5 5600, 32 GB, Arc B580 12 GB.
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.