GPU: a capped view heap keeps room for its page table's view pairs #3122

Open
github-bot wants to merge 2 commits from github-bot/gh-3122 into main AGit
Owner

@⁠Indy2l on GitHub · 2026-11-26 09:05 UTC · original
Indy2l:gpu/capped-view-heap → main · +26 −7 · 2 files · 2 commits · open

What

On hosts that cap shader-visible view heaps below HEAP_VIEWS (NVIDIA: 1,000,000), HostHeap::new made the heap exactly count + MIN_DYNAMIC slots. HostHeap::pair then had no range of its own (pairs_end == count + dynamic), so every page-table view pair fell back to self.dynamic(2) and drained the per-draw dynamic pool. When that pool runs out, tables are refused and draws are dropped.

lists_share_a_table_and_copies_keep_their_views already guards against this ("none takes a per-draw dynamic slot"). On an RTX 3060 its pairs came back as slots 2 and 4, which are dynamic slots.

Change

  • A capped heap reserves CAPPED_PAIRS slots past its dynamic range, as an uncapped heap has between count + DYNAMIC and HEAP_VIEWS. The overflow branch (title count past PORTABLE_VIEWS) takes that reservation from the title's kept-in-place slots.
  • Size: 2^14 (16,384). A pair per shadow copy: the world's roughly 4,700 copies take about 9,400 slots, so 2^14 leaves about 1.7 times that. In the overflow branch, each reserved slot is a title descriptor no longer kept in place, so it stays no larger than that. Pairs past the reservation still fall back to dynamic slots, as before.
  • Tests:
    • dynamic_slots_are_held_until_released accepts the capped layout and checks that the pair room exists.
    • The page-table test compares pairs against address_slots() instead of a hard-coded 1 << 18.

VICTORY_DYNAMIC_SLOTS (from the first revision) is split out, per review, to come back in its own PR with measurements from this repo.

Testing

  • RTX 3060, driver 32.0.16.2140, Windows 11.
  • cargo test -p victory-gpu --lib --locked: 231 passed. On main, 2 victory-gpu tests fail on this card.
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings: clean.
  • cargo xtask policy: clean.
  • Not yet measured in the world.

Refs #1744.

🤖 Generated with Claude Code

**@⁠Indy2l** on GitHub · 2026-11-26 09:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122) `Indy2l:gpu/capped-view-heap` → `main` · +26 −7 · 2 files · 2 commits · open ## What On hosts that cap shader-visible view heaps below `HEAP_VIEWS` (NVIDIA: 1,000,000), `HostHeap::new` made the heap exactly `count + MIN_DYNAMIC` slots. `HostHeap::pair` then had no range of its own (`pairs_end == count + dynamic`), so every page-table view pair fell back to `self.dynamic(2)` and drained the per-draw dynamic pool. When that pool runs out, tables are refused and draws are dropped. `lists_share_a_table_and_copies_keep_their_views` already guards against this ("none takes a per-draw dynamic slot"). On an RTX 3060 its pairs came back as slots 2 and 4, which are dynamic slots. ## Change - A capped heap reserves `CAPPED_PAIRS` slots past its dynamic range, as an uncapped heap has between `count + DYNAMIC` and `HEAP_VIEWS`. The overflow branch (title count past `PORTABLE_VIEWS`) takes that reservation from the title's kept-in-place slots. - **Size: 2^14 (16,384).** A pair per shadow copy: the world's roughly 4,700 copies take about 9,400 slots, so 2^14 leaves about 1.7 times that. In the overflow branch, each reserved slot is a title descriptor no longer kept in place, so it stays no larger than that. Pairs past the reservation still fall back to dynamic slots, as before. - Tests: - `dynamic_slots_are_held_until_released` accepts the capped layout and checks that the pair room exists. - The page-table test compares pairs against `address_slots()` instead of a hard-coded `1 << 18`. `VICTORY_DYNAMIC_SLOTS` (from the first revision) is split out, per review, to come back in its own PR with measurements from this repo. ## Testing - RTX 3060, driver 32.0.16.2140, Windows 11. - `cargo test -p victory-gpu --lib --locked`: 231 passed. On main, 2 victory-gpu tests fail on this card. - `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings`: clean. - `cargo xtask policy`: clean. - Not yet measured in the world. Refs #1744. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a host that caps shader-visible view heaps below HEAP_VIEWS (NVIDIA,
1,000,000), the heap was made exactly count + MIN_DYNAMIC slots, so
HostHeap::pair had no range of its own and every view pair took two
per-draw dynamic slots. Those ran out, and refused tables are dropped
draws. A capped heap now reserves CAPPED_PAIRS (2^16) past its dynamic
slots, as an uncapped heap has below HEAP_VIEWS.

VICTORY_DYNAMIC_SLOTS (opt-in, from VIctory-NVIDIA a9632bc) takes more
dynamic slots from the title's kept-in-place slots on a heap the title
overfills.

The two victory-gpu tests that failed on NVIDIA now pass: the heap-size
check accepts the capped layout, and the page-table test checks pairs
against the heap's own dynamic end instead of 2^18.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Per review: the dynamic-slot knob is a separate behaviour change and goes
to its own PR with measurements from this repo. The pair reservation is
sized from the world's about 4,700 shadow copies (about 9,400 slots): 2^14
leaves about 1.7 times that while taking fewer title slots in the overflow
branch; pairs past it still fall back to dynamic slots.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:07:54 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:07 UTC · original · approved these changes

Verified on RTX 5090 (1M view-heap cap) & WARP against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1: 15/15 passed on RTX 5090 (including dynamic_slots_are_held_until_released, which fails on clean origin/main under #1744).
  • cargo test -p victory-gpu --lib memory:: -- --test-threads=1: 8/8 passed on RTX 5090 and WARP (including lists_share_a_table_and_copies_keep_their_views, also previously failing on RTX 5090 under #1744).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly reserves room for the page table's view pairs on capped 1M view heaps (NVIDIA).

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122#pullrequestreview-6071219514) · **approved these changes** Verified on RTX 5090 (1M view-heap cap) & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1`: **15/15 passed** on RTX 5090 (including `dynamic_slots_are_held_until_released`, which fails on clean `origin/main` under `#1744`). - `cargo test -p victory-gpu --lib memory:: -- --test-threads=1`: **8/8 passed** on RTX 5090 and WARP (including `lists_share_a_table_and_copies_keep_their_views`, also previously failing on RTX 5090 under `#1744`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly reserves room for the page table's view pairs on capped 1M view heaps (NVIDIA). Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Indy2l on GitHub · 2026-11-26 09:14 UTC · original

Refs #1744. This should cover the failures there that come from the 1,000,000 view heap cap: dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views pass on an RTX 3060 here and on an RTX 5090 per the review above. I haven't confirmed the other two failures in that report; if the reporter can re-run cargo test -p victory-gpu --lib on this branch, that would settle it.

**@⁠Indy2l** on GitHub · 2026-11-26 09:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122#issuecomment-7187632265) Refs #1744. This should cover the failures there that come from the 1,000,000 view heap cap: `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views` pass on an RTX 3060 here and on an RTX 5090 per the review above. I haven't confirmed the other two failures in that report; if the reporter can re-run `cargo test -p victory-gpu --lib` on this branch, that would settle it.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 09:20 UTC · original

Automated triage for the maintainers.

Needs work: please split it. The core fix is right. On a capped heap pairs_end == count + dynamic, so HostHeap::pair always fell back to self.dynamic(2). Reserving CAPPED_PAIRS past the dynamic range in HostHeap::new (crates/victory-gpu/src/descriptor/host.rs) fixes that, and the updated address_slots() assertion in memory.rs is good. Before merge:

  1. Move capped_dynamic/VICTORY_DYNAMIC_SLOTS to their own PR. It is a separate behaviour change with no test. It can take up to about half the heap from the title's kept-in-place slots, and its comment cites numbers from another fork. It can come back with measurements from this repo.
  2. Justify the 2^16 reservation. In the overflow branch, each of those slots is a title descriptor that can no longer be kept in place. The world's roughly 4,700 copies need about 9,400 slots per table, so 2^14 may be enough.
  3. Wrap the long let asked = ... line.

A PR with only the pair reservation, sized with a stated reason, would be a merge candidate. This does not overlap #3119.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 09:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122#issuecomment-7187821229) <!-- victory-triage v1 head=d2b946aa7876b8f94225400dc08b2f6cb783c1aa verdict=needs-work at=2026-11-26T09:22:00Z --> Automated triage for the maintainers. **Needs work: please split it.** The core fix is right. On a capped heap `pairs_end == count + dynamic`, so `HostHeap::pair` always fell back to `self.dynamic(2)`. Reserving `CAPPED_PAIRS` past the dynamic range in `HostHeap::new` (`crates/victory-gpu/src/descriptor/host.rs`) fixes that, and the updated `address_slots()` assertion in `memory.rs` is good. Before merge: 1. Move `capped_dynamic`/`VICTORY_DYNAMIC_SLOTS` to their own PR. It is a separate behaviour change with no test. It can take up to about half the heap from the title's kept-in-place slots, and its comment cites numbers from another fork. It can come back with measurements from this repo. 2. Justify the 2^16 reservation. In the overflow branch, each of those slots is a title descriptor that can no longer be kept in place. The world's roughly 4,700 copies need about 9,400 slots per table, so 2^14 may be enough. 3. Wrap the long `let asked = ...` line. A PR with only the pair reservation, sized with a stated reason, would be a merge candidate. This does not overlap #3119. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 09:27 UTC · original · approved these changes

Clean, well-scoped fix for NVIDIA's 1,000,000-descriptor view-heap cap.

Reviewed crates/victory-gpu/src/descriptor/host.rs and crates/victory-gpu/src/memory.rs:

  • Non-overflow capped heaps (count + MIN_DYNAMIC + CAPPED_PAIRS <= PORTABLE_VIEWS) allocate CAPPED_PAIRS (65,536) slots past [count, count + MIN_DYNAMIC), so HostHeap::pair stops falling back to self.dynamic(2) and draining per-draw dynamic slots.
  • Overflow capped heaps clamp VICTORY_DYNAMIC_SLOTS to [MIN_DYNAMIC, PORTABLE_VIEWS / 2 - CAPPED_PAIRS] ([65_536, 434_464]), preserving at least 500,000 in-place title slots plus 65,536 pair slots with no underflow.
  • Uncapped heaps / WARP stay on the existing (count + DYNAMIC).max(HEAP_VIEWS) path unchanged.
  • Updating memory.rs to assert >= views.address_slots() validates the real invariant (pairs live past dynamic slots) across both capped and uncapped layouts.

Verified locally on Windows 11 with a 1M-capped RTX 5090 and WARP:

  • cargo clippy --workspace --all-targets [--all-features] -- -D warnings: clean
  • cargo xtask policy: 191 files ok
  • RTX 5090: descriptor::host::tests:: 15/15 passed (dynamic_slots_are_held_until_released now passes) and memory::tests:: 8/8 passed (lists_share_a_table_and_copies_keep_their_views now passes)
  • RTX 5090 + VICTORY_D3D12_DEBUG=1: both previously failing tests pass with zero debug layer errors
  • RTX 5090 with VICTORY_DYNAMIC_SLOTS=0, 524288, 999999999: dynamic_slots_are_held_until_released passes in all cases
  • WARP (--features diagnostics, VICTORY_D3D12_WARP=1) + VICTORY_D3D12_DEBUG=1: descriptor::host::tests:: 15/15 passed, memory::tests:: 8/8 passed

Two minor non-blocking notes:

  • count + MIN_DYNAMIC + CAPPED_PAIRS at descriptor/host.rs:180,182 (like the existing count + DYNAMIC at line 175) uses unchecked u32 addition; using saturating_add would guard against a wild title descriptor count.
  • VICTORY_DYNAMIC_SLOTS could be documented alongside the other VICTORY_* environment variables if desired.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122#pullrequestreview-6071538677) · **approved these changes** Clean, well-scoped fix for NVIDIA's 1,000,000-descriptor view-heap cap. Reviewed `crates/victory-gpu/src/descriptor/host.rs` and `crates/victory-gpu/src/memory.rs`: - Non-overflow capped heaps (`count + MIN_DYNAMIC + CAPPED_PAIRS <= PORTABLE_VIEWS`) allocate `CAPPED_PAIRS` (65,536) slots past `[count, count + MIN_DYNAMIC)`, so `HostHeap::pair` stops falling back to `self.dynamic(2)` and draining per-draw dynamic slots. - Overflow capped heaps clamp `VICTORY_DYNAMIC_SLOTS` to `[MIN_DYNAMIC, PORTABLE_VIEWS / 2 - CAPPED_PAIRS]` (`[65_536, 434_464]`), preserving at least 500,000 in-place title slots plus 65,536 pair slots with no underflow. - Uncapped heaps / WARP stay on the existing `(count + DYNAMIC).max(HEAP_VIEWS)` path unchanged. - Updating `memory.rs` to assert `>= views.address_slots()` validates the real invariant (pairs live past dynamic slots) across both capped and uncapped layouts. Verified locally on Windows 11 with a 1M-capped RTX 5090 and WARP: - `cargo clippy --workspace --all-targets [--all-features] -- -D warnings`: clean - `cargo xtask policy`: `191 files ok` - RTX 5090: `descriptor::host::tests::` 15/15 passed (`dynamic_slots_are_held_until_released` now passes) and `memory::tests::` 8/8 passed (`lists_share_a_table_and_copies_keep_their_views` now passes) - RTX 5090 + `VICTORY_D3D12_DEBUG=1`: both previously failing tests pass with zero debug layer errors - RTX 5090 with `VICTORY_DYNAMIC_SLOTS=0`, `524288`, `999999999`: `dynamic_slots_are_held_until_released` passes in all cases - WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`) + `VICTORY_D3D12_DEBUG=1`: `descriptor::host::tests::` 15/15 passed, `memory::tests::` 8/8 passed Two minor non-blocking notes: - `count + MIN_DYNAMIC + CAPPED_PAIRS` at `descriptor/host.rs:180,182` (like the existing `count + DYNAMIC` at line 175) uses unchecked `u32` addition; using `saturating_add` would guard against a wild title descriptor count. - `VICTORY_DYNAMIC_SLOTS` could be documented alongside the other `VICTORY_*` environment variables if desired. LGTM.
Author
Owner

@⁠Indy2l on GitHub · 2026-11-26 09:32 UTC · original

Thanks for the review. Addressed in 69618cf:

  1. capped_dynamic / VICTORY_DYNAMIC_SLOTS removed from this PR. I'll bring it back separately with in-world measurements from this repo.
  2. CAPPED_PAIRS is now 2^14, with the reason beside the constant: about 4,700 world copies take about 9,400 pair slots, so 2^14 gives about 1.7x headroom while taking fewer title slots in the overflow branch. Pairs past it still fall back to dynamic slots.
  3. The long line went with (1).

cargo test -p victory-gpu --lib (231 passed), both clippy configurations and cargo xtask policy are clean on an RTX 3060. The PR description is updated to match.

**@⁠Indy2l** on GitHub · 2026-11-26 09:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/3122#issuecomment-7188135848) Thanks for the review. Addressed in 69618cf: 1. `capped_dynamic` / `VICTORY_DYNAMIC_SLOTS` removed from this PR. I'll bring it back separately with in-world measurements from this repo. 2. `CAPPED_PAIRS` is now 2^14, with the reason beside the constant: about 4,700 world copies take about 9,400 pair slots, so 2^14 gives about 1.7x headroom while taking fewer title slots in the overflow branch. Pairs past it still fall back to dynamic slots. 3. The long line went with (1). `cargo test -p victory-gpu --lib` (231 passed), both clippy configurations and `cargo xtask policy` are clean on an RTX 3060. The PR description is updated to match.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3122/head:github-bot/gh-3122'
git switch 'github-bot/gh-3122'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3122'
git switch 'github-bot/gh-3122'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3122'
git switch 'github-bot/gh-3122'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3122'
git switch 'main'
git merge --squash 'github-bot/gh-3122'
git switch 'main'
git merge --ff-only 'github-bot/gh-3122'
git switch 'main'
git merge 'github-bot/gh-3122'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3122
No description provided.