GPU: a wider loose window covers a later smaller ask #2856
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!2856
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2856"
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?
@Luislariosss on GitHub · 2026-11-25 22:27 UTC · original
Luislariosss:gpu/loose-window-reuse→main· +117 −0 · 2 files · 2 commits · openWhy
Title memory outside buffer objects gets host copies of the aligned windows it touches (
shadow::loose). These windows are the shared segment's own content on a machine whose system RAM is half the card's: one measured run held 878 of them totalling 3,926 MB, and the non-local segment (budget: half of system RAM) was pinned at its budget in every long run. At that ceiling the run dies two ways: a host command list's Close() returns E_OUTOFMEMORY, or a staging allocation the runtime could not make feeds the title a value it dereferences (its own missing check; our failure is the trigger either way).The windows were keyed to their exact (start, length): a memory range a wider window already spanned made its own host buffer and its own copy anyway.
What
A miss now takes the first window that covers it (start at or before ours, end at or past ours, nearest start first). The reuses are counted and printed with the periodic lines, and the windows themselves are too (count and bytes; they are never freed by design, so what they reach is what the segment carries).
Measured
One hardware run (AMD, RDNA4, 15.2 GB system RAM, diagnostics build, 5+ minutes to the world):
Verification
cargo clippy --workspace --all-targets --locked -- -D warningsand the--all-featuresvariant: clean.cargo test --workspace --locked: green.No shader bytes, hashes, or program names from any title (asset policy).
@fuzeofficlal on GitHub · 2026-11-25 23:00 UTC · original
Reviewed and tested
24e65566on Windows 11 (RTX 5090 + WARP) againstmain(842b0cb):Verification
cargo xtask policy(190 files ok),cargo clippy --locked -p victory-gpu --all-targets(default &--features diagnostics, 0 warnings).shadow::tests10/10 (includinga_wider_loose_window_covers_a_later_smaller_ask) anddraw::tests20/20 passed on both RTX 5090 and WARP.Three edge cases / concerns to address
shadow.rs:1479):loose()alignsstarttoWINDOW = 4 MiB(4,194,304, which is not a multiple of 3). For a structured buffer with stride12/24/48bytes aligned to its own4 MiBwindow (offset == 0), reusing an earlier wider window shifted by4 MiBmakesshadow.offset(address) % 12 == 4 != 0, forcingfor_viewto fall back toexact()and allocate a separate copy anyway.512 MiB) loose window for a hot4 MiBsub-range couplesShadow::clean()andMARKStracking across the entire wide window; on misses,.range(..(start, u64::MAX)).rev().find(...)linearly scans all earlier entries.at + *l >= start + len(shadow.rs:1094) should usesaturating_add, and the"loose windows: ..."counters/logging inhost.rs:3080-3090andshadow.rs:1066are under plain#[cfg(windows)]instead of#[cfg(feature = "diagnostics")].@Marvisak on GitHub · 2026-11-26 03:26 UTC · original
Automated triage for the maintainers.
Verdict: merge candidate.
crates/victory-gpu/src/shadow.rsloose: on a miss for the exact(start, len)window, it now looks for an existing window that starts at or beforestartand reaches paststart + len, and returns that copy instead of allocating another host buffer for memory already copied.host.rsMeter::frameadds the window count, bytes and reuses to the 5-second line.Checked: callers only use the returned
Shadowthroughoffset(address), so a copy that starts earlier serves the same bytes. One copy of a range instead of several overlapping ones also can't make GPU writes less consistent. On the structured-view concern raised above: when the offset into the wider copy isn't element-aligned,for_viewalready falls back toexact, so that case costs a copy but stays correct. The measured effect (120k covered asks in one run) is one run, but the change is a straightforward reduction in duplicate copies.CI: failing, in
descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait. This PR doesn't touch that code, and other PRs report it flaking onmaintoo. A re-run should clear it.Generated by Claude Code
@pickles976 on GitHub · 2026-11-26 04:16 UTC · original
Independent Wine/NVIDIA fixture verification: 1/1 PASS, actual RTX 4060 Laptop GPU 8 GiB, driver 590.48.01, 16 GiB system RAM, Wine 11.0 / vkd3d-proton 3.2.0;
DXVK_CONFIG='dxgi.hideNvidiaGpu = False'. Windows-MSVC test build, Rust 1.98.1, one test process/thread in a 9 GiB / 512 MiB-swap scope.Runtime source is exact head
24e65566c1; local test-only strengthening disclosed: replaced all three optional host-buffer lookups (wide/narrow/beyond) withexpect, rather than allowing this run to pass by skipping assertions. No production changes.a_wider_loose_window_covers_a_later_smaller_askverified Arc identity for the narrower covered request, a distinct backing for the beyond-range request, and the isolated reuse-counter delta. Output:verified all three host lookups; covered backing 8388608 bytes, noncovered 8388608 bytes. Physical NVIDIA adapter explicitly enumerated. This is buffer creation/reuse correctness, not a GPU shader dispatch or gameplay test.Command:
cargo test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib a_wider_loose_window_covers_a_later_smaller_ask -- --nocapture --test-threads=1via local Wine runner. Fresh compilation from this checkout confirmed; logverify-pr2856-wine-rtx4060-strict-window.log.Why this matters on this host: a separate, instrumented main
63bcca4load without this PR measured loose-window backing 256 -> 2,012 MiB before the unchanged free-RAM guard stopped loading; texture staging stayed at 32 MiB. Full owner measurements and caveats: #3012 . That makes this PR relevant, but I have not measured its reduction in that title run, nor does the fixture show bounded growth/reclamation of retained windows.Suggested fixture improvement remains the one earlier reviewers identified: require narrow/beyond lookups after successful hardware creation so allocation failures cannot skip the consumer-visible assertions; keep global counter checks isolated from unrelated tests. No objection from this isolated laptop/Wine lookup fixture.
AI assistance: OpenAI Codex ran the local verification and drafted this report. No title assets attached.
@pickles976 on GitHub · 2026-11-26 04:20 UTC · original
Follow-up retail loading measurement on the same RTX 4060 Laptop GPU 8 GiB / 16 GiB RAM / Wine 11.0 host: the reuse path executes, but this change alone did not clear the guarded world-load RAM blocker.
Provenance: main
63bcca43c6a00a758510398fa43096ce7e4f7df0+ the same local read-only memory probe described in #3012 . Candidate adds this PR's exact covering-range lookup and return behavior from24e65566, with a cumulative reuse counter in the probe (rather than the PR's 5-second presentation logger). This is a local main integration, not an exact PR-head title run. No other runtime changes. Fresh release diagnostics compilation verified.Both arms: Series S, reported 1920x1080/window 1280x720,
VICTORY_KEYS=20:Enter, 110 s maximum, 9 GiB scope / 512 MiB swap, global MemAvailable floor 2,048 MiB, GPU limit 6,000 MiB. Existing caches retained between arms; no cache reset. Initial available RAM differed (11,517.5 vs 11,217.7 MiB), and file-cache/background state was not controlled. Treat wall-time samples as descriptive, not matched world progress or a causal FPS/memory improvement.Candidate recorded 7,707 covering hits by its last sample. This is reuse-hit count, not unique buffers or bytes saved. The standing map still grows: overlapping reuse prevents some allocations but does not retire windows or bound distinct required content.
The baseline guard stopped at 73.90 s / 2,032.4 MiB available. Candidate stopped at 90.14 s / 1,960.5 MiB available, scope 7,647.3 MiB (anon 2,814.0), global GPU 3,113 MiB, disk 16.53 GiB; exit 137 was the guard, not a title crash. At ~70 s the candidate screenshot remained loading artwork, not gameplay. Candidate last diagnostics reported 3,873 decimal MB non-local video-memory use; its texture chunks stayed at 32 MiB and registered shadow backing reached ~895.7 MiB. Its final 2.5 FPS line describes loading, not gameplay performance or a demonstrated regression.
Suggested next measurable owner change: guest-lifetime-aware retirement/reuse of loose backing, with GPU-write/list/view/fence preservation, or an ownership census that identifies how much remains genuinely required. Do not turn the missing reclaim path into an indefinite admission wait. This does not retract the focused lookup-test pass; it limits what that pass and the reuse count establish for 16 GiB playability.
Local logs: baseline
20261126T041203Z-{console.log,resources.csv}; candidate20261126T041844Z-{console.log,resources.csv}andmain-63bcca4-pr2856-memory-build.log. Candidate screenshotmenu-20261126T041954164984Z.pngremains local. AI-assisted (OpenAI Codex); no assets attached.@kotekompotek on GitHub · 2026-11-25 22:51 UTC · original · reviewed
Sound reuse: a covering window serves the same memory by construction, the range(..(start, MAX)).rev() walk finds candidates starting at-or-before ours nearest-first, and 'first whose end reaches past ours' is exactly the containment test. The diagnostics counters make the savings measurable. LGTM.
@AwsAli05 on GitHub · 2026-11-25 22:56 UTC · original · reviewed
The new covering-window test at
24e6556passed on an RTX 5070 Ti. I found one reliability issue in that test.REUSESis process-wide, so another test that finds a covered window between the two loads can invalidate the exactbefore + 1assertion. Once the wide window exists, the conditionalnarrowandbeyondchecks also allow a failed lookup to skip the assertion they are meant to exercise.Could the coverage test assert identity and the returned range on both lookups, with the global counter check moved to an isolated run? That would keep the regression test focused on the reuse that reduces world-streaming memory.
AI-assisted review and test.
@Dukestar69 on GitHub · 2026-11-26 03:49 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):cargo test -p victory-gpu --lib shadow::tests: 10 passed, 0 failed (including newa_wider_loose_window_covers_a_later_smaller_ask).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 11:47 UTC · original · approved these changes
Reviewed and verified
24e65566on Windows 11 with RTX 5090, WARP (VICTORY_D3D12_WARP=1), and D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1).shadow::loose(crates/victory-gpu/src/shadow.rs:1091-1104) scans.range(..(start, u64::MAX)).rev()and selects the nearest-start window whose end reaches paststart + len, covering both strictly earlier starts and wider windows at the exact samestart.Shadowthroughoffset/left/gpuand refresh/write-back only their[address, address + len)sub-range; for structured views whose stride does not divide the shifted offset,for_viewalready falls back toexact(), preserving correctness.Verification:
cargo xtask policy(190 files ok) andcargo clippy -p victory-gpu --tests -- -D warnings(default and--all-features): clean.VICTORY_D3D12_DEBUG=1):shadow::tests10/10 (includinga_wider_loose_window_covers_a_later_smaller_ask) anddraw::tests20/20 passed.VICTORY_D3D12_DEBUG=1:shadow::tests10/10 passed.Two minor non-blocking notes: using
saturating_addonat + *l >= start + len(shadow.rs:1094) would guard against extreme high addresses, and ina_wider_loose_window_covers_a_later_smaller_ask(shadow.rs:1457-1522), assertingnarrow.expect(...)/beyond.expect(...)and avoiding an exactbefore + 1check against the process-wideREUSESatomic would keep the test strict and immune to parallel test interference.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.