Skip to content

GPU: reuse immutable descriptor tables across command lists - #562

Draft
aycow wants to merge 5 commits into
Marvisak:mainfrom
aycow:gpu/reuse-immutable-descriptor-tables
Draft

aycow wants to merge 5 commits into
Marvisak:mainfrom
aycow:gpu/reuse-immutable-descriptor-tables

Conversation

@aycow

@aycow aycow commented Nov 24, 2026 •

Copy link
Copy Markdown

Change

Share immutable texture SRV tables that current main already rebuilds because they extend beyond the mirrored portion of a capped native descriptor heap. The cache matches the full table width, populated offsets, title view generations and native resource identities. Each recorded list retains its allocation and the native resources through execution and replay. Cache hits still schedule the list's usual texture preparation and state transitions.

Ordinary dynamic ranges also retain their original allocator. Resetting an old recording releases only the slots it owns, even if a replacement title heap uses the same guest address. Current main's raw table CBVs, mixed tables, placed views, UAVs and direct bindless paths keep their existing materialization.

Synthetic reproduction and validation

On Windows with the D3D12 debug layer, a DXC supporting SM 6.6 and the Agility SDK 1.620.x x64 runtime:

$env:VICTORY_TABLE_TEST_AGILITY = 'C:/path/to/Agility/build/native/bin/x64'
$env:VICTORY_TABLE_TEST_DXC = 'C:/path/to/dxc.exe'
$env:VICTORY_TABLE_TEST_ADAPTER = 'amd' # or nvidia or warp
cargo test --locked -p victory-gpu --features diagnostics --lib descriptor::host::reuse_tests::capped_pool_texture_table_reuse -- --exact --ignored --nocapture --test-threads=1

Head 4cd352f passed strict diagnostics Clippy and 14 descriptor and memory tests. AMD Radeon Graphics, GeForce RTX 5070 Laptop GPU, and WARP passed the allocation, native readback, closed-list replay, heap replacement and last-owner retirement checks with full GPU-based validation. The fixture exercises the native allocator and output, with title-side eligibility tested separately. Reproduction and timing method

Workload on a 65,536-slot pool Allocation failures, baseline → shared Peak slots, baseline → shared
41 requests for repeated 2,048-slot tables 9 → 0 65,536 → 4,096
24 requests for repeated 2,048-slot tables 0 → 0 49,152 → 4,096
24 requests for unique 2,048-slot tables 0 → 0 49,152 → 49,152

Scope

The current results measure occupancy and correctness on an original synthetic workload. Title-level hit rates, performance and mixed-table coverage remain open. The cache uses main's synchronous completion contract and retains slots while a valid recording can replay them. Distinct ranges can still exhaust or fragment the pool. Fragmentation report

rpmaster2 recorded 12,212 mixed and 3,710 CBV-only requests before the first failed rebuilt table on RX 9070 XT. The texture cache saw zero hits there. LooperSalty eliminated the reported indirect allocation failures by enlarging the dynamic range from 65,536 to 262,144 on a different NVIDIA stack. AMD demand report · NVIDIA capacity control

The earlier CBV ownership and transactional reservation experiments remain available as supporting results. Cross-list mixed-resource and CBV sharing still requires immutable upload versions or submission-time binding. CBV replay fixture · Transactional reservation fixture

Draft pending a title workload that establishes demand for the eligible SRV tables. AI-assisted with OpenAI Codex.

@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown
Author

I published an opt-in companion branch at 82e4aa6 to measure which rebuilt tables account for the dynamic-pool demand. It reports reservations and failures by width, descriptor type, CBV presence, exact cross-list record duplication, generation changes and texture-sharing eligibility. AMD, NVIDIA and WARP passed the capped-pool readback fixture with full GPU-based validation.

If you're authorized to retest the exhaustion case, build the diagnostics branch, set VICTORY_DESCRIPTOR_DEMAND=1, and repeat the same warm-cache route. Please share only the rebuilt descriptor demand aggregate lines, revision, GPU/driver and whether the run exhausted the pool. Use a separate pass with the flag off for timing comparisons. Reproduction and counter definitions

@rpmaster2

rpmaster2 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested on RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26300, Ryzen 5 5600, 32 GB, pagefile 32/48 GB; diag build of this PR.

Menus 30 fps; world entry around frame 1024; no free dynamic descriptor slots: a table is not made n=135; 2 fps; host device removed (0x887A0004/0x887A0006) before the first cutscene. The reuse here does not remove the exhaustion on this host.

Requested diagnostics (aycow:gpu/descriptor-allocation-demand @82e4aa6, VICTORY_DESCRIPTOR_DEMAND=1), at the first failed rebuilt table (frame 1096):

  • outcome: LocalNew 13,879 tables / 71,536 slots; LocalReuse 2,906 / 39,215; NoRange 1 / 178; SharedNew and SharedReuse 0.
  • widths: 16 -> 8,483 / 60,196; 256 -> 167 / 23,064; 1024 -> 25 / 6,450; 4 -> 4,316 / 15,483; 1 -> 3,695 / 3,695; 64 -> 100 / 2,041.
  • composition: Mixed 12,212 / 72,250 with duplicate_untracked 11,947 / 71,159; CbvOnly 3,710 / 3,725 with duplicate_untracked 3,707 / 3,722; Unresolved 864 / 34,954 with duplicate_untracked 864 / 34,954.
  • then no free dynamic descriptor slots n=178 and device removal.

#550 was tested too: its past-host-heap path never fires on this host and the TDR remains. Full report: #597 (comment). No game data.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.

@LooperSalty

Copy link
Copy Markdown

A measurement for the capped-heap case this PR is about, on an RTX 4070 SUPER (view heap capped at 1,000,000; the title asks for 1,245,184), diag build of main 58fed37 + #89 #493 #189 #206 #469 #459 #454 #688 #464 #490 #497 #346 #483 #638 #579 #302 #489 #585 #617 #307 #550, 2 minutes in the world each time:

  • capped dynamic range 65,536 (current MIN_DYNAMIC): no dynamic slots for its tables 15 times, up to dropped=16384; and ~720 draws/frame dropped as indirect kind 10: prepare failed (compute false, mesh true) plus ~256/frame indirect kind 0: prepare failed for indirect rectangles (both go through take_dynamic in prepare_for/root_srv_table).
  • capped dynamic range 262,144 (local experiment: the capped branch takes PORTABLE_VIEWS - dynamic - guard title slots instead): 0 no dynamic slots, and neither indirect message appears any more. No new warning, no device removal.

So on NVIDIA the exhaustion is what drops the indirect mesh dispatches. The cost is fewer mirrored title slots (737,855 instead of 934,463); I saw no draw needing a slot in that range, but I have not checked it directly. Reusing tables as this PR does would get the same result without giving up title slots; it conflicts with #688's lease/reclaim allocator on my stack, so I could not test the two together.

🤖 Generated with Claude Code

@aycow
aycow force-pushed the gpu/reuse-immutable-descriptor-tables branch from b82f29c to 05c3757 Compare November 24, 2026 16:27
@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown
Author

@rpmaster2 @LooperSalty Thanks for the two controls. 05c3757 is rebased on ffe310e and keeps the #336 cap and refusal behavior. The 65,536-slot texture fixture again passed AMD, NVIDIA and WARP with GBV. The AMD workload had zero texture sharing hits and points to mixed/CBV demand. The NVIDIA capacity experiment identifies allocation pressure for indirect mesh admission, with a title-slot tradeoff on that test stack. I’ve recorded both results in the description. The synthetic ordered-copy test still needs separate upload versions even for identical CBV records; the rebased path keeps those uploads list-local.

@rpmaster2

Copy link
Copy Markdown

@aycow thanks - noted, and good to see 05c3757 rebased on ffe310e with the #336 cap and refusal behaviour kept.

One honest limitation from my side, so the record is clear: on the RX 9070 XT the "no free dynamic descriptor slots" refusal no longer appears at all on main @58fed37 or later (0 occurrences across a dozen 300-480 s world runs), so I cannot show a benefit from table reuse there any more - the pool simply is not the limiter on this host now. The AMD control you recorded (zero texture-sharing hits, mixed/CBV demand) is the last measurement where the demand was visible.

What I can still test on the rebased head, if it helps you: the same 480 s A/B against ffe310e with VICTORY_DESCRIPTOR_DEMAND=1, reporting the demand breakdown and whether no free dynamic slots stays at zero. Say the word and it goes in the queue - GPU runs on this machine are paused tonight after a driver reset froze it, so it would be tomorrow.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; the hardware and the dump are mine.

@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks for the RX 9070 XT repetition. The zero current-main refusals are a useful control. If a matched warm scene is available, could you share aggregate dynamic table counts by width and composition (CBV-only, mixed CBV/SRV/UAV, and sampler), unique/repeated counts, peak live slots and refusal counts? The exact commit and settings help compare shape without attributing a speedup to reuse. Counts only are sufficient. Cross-list CBVs still need immutable upload contents retained until fence completion.

@rpmaster2

Copy link
Copy Markdown

@aycow counts from the run I did on your diagnostics branch, as requested. All numbers are aggregates at the first failed rebuilt table, nothing scene-specific.

  • commit: aycow:gpu/descriptor-allocation-demand @82e4aa6, diag build, VICTORY_DESCRIPTOR_DEMAND=1, VICTORY_D3D12_DRED=1, DRED off for this run otherwise default; RX 9070 XT 16 GB, Adrenalin 26.11.2, Windows 11 26300, Ryzen 5 5600, 32 GB.
  • frame: 1096, reason first failed rebuilt table.

Outcome across the frame:

  • LocalNew 13,879 tables / 71,536 slots
  • LocalReuse 2,906 / 39,215
  • NoRange 1 / 178
  • SharedNew and SharedReuse 0 / 0

By width (requested):

  • 16: 8,483 tables / 60,196 slots (reserved 7,073 / 48,794)
  • 256: 167 / 23,064 (reserved 22 / 2,818)
  • 1024: 25 / 6,450 (reserved 3 / 774)
  • 4: 4,316 / 15,483 (reserved 4,289 / 15,405)
  • 1: 3,695 / 3,695 (reserved 2,427 / 2,427)
  • 64: 100 / 2,041 (reserved 65 / 1,318)

By composition:

  • Mixed: 12,212 tables / 72,250 slots, reserved 10,775 / 60,770, duplicate_untracked 11,947 / 71,159
  • CbvOnly: 3,710 / 3,725, reserved 2,442 / 2,457, duplicate_untracked 3,707 / 3,722
  • Unresolved: 864 / 34,954, reserved 662 / 8,309, duplicate_untracked 864 / 34,954

Then no free dynamic descriptor slots: a table is not made n=178 and the device was removed.

Two caveats for shape comparison, both from later runs on my host:

  1. That run predates GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots #336 landing in main; on main @58fed37 and later the refusal count is zero in every 300-480 s world run (a dozen of them), so this is the last measurement where the demand was visible on this card.
  2. I do not have a matched warm scene: each run restores the same save, but which passes finish compiling varies, so treat the counts as one sample of the same scene rather than a repeatable steady state.

I can re-run the demand branch on current main after this session (a long run is in flight right now) if a current-tree number is more useful than the historical one; it would be the same protocol, counts only.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; the hardware and the dump are mine.

@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown
Author

@rpmaster2 Thanks for the breakdown. The historical failure provides a useful width-178 stress case. Mixed tables accounted for 60,770 reserved slots and CBV-only tables for 2,457. The mixed duplicate counter did not establish identical immutable descriptor and upload generations, so it does not predict reusable capacity.

Your zero-refusal current-main results and the new RTX 5060 #1349 comparison make the next comparison more specific. Would you be able to share a current-main warm-window census with the same aggregate fields and peak live slots, including when refusals are zero? A #1349 comparison on the affected hardware would help establish how much pressure remains. We are keeping #562 in draft and holding mixed-CBV expansion until there is current demand and evidence that sealed upload versions can reduce it.

AI-assisted using Codex.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/descriptor.rs, crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

@aycow

aycow commented Nov 25, 2026

Copy link
Copy Markdown
Author

Updated to upstream 42363ab at 4cd352f. The draft shares immutable texture SRVs only when main already rebuilds the table on a capped heap. Main’s raw CBV and mixed-table paths are preserved. Recorded allocations now release into their original native heap even after title heap address reuse.

AMD, NVIDIA, and WARP passed native readback and closed-list replay with full GPU-based validation. In the synthetic 65,536-slot test, repeated tables reduced peak slots from 65,536 to 4,096 and allocation failures from nine to zero. The unique-table control kept the same occupancy. I updated the description with reproduction steps and the limitations of the current workload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants