GPU: stop the descriptor view table growing without bound #2097
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2099"
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 0xkn0wh3r3 on 2026-11-25T04:59:02Z.
The problem
The descriptor view table grows for the whole run, by about 1 GB after four minutes of Grand Theft Auto VI.
The table (
Viewsindescriptor.rs) never frees constant buffer views or views of placed memory. They have no resource object, so nothing releases them. Grand Theft Auto VI writes about 14,000 constant buffer views a frame at new addresses, and each is a new entry. Measured on fxceless/victory-fork: about 2.45 million entries (about 1 GB) after four minutes, and 11,000 more every second.The fix
These two kinds of view are no longer table entries. A descriptor's record already holds two 32-bit words; their top two bits now say what they hold:
constant_words).placed_words). A shape is the view's description without the address, kept in a small table of its own (one per kind of texture or buffer, however often the title moves them).Details:
view_at, which decodes all three. The host heap already read records through it;descriptor::viewnow does too.Ported from fxceless/victory-fork (commit
578d459): the view-table change only, not that commit's other descriptor changes.Testing
constant_views_fit_their_records: records round-trip addresses and sizes, and views that do not fit say so.views_at_new_addresses_add_no_entries: 20,000 views at new addresses add no table entries, and one shape stands for all the placed views.released_entries_keep_their_generations_below_the_kind_bits: a table generation wraps without colliding with the new record kinds.cargo test -p victory-gpu --libon an RTX 5070 Ti: all pass except the two tests that already fail onmainfrom the NVIDIA heap cap (#1835).cargo clippy -p victory-gpu --all-targets, with and without--features diagnostics: clean.Not covered
Not run with a game (no game data here); the growth figures are from the fork's run.
Rebased onto
13f91caUpstream's heap sync (
f809521) checks a page's records under one lock withviews_current, which read the table directly instead of going throughview_at. Records holding a constant buffer or placed view were never current, so a sync never made their slots (heap_syncs_make_the_slots_whose_records_changedfailed).views_currentnow decodes records asview_atdoes. Two new tests cover it:views_held_whole_are_current_for_heap_syncs(CPU-only) andheap_syncs_make_the_slots_whose_records_hold_their_views_whole. Test, clippy and policy results are unchanged from above.Rebased onto
f3578e3Only the tests conflicted (beside #2449's
null_cbv_clears_a_stale_view). #2449's null CBV isConstant(0, 0), which a record holds whole like any other constant buffer view. No upstream change since13f91careads record words apart fromview_at/views_current(#1906's view addresses, #2234, #2262 and #2462 work on decoded views).cargo test -p victory-gpu --lib: all pass but the three that fail onmainhere (two NVIDIA heap-cap tests and the flakyviews_bound_while_another_slot_gets_its_texture_do_not_wait). Clippy clean with and without--features diagnostics;cargo xtask policypasses.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:02:22Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Descriptor view table bounded — stops unbounded growth; check the eviction policy when the cap is hit (LRU vs fail).
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T05:36:58Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib descriptor::tests::— 8 passed, 0 failedcargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean bounded inline/generational representation stopping unbounded growth of the descriptor view table. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by desplmfao on 2026-11-25T06:21:30Z.
Tested this in Grand Theft Auto VI's world: RTX 5080, Linux, proton-cachyos 11.0, on
mainplus a few other open PRs (#2153, #2151). I measured VIctory's Rust heap with a counting global allocator and tracked allocations of 1 MiB or more by call site.Vecindescriptor::record(68, then 136, then 272 MB), and blocks under 4 KB grew alongside it, which fits theBTreeMapindex.descriptor::recordwas no longer among the top sites.Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:35:31Z.
@catminou4: there's no eviction. When something doesn't fit the new compact form, it stays an ordinary table entry, exactly as before this change. That covers a constant-buffer view past a 47-bit address, or one of 16 KiB or more that isn't a multiple of 256 bytes or reaches 4 MiB, a placed view past 1 TiB, and any placed view once the shape table is full. So hitting the cap only means those views grow the table as they do on
main; nothing is dropped or reused. The shape table holds one entry per kind of texture or buffer description, without the address, so it stays small however often the game moves its views.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:37:38Z.
Automated triage for the maintainers.
Merge candidate (re-checked on
2cad160). This push is a rebase ontomain. A range-diff against the previously reviewed head82d5d11shows the three commits unchanged. The only difference is one context line in an existingdescriptor.rstest, taken frommain.The change itself is unchanged. Constant buffer and placed views are encoded whole in their descriptor records (
constant_words,placed_wordsplus the smallshapestable), so they no longer add aViewstable entry each time.view_atandviews_currentdecode all three record kinds, and table generations wrap below the kind bits. An independent NVIDIA/Wine check of the previous head passed the five focused tests, including the host heap-sync test.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T18:37:11Z.
Thanks, both done in
b0af626:Viewsdoc comment now says only what the code does: constant buffer and placed views are named whole in their records, and the table keeps only placed-view shapes and the views that don't fit. The run figures and the fork reference are now only in the description. The same trim applies toviews_at_new_addresses_add_no_entries's doc comment.VICTORY_VIEW_INLINEis gone. Nothing depended on it, and the test that skipped when it was off now always runs.Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-25T20:25:12Z.
Independent Wine/NVIDIA check of
82d5d117b7, including theviews_current/ heap-sync follow-up. This used a separate checkout of the exact PR head, not our older title-integration tree.Environment: RTX 4060 Laptop 8 GiB, 16 GiB system RAM; Linux 6.17.0-40-generic; Wine 11.0; NVIDIA 590.48.01; DXVK 3.1.1-209-g1039f682058fa71; stock vkd3d-proton 3.2.0 (
2576c0b4adfae4a). Rust 1.98.1 Windows-MSVC cross-build, Wine Cargo runner,VICTORY_ADAPTER=nvidia,DXVK_CONFIG='dxgi.hideNvidiaGpu = False'. No Microsoft D3D12 debug-layer validation.After configuring the Windows SDK/linker and runner environment:
5 passed, 0 failed, 0 ignored. This covers compact CBV round-trips/boundaries, 20,000 changing addresses without table growth, generation wrapping/stale views, current-record classification, and the host-heap synchronization path for byte-copied compact records.
To rule out the GPU fixture's silent
host().is_none()return, I temporarily replaced only that return withassert!(host().is_some(), ...)and reranheap_syncs_make_the_slots_whose_records_hold_their_views_whole: 1 passed. The real NVIDIA device and host descriptor heap were used. That test-only change was then reverted; no runtime code was altered.Limits: the host test checks descriptor creation/synchronization, not shader execution or pixel readback. No full-suite result, in-title memory-growth measurement, VRAM saving, world-entry pass, or 15-minute stability claim follows from these checks. Those remain separate from the focused compatibility result above.
AI-assisted: omp with
openai-codex/gpt-6-astrainspected the PR, ran the checks and temporary no-skip probe, and prepared this report from the observed output.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:11:34Z.
Review: APPROVED
Reviewed
2cad1608b26fmerged cleanly onto63bcca43.Inlining constant buffer views and title-memory placed views directly into the 64-bit
(i, generation)slot record (crates/victory-gpu/src/descriptor.rs:484-640) eliminates unboundedViews::listgrowth without introducing eviction or stale-slot UAF risk:descriptor.rs:484-590): Using the top 2 bits ofgeneration(KIND_SHIFT = 30) gives 62 payload bits forCONSTANT(47-bit address + 15-bit exact/256B-scaled size) andPLACED(40-bit title-memory address + 22-bit deduplicatedShapeindex), with out-of-range addresses/sizes or full shape tables falling back cleanly to normal table entries.descriptor.rs:675-727): Wrapping table generations via((generation + 1) & GENERATIONS).max(1)keeps table entries strictly within1..=0x3FFF_FFFF(never colliding with0orCONSTANT/PLACEDkind bits), whileCONSTANT/PLACEDrecords always have non-zerogeneration.view_at(descriptor.rs:688) andviews_current(descriptor.rs:708) match across all four kind values, including unknown shape indices and untagged records.Hardware & D3D12 Debug Layer verification (RTX 5090 + Microsoft WARP,
VICTORY_D3D12_DEBUG=1):cargo xtask policyandcargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features) pass cleanly.descriptor::tests::(11/11) anddescriptor::host::tests::heap_syncs_make_the_slots_whose_records_hold_their_views_wholepass on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1.sync_slotscalls: zero D3D12 Debug Layer messages (host.log_messages() == None) and device healthy on both RTX 5090 and WARP.LGTM.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T02:29:56Z.
One gap that may let the shape table fill (read from this head
2cad160and another tree's measurements; not run here).shape_of(descriptor.rs:547-555) keys a placed view's shape on the whole 14-word resource description,(unordered, *resource, rest). Two of those words are padding inD3D12_RESOURCE_DESC:Alignment;Flagsat offset 48, padding the struct to 56 bytes.trustno1-coder/VIctory-NVIDIA#58 found that the title sometimes leaves exactly words 1 and 13 unwritten when it calls device methods
0x230/0x238. The same view then arrives with different bytes. Before its fix, their view table reached 2.3 million kept views (about 2.1 GB) in a 15-minute session at 1440p, Series X. With padding-only differences,Views::shapehere would hand out a new shape for each variant untilSHAPES(2^22) is reached, and then every further placed view goes back to being a table entry.Their fix, from JMAN730/project-flamingo
b1e0cd1dby way of Vice-Tay (GPL-3): copy only the named fields and zero the padding, with const asserts on the D3D12 offsets (alignment at 8, flags at 48, size 56). Here that would be zeroingresource[1]andresource[13]inshape_of, or increate_placed_srv/create_placed_uavbeforerecord. They also fixed a test,views_at_new_addresses_add_no_entries, that had built its description with non-zero padding words.A second, independent count of the same title behaviour, from another project's view-by-address textures (xcl-dev/xcl, GPL-2.0; numbers only): its key cleared bytes
0x34..0x38but not0x04..0x08of the same 0x38-byte description (words 1 and 13 here). There, 24,844 of 80,953 textures in a 200 s run were padding twins (31 %, xcl-dev/xcl#2762). With both ranges cleared, runs kept 29-31 % fewer such textures (RTX 4070 under Wine, RX 7900 XT under RADV).AI-assisted (Claude Code, Claude Opus 5.5 read this head and #58 there).
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.