gpu: preserve dynamic descriptor budget on capped heaps #3419
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!3419
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3419"
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?
@danielibabet on GitHub · 2026-11-27 00:18 UTC · original
danielibabet:pr/nvidia-dynamic-slots→main· +61 −12 · 1 files · 1 commits · openWhen a host caps shader-visible CBV/SRV/UAV heaps at \PORTABLE_VIEWS\ (1,000,000 on NVIDIA) and (count + DYNAMIC).max(HEAP_VIEWS)\ fails, \HostHeap::new\ previously dropped all the way down to \MIN_DYNAMIC\ (65,536) even when plenty of room remained below \PORTABLE_VIEWS.
Keep the full \DYNAMIC\ (262,144) budget — or \VICTORY_DYNAMIC_SLOTS\ clamped to [MIN_DYNAMIC, PORTABLE_VIEWS / 2]\ — when \PORTABLE_VIEWS\ allows it, only falling back to \MIN_DYNAMIC\ if the larger allocation itself fails.
Verified:
@Dukestar69 on GitHub · 2026-11-27 00:27 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: all passed.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-27 00:48 UTC · original · approved these changes
Looks good. Verified
capped_heap_slotsandHostHeap::newon a 1M-capped hardware adapter (RTX 5090,VICTORY_D3D12_DEBUG=1) as well as WARP (uncapped 2M heap):cargo xtask policyandcargo clippy --tests -p victory-gpu(default and--features diagnostics,-D warnings) pass cleanly.HostHeap::newpreserves the fullDYNAMIC(262,144) budget by default across small, large, and over-cap title counts (4 -> 4 + 262,144,900,000 -> 737,856 + 262,144,1,500,000 -> 737,856 + 262,144), and honorsVICTORY_DYNAMIC_SLOTSwith proper clamping to[MIN_DYNAMIC (65,536), PORTABLE_VIEWS / 2 (500,000)](131072,999999 -> 500000,100 -> 65536). Full dynamic-range allocation, exhaustion, release, and re-allocation succeed with no unexpected D3D12 debug layer errors.descriptor::host::testspass and the uncapped 2,097,152-slot layout (pairs_end = NULL_BUFFER_VIEW - 1) is unchanged.@rezioliver-collab on GitHub · 2026-11-27 02:59 UTC · original
I exercised the allocation-failure path on an Apple M1 by running the heap-selection code with a stub that records each requested size and can fail a specific attempt. I checked nine title counts, seven environment settings and four allocator behaviors on base
63bcca43and PR26987c81(252 combinations per revision).With 900,000 static descriptors requested and the default dynamic budget, the PR tried 2,097,152 slots, then 1,000,000. When I forced that second request to fail too, it retried with exactly 965,536 and succeeded, keeping all 900,000 static slots plus 65,536 dynamic. If the million-slot request succeeded, it selected 737,856 static plus 262,144 dynamic, matching the hardware result above. The first static request that loses a slot on that successful path is 737,857.
This checks retry order and the resulting partition using synthetic allocator responses. AI-assisted with Codex.
@borosf on GitHub · 2026-11-27 11:23 UTC · original
Arc data point, because the PR reads as NVIDIA-only and this card takes a third path into the same fallback. Intel Arc B580,
origin/main(63bcca43) + #2958, 200 s world run:So
count + DYNAMIC(1,507,328) andcount + MIN_DYNAMIC(1,310,720) both fail, and the heap ends upPORTABLE_VIEWSwithcount = 934,464,dynamic = 65,536. That 65,536 is exhausted every frame:a draw or dispatch dropped: no dynamic slots for its tablesno dynamic slots for root views [mesh …, pixel …]What I checked before saying the wider budget is safe on this title: the cap leaves 310,720 title slots unheld, and every one of them is read through the title-side path, not by a draw —
title slot past the host heap … for_draw=true: 0 occurrences in the whole 200 s log… for_draw=false: 310,720, all in a 1.8 s burst during heap build (indices 934,464 → 1,245,183)So on Arc, no draw ever reads a title slot past 934,464, and cutting
countto 737,856 to keepDYNAMICcosts nothing the renderer can see, while the dynamic starvation drops above go away. That is the case for the change on Intel, not just on NVIDIA.One caveat for whoever merges: with
countat 737,856 the title-side enumeration warns about 507,328 slots instead of 310,720, i.e. ~5 MB of WARN text per burst from this one heap. Worth pairing with #3475 (name the slots a capped heap could not hold) or aonce!-style rate limit; I would not block on it, but as it stands the log grows by that much each time the title rebuilds the heap.Synthetic tests only, no game files in the tree; the numbers are from a run of the title on my own dump.
@borosf on GitHub · 2026-11-27 11:29 UTC · original
Ran it on Intel Arc B580 with the game, not just the unit test — this PR takes a third path that its test does not cover, and on this card that path is the one used. It works: the dynamic-slot starvation goes from 201 drop events to zero.
Setup.
origin/main(63bcca43) + #2958 (our measured baseline,223ac4b9) with this PR's commit applied on top,--profile diag --features diagnostics, title 1.0.2.1,--console series-x,VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1, 110 s.The path.
capped_heap_slots(1_245_184, DYNAMIC)=(737_856, 262_144), andmake(737_856 + 262_144)= exactlyPORTABLE_VIEWS, which this host accepts:Before the PR this card landed on
count = 934,464, dynamic = 65,536(bothcount + DYNAMICandcount + MIN_DYNAMICfail here), so the dynamic budget is 4× with this PR.The result that matters —
no dynamic slotsdrop events, same logging, before/after:no dynamic slots for its tables/for root viewstitle slot past the host heap … for_draw=falsetitle slot past the host heap … for_draw=trueThose 201 were real work not submitted (each names a
mesh/pixelpair or a dispatch), so the change is a drawing improvement on this title, not only a budget one.Two things to act on:
934,464 − 737,856). So nothing warns spuriously — but that is ~75 MB of WARN text per heap build here, and it will grow if the band widens.capped_heap_slots_preserves_dynamic_budget_and_clampscovers500_000and900_000, both≤ PORTABLE_VIEWS, so thecount > PORTABLE_VIEWScase this card hits is never exercised. One line makes the Arc/NVIDIA-capped-below-demand case explicit:No timing claim from me. World frames only (draws ≥ 500) were 5 frames with the PR at a median 1,174.6 ms/frame (924.7 ms GPU, 3,565 draws) against 19 frames at 1,347.1 ms (990.3 ms GPU, 2,370 draws) on the baseline — different world points and too few frames to mean anything, though the direction is consistent with not dropping draws. The drop counters above are the per-frame facts.
Synthetic tests only in the tree; the run is my own dump. Machine: Windows 11 x64, Ryzen 5 5600, 32 GB, Arc B580 12 GB.
@KainanP on GitHub · 2026-11-27 11:54 UTC · original
At head
26987c81, a case this changes that @borosf's Arc run doesn't cover (read from the code, not run): a title whose view heap fits under the cap together withMIN_DYNAMICloses title slots thatmainkept.descriptor/host.rs:116-120:Take
count = 900_000on a 1,000,000-capped host:main,make(count + DYNAMIC)fails, thenmake(count + MIN_DYNAMIC)= 965,536 succeeds. All 900,000 title slots are kept, and there are 65,536 dynamic slots.capped_heap_slots(900_000, DYNAMIC)=(737_856, 262_144), andmake(1_000_000)succeeds. Title slots 737,856..899,999 now returnNoneat the top ofmirror(index >= self.count), for draws too. Tables there read null descriptors.The PR's own test asserts this outcome (
capped_heap_slots(900_000, DYNAMIC), line 2252). It also contradicts theMIN_DYNAMICdoc comment just above, "the title's slots keep their room first". Everycountbetween 737,856 and 934,464 is affected. That includes any title smaller than GTA VI's 1,245,184, where thefor_draw=true= 0 evidence doesn't apply.A rule that keeps the Arc/NVIDIA gain for counts above the cap and leaves smaller heaps as on
main: shrink the dynamic budget before cutting title slots.For 1,245,184 this still gives
(737_856, 262_144), the case measured above. For 900,000 it gives(900_000, 100_000), which is more dynamic room thanmain's 65,536 and no lost title slots.AI use: Claude Code (Claude Opus 5.5).
@borosf on GitHub · 2026-11-27 12:31 UTC · original
Game-measured, together with #2703, on Intel Arc B580. I built both PRs on top of a stack of my own 20 open PRs plus #2958, drove the title into the world with a scripted capture (below), and compared 300 s runs against
main(63bcca43) + #2958.no dynamic slotseventsroot view's offsetevents63bcca4+ #2958They do not conflict. Both edit
crates/victory-gpu/src/descriptor/host.rsand merge cleanly in either order — I merged this one first, then #2703, with no hand-resolution. If a maintainer wants both, there is nothing to reconcile.How the capture reaches the world (this is the part that was missing in my earlier reports): the title's first screen is mouse-driven — a click on the PLAYER label at ~(0.90, 0.945) of the window advances it, and Enter (pad A) does not. With that click, plus a prompt detector that only acts on the small bright prompt strip (
0.005 < bright < 0.25, so it never clicks a full-bright loading screen into quitting), and a local, never-pushed build flag that liftsgameinput.rs:1238's "foreground window is ours" gate, runs reach the world unattended. That flag is a measurement tool only; I am not proposing it here.Caveats, stated plainly. The stack run ended at 502 draws on the known pre-existing guest fault (
victory-image-b99f876b74d4a77f.dll+0x23cf683,write 0x0— the same PC as mymaincontrols, tracked in #2671), so the zero counters come from fewer world frames than the base row. The base row itself lost the device four times before reaching 7,648 draws. On this card roughly one run in three dies that way regardless of tree, which is why the numbers above are drop counters (per-frame facts) rather than timings; I would not quote a frame-time delta from one pair of runs.Synthetic tests only in the tree; every number is a run of the title on 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.