Repository navigation
GPU: stop the descriptor view table growing without bound - #2099
0xkn0wh3r3 wants to merge 3 commits into
Conversation
catminou4
left a comment
There was a problem hiding this comment.
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).
DenRakEiw
left a comment
There was a problem hiding this comment.
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).
|
Tested this in Grand Theft Auto VI's world: RTX 5080, Linux, proton-cachyos 11.0, on
|
|
@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 |
|
Automated triage for the maintainers. Merge candidate (re-checked on The change itself is unchanged. Constant buffer and placed views are encoded whole in their descriptor records ( CI: passing ( Generated by Claude Code |
The previous main (old upstream base) is the first parent; the second is upstream main with the current heads of our pull requests merged in: Marvisak#2143, Marvisak#1849 (carried onto main's per-region runtime_pages), Marvisak#259, Marvisak#491, Marvisak#2153, Marvisak#2099, Marvisak#2071 (main covers it), Marvisak#2162, Marvisak#2218, Marvisak#2088, Marvisak#2389, Marvisak#177's element-type key on main's three handle maps, and the README. Marvisak#2112 (opt-in, in place) stays in the renderer branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, both done in b0af626:
|
b0af626 to
82d5d11
Compare
|
Independent Wine/NVIDIA check of 82d5d11, including the 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 ( After configuring the Windows SDK/linker and runner environment: cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc \
-p victory-gpu --lib -- --nocapture --test-threads=1 \
constant_views_fit_their_records \
views_at_new_addresses_add_no_entries \
released_entries_keep_their_generations_below_the_kind_bits \
views_held_whole_are_current_for_heap_syncs \
heap_syncs_make_the_slots_whose_records_hold_their_views_whole5 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 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 |
…ound) into demo
Every view a title writes is kept in one table, and a descriptor's record (the tag and two words) names its entry and generation, which survives titles copying descriptors as bytes. Views of resource objects are freed with their resource, but views without one (constant buffers, views of placed memory) have nothing that releases them, so their entries were kept for the run. Grand Theft Auto VI writes some 14,000 constant buffer views a frame, each at the address its constants have that frame: on fxceless/victory-fork, 2,450,139 entries after four minutes of play, about 1 GB with the index, growing by 11,000 a second. The record's two words now say what they hold in the generation's top two bits: 0, a table entry as before (generations stay below those bits); a constant buffer view whole (a 47-bit address and a 15-bit size: bytes below 16 KiB, else 256-byte units below 4 MiB); or a view of placed memory whole (a 40-bit title address and the number of its "shape", the view's description without its address, kept in a table of their own: as many as the title has kinds of textures and buffers). Views that do not fit (larger addresses or sizes, shapes past 2^22) stay table entries. Every reader goes through `view_at`, which decodes all three; the host heap keys its slots by the same two words, which stay equal for equal views and differ for different ones. `VICTORY_VIEW_INLINE=0` keeps every view a table entry. Ported from fxceless/victory-fork (commit 578d459), the view-table part only (not that commit's other descriptor changes). Tests (no GPU needed): - `constant_views_fit_their_records`: addresses and sizes round-trip, and those that do not fit say so. - `views_at_new_addresses_add_no_entries`: 20,000 constant buffer and placed views at new addresses add no entries and one shape. - `released_entries_keep_their_generations_below_the_kind_bits`: a generation bumped past the top wraps to 1, and the released view's record goes stale. Co-authored-by: fxceless <36782933+fxceless@users.noreply.github.com>
… records The VICTORY_VIEW_INLINE switch is gone, and the view table's doc comment says only what the code does; the measurements stay in the pull request.
`views_current`, which a heap sync uses to look at a page's records under one lock, compared every record with the table entry it names, so a record holding a constant buffer view or a view of placed memory whole was never current and its slot was never made: a title copying such records as bytes left the copies null. It now decodes records as `view_at` does: a table entry at its own generation, a constant buffer view, or a placed view whose shape is numbered. Tests: - `views_held_whole_are_current_for_heap_syncs` (no GPU needed): `views_current` agrees with `view_at` on constant and placed views held whole, live and released table entries, unknown shapes and kinds, and records without the tag. - `heap_syncs_make_the_slots_whose_records_hold_their_views_whole`: a heap sync makes slots given byte copies of a constant buffer view's and a placed view's records, and leaves a cleared one null.
82d5d11 to
2cad160
Compare
…e in their records Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # crates/victory-gpu/src/descriptor.rs
…nd views held whole) descriptor.rs is fork/main's but for Marvisak#688's lease module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous renderer (old upstream base 940d32f) is the first parent and is also kept as the branch renderer-2026-11-25-oldbase; the second parent is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with the renderer stack merged on it: Marvisak#439 (on main: update/439-main's resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292, Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes. Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by main: Marvisak#1769, Marvisak#1763, Marvisak#2366. The picture on this base still shows the overlay that plain upstream main shows too; that is being looked into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 (NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #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 13f91ca
Upstream's heap sync (f809521) checks a page's records under one lock with
views_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 f3578e3
Only 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 since 13f91ca reads 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.