GPU: reserve 2^18 dynamic slots on capped view heaps and trim fresh tables #2473

Open
kais7654 wants to merge 2 commits from upstream-pr/2475 into main
kais7654 commented 2026-11-25 14:19:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T14:19:36Z.


Implements #747, taking over #1349 (@wbkepler, author @wrothgaril kept on
the commit) rebased onto main 940d32f's layout.

The heap-sizing change keeps main's flow (the 2M mirrored floor, the
MIN_DYNAMIC middle branch) and changes only the deeply capped path: when
the host refuses both, the capped heap takes
capped_split(PORTABLE_VIEWS) — 737,856 mirrored title slots + the full
2^18 = 262,144 dynamic reserve — so the world's fresh tables stop
dropping every indirect draw and mesh dispatch for missing slots.

Fresh dynamic descriptor tables in draw.rs are trimmed to
[first_used, last_used] (clamped to the mirrored count so
base = first - start never underflows) and the per-list cache key
includes the [start, end) range.

Commits:

  1. the rebased #1349 change (2 files, author preserved);
  2. #1943's descriptor-heap test adaptation (cherry-picked, since
    dynamic_slots_are_held_until_released and
    lists_share_a_table_and_copies_keep_their_views fail on a capped host
    otherwise).

Verified on an RTX 5070 Laptop GPU (driver 616.87, Windows 11) where the
host caps its heaps right now: large_view_heap_keeps_full_dynamic_budget
runs the capped path live — a real 1,000,000-slot heap at 737,856
mirrored + 262,144 dynamic — and the full victory-gpu suite passes (146
tests; on a capped host the two adapted tests report the cap and skip
their size and pair-range assertions). WARP and uncapped hosts keep
main's assertions and behaviour unchanged.

The world-measurement numbers stay the ones the #747 thread collected.

AI-assisted (Mistral Vibe).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493132145 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T14:19:36Z. --- Implements #747, taking over #1349 (@wbkepler, author @wrothgaril kept on the commit) rebased onto main 940d32f's layout. The heap-sizing change keeps main's flow (the 2M mirrored floor, the MIN_DYNAMIC middle branch) and changes only the deeply capped path: when the host refuses both, the capped heap takes `capped_split(PORTABLE_VIEWS)` — 737,856 mirrored title slots + the full 2^18 = 262,144 dynamic reserve — so the world's fresh tables stop dropping every indirect draw and mesh dispatch for missing slots. Fresh dynamic descriptor tables in draw.rs are trimmed to [first_used, last_used] (clamped to the mirrored count so `base = first - start` never underflows) and the per-list cache key includes the `[start, end)` range. Commits: 1. the rebased #1349 change (2 files, author preserved); 2. #1943's descriptor-heap test adaptation (cherry-picked, since dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views fail on a capped host otherwise). Verified on an RTX 5070 Laptop GPU (driver 616.87, Windows 11) where the host caps its heaps right now: `large_view_heap_keeps_full_dynamic_budget` runs the capped path live — a real 1,000,000-slot heap at 737,856 mirrored + 262,144 dynamic — and the full victory-gpu suite passes (146 tests; on a capped host the two adapted tests report the cap and skip their size and pair-range assertions). WARP and uncapped hosts keep main's assertions and behaviour unchanged. The world-measurement numbers stay the ones the #747 thread collected. AI-assisted (Mistral Vibe).
DenRakEiw commented 2026-11-25 14:34:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:34:27Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • Reserving 2^18 dynamic slots on capped view heaps and trimming fresh tables fixes both pre-existing NVIDIA #1744 baseline failures on RTX 5090!
  • cargo test -p victory-gpu descriptor::host::tests: 7/7 passed on RTX 5090, 7/7 passed on WARP (including capped_view_heap_reserves_dynamic_slots, large_view_heap_keeps_full_dynamic_budget, and dynamic_slots_are_held_until_released).
  • cargo test -p victory-gpu memory::tests: 3/3 passed on RTX 5090 (including lists_share_a_table_and_copies_keep_their_views).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6059619360 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#pullrequestreview-6059619360). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T14:34:27Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP: - Reserving `2^18` dynamic slots on capped view heaps and trimming fresh tables fixes both pre-existing NVIDIA `#1744` baseline failures on RTX 5090! - `cargo test -p victory-gpu descriptor::host::tests`: 7/7 passed on RTX 5090, 7/7 passed on WARP (including `capped_view_heap_reserves_dynamic_slots`, `large_view_heap_keeps_full_dynamic_budget`, and `dynamic_slots_are_held_until_released`). - `cargo test -p victory-gpu memory::tests`: 3/3 passed on RTX 5090 (including `lists_share_a_table_and_copies_keep_their_views`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 14:57:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:57:39Z.

Review: COMMENTED


Reserve 2^18 dynamic slots on capped view heaps, trim (+180). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Third PR in the heap-capping cluster after #2451/#2461 — all three touch descriptor/host.rs caps; they will conflict with each other.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059997248 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#pullrequestreview-6059997248). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:57:39Z. **Review:** COMMENTED --- Reserve 2^18 dynamic slots on capped view heaps, trim (+180). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Third PR in the heap-capping cluster after #2451/#2461 — all three touch descriptor/host.rs caps; they will conflict with each other.
kotekompotek commented 2026-11-25 15:04:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:29:10Z.


Two separable changes, both in the right direction:

  1. capped_split keeping the full DYNAMIC inside the cap matches the #747 report — MIN_DYNAMIC's 2^16 starving the fresh tables on capped heaps is a real failure mode. Trimming title slots instead is defensible (highest title index seen ~720K < 737,856 kept here).

  2. The fresh-table trim is a good idea — copying only [start, end) instead of the whole prefix — with one edge to confirm: a table index below start now lands at base + k < first, i.e. inside unrelated heap slots (a mirrored slot of a different title slot, or another dynamic allocation), where the old whole-prefix copy put a real view or a null there. If a shader can index a descriptor array below its first used entry, it reads a foreign descriptor instead of a null — not a fault, but a wrong view. Worth a start = 0 clamp, or a comment on why indices below start are unreachable.

Overlap for triage: the heap-size test relaxation duplicates part of #2251 (merge-candidate), and the capped layout overlaps #2461's — worth merging one story for the NVIDIA cap.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165351280 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7165351280). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:29:10Z. --- Two separable changes, both in the right direction: 1. `capped_split` keeping the full `DYNAMIC` inside the cap matches the #747 report — `MIN_DYNAMIC`'s 2^16 starving the fresh tables on capped heaps is a real failure mode. Trimming title slots instead is defensible (highest title index seen ~720K < 737,856 kept here). 2. The fresh-table trim is a good idea — copying only `[start, end)` instead of the whole prefix — with one edge to confirm: a table index below `start` now lands at `base + k < first`, i.e. inside unrelated heap slots (a mirrored slot of a different title slot, or another dynamic allocation), where the old whole-prefix copy put a real view or a null there. If a shader can index a descriptor array below its first *used* entry, it reads a foreign descriptor instead of a null — not a fault, but a wrong view. Worth a `start = 0` clamp, or a comment on why indices below `start` are unreachable. Overlap for triage: the heap-size test relaxation duplicates part of #2251 (merge-candidate), and the capped layout overlaps #2461's — worth merging one story for the NVIDIA cap.
Marvisak commented 2026-11-25 17:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:39:48Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (67e8ae14). Conflicting files: 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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168339191 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7168339191). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:39:48Z. --- <!-- victory-triage v1 head=e33b8bff8203e7bda205042702c693f7ff1a2a34 verdict=needs-rebase at=2026-11-25T16:42:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (67e8ae14). Conflicting files: `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](https://claude.ai/code)_
xyzMikah commented 2026-11-25 17:05:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xyzMikah on 2026-11-25T17:04:40Z.


@kais7654 RTX 5060 Ti 16 GB, Windows 11. Both tests fail on main for me. Can test your branch once it's rebased. Want me to take the host.rs or draw.rs conflicts?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168967749 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7168967749). Originally posted by [xyzMikah](https://github.com/xyzMikah) on 2026-11-25T17:04:40Z. --- @kais7654 RTX 5060 Ti 16 GB, Windows 11. Both tests fail on main for me. Can test your branch once it's rebased. Want me to take the host.rs or draw.rs conflicts?
xyzMikah commented 2026-11-25 18:02:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xyzMikah on 2026-11-25T17:06:16Z.


RTX 5060 Ti 16 GB, Windows 11. Ran cargo test -p victory-gpu --lib on this branch: 146 passed, 0 failed, 2 ignored. Both tests that fail on main pass here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169009697 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7169009697). Originally posted by [xyzMikah](https://github.com/xyzMikah) on 2026-11-25T17:06:16Z. --- RTX 5060 Ti 16 GB, Windows 11. Ran cargo test -p victory-gpu --lib on this branch: 146 passed, 0 failed, 2 ignored. Both tests that fail on main pass here.
assttro commented 2026-11-26 13:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by assttro on 2026-11-26T13:03:01Z.


Tested on an RTX 3070 8 GB (driver 610.88; this host caps shader-visible view heaps). I applied only the descriptor/host.rs and memory.rs parts onto 940d32f + #230.

  • capped_view_heap_reserves_dynamic_slots, large_view_heap_keeps_full_dynamic_budget (gets the full 2^18 on the capped host) and the adapted descriptor-heap and memory tests: pass.
  • descriptor::host:: + memory::: 10 of 10.
  • Before this, the two size assertions failed on this card; that explains the "baseline failures" I'd seen.

I left out the draw.rs fresh-table trim, because of kotekompotek's point: an index below start would read another table's slot instead of a null. If the 2^18 split alone is enough in game, the trim could follow separately with start = 0 or a proof that lower indices are unreachable.

AI-assisted (Claude); results above are from my own runs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192805363 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7192805363). Originally posted by [assttro](https://github.com/assttro) on 2026-11-26T13:03:01Z. --- Tested on an RTX 3070 8 GB (driver 610.88; this host caps shader-visible view heaps). I applied only the `descriptor/host.rs` and `memory.rs` parts onto 940d32f + #230. - `capped_view_heap_reserves_dynamic_slots`, `large_view_heap_keeps_full_dynamic_budget` (gets the full 2^18 on the capped host) and the adapted descriptor-heap and memory tests: pass. - `descriptor::host::` + `memory::`: 10 of 10. - Before this, the two size assertions failed on this card; that explains the "baseline failures" I'd seen. I left out the `draw.rs` fresh-table trim, because of kotekompotek's point: an index below `start` would read another table's slot instead of a null. If the 2^18 split alone is enough in game, the trim could follow separately with `start = 0` or a proof that lower indices are unreachable. *AI-assisted (Claude); results above are from my own runs.*
HLVM04 commented 2026-11-26 14:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by HLVM04 on 2026-11-26T13:26:42Z.


An in-game data point for "if the 2^18 split alone is enough", though from the fork (fxceless/victory-fork), not this branch: RTX 5070 Ti 16 GB, Windows, Series S profile, a fork tree (0b0074e plus several open PRs and local changes).

  • The card caps shader-visible view heaps at exactly 1,000,000 (we tried sizes up to 2^21). Our build makes a 1,000,000-view heap and keeps the full 2^18 dynamic slots, so title indices past ~737,856 read the null slot, the same split as here.
  • The fork's fresh-table code at 0b0074e copies the whole prefix 0..n of a table, i.e. no [first_used, last_used] trim.
  • With that: 0 fresh tables refused for lack of slots in 3 runs of 210 s each, with about 275k tables asked per run.

So on this card and title the 2^18 reserve alone kept up, without the trim. Three runs, one scene region, and a different tree, so it says nothing about the trim's own cost or about the below-start edge.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193360687 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7193360687). Originally posted by [HLVM04](https://github.com/HLVM04) on 2026-11-26T13:26:42Z. --- An in-game data point for "if the 2^18 split alone is enough", though from the fork (fxceless/victory-fork), not this branch: RTX 5070 Ti 16 GB, Windows, Series S profile, a fork tree (0b0074e plus several open PRs and local changes). - The card caps shader-visible view heaps at exactly 1,000,000 (we tried sizes up to 2^21). Our build makes a 1,000,000-view heap and keeps the full 2^18 dynamic slots, so title indices past ~737,856 read the null slot, the same split as here. - The fork's fresh-table code at 0b0074e copies the whole prefix `0..n` of a table, i.e. no `[first_used, last_used]` trim. - With that: 0 fresh tables refused for lack of slots in 3 runs of 210 s each, with about 275k tables asked per run. So on this card and title the 2^18 reserve alone kept up, without the trim. Three runs, one scene region, and a different tree, so it says nothing about the trim's own cost or about the below-`start` edge.
borosf commented 2026-11-27 17:12:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T17:12:23Z.


Coordination note: same title as #1349 by @wbkepler, opened earlier (+145/−32 vs +180/−29). #1349 already has the capped-heap discussion, and #3518 argues about the same budget. Worth settling which one carries the 2^18 reservation before either merges.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224146709 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2475#issuecomment-7224146709). Originally posted by [borosf](https://github.com/borosf) on 2026-11-27T17:12:23Z. --- Coordination note: same title as #1349 by @wbkepler, opened earlier (+145/−32 vs +180/−29). #1349 already has the capped-heap discussion, and #3518 argues about the same budget. Worth settling which one carries the 2^18 reservation before either merges.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2475:upstream-pr/2475'
git switch 'upstream-pr/2475'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2475'
git switch 'upstream-pr/2475'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2475'
git switch 'upstream-pr/2475'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2475'
git switch 'main'
git merge --squash 'upstream-pr/2475'
git switch 'main'
git merge --ff-only 'upstream-pr/2475'
git switch 'main'
git merge 'upstream-pr/2475'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2473
No description provided.