GPU: Graceful degradation and dynamic recycling for descriptor heaps exceeding 1,000,000 slots #2189

Open
github-bot wants to merge 4 commits from github-bot/gh-2189 into main AGit
Owner

@⁠Xvania7 on GitHub · 2026-11-25 07:21 UTC · original
Xvania7:fix/issue-887-descriptor-heap-limit → main · +133 −5 · 2 files · 4 commits · open

Fixes #887 (supersedes tracking issue #902; related to #871, #876, #562).

Summary

  • Multi-tiered Heap Fallback (crates/victory-gpu/src/descriptor/host.rs): When requested views + dynamic headroom exceed PORTABLE_VIEWS (1,000,000) or heap creation fails, gracefully steps down through [PORTABLE_VIEWS, 500_000, 250_000, MIN_DYNAMIC] with 131_072 dynamic slots on capped 1M heaps.
  • Cursor Wraparound & Lifetime-Safe Allocation (descriptor/host.rs, draw.rs): Fixes free-span search across the ring cursor and keeps occupied dynamic slots strictly reserved until owning command lists release them (incorporating @⁠andrewpozdnakov7-jpg's lifetime fix 280d033 + @⁠MichaelSmithAI's review feedback).
  • Safe Out-of-Bounds Mirroring (HostHeap::mirror): Recovers and returns the underlying title View when index >= self.count so resource transitions and barriers continue cleanly.

Verification

  • Synthetic tests: heap_request_over_one_million_caps_gracefully, exhausted_heap_keeps_existing_descriptor_tables_reserved, dynamic_cursor_wraparound_finds_contiguous_span
  • Independently verified on RTX 5060 / Win10 and WARP (see #902 comments).
**@⁠Xvania7** on GitHub · 2026-11-25 07:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2189) `Xvania7:fix/issue-887-descriptor-heap-limit` → `main` · +133 −5 · 2 files · 4 commits · open Fixes #887 (supersedes tracking issue #902; related to #871, #876, #562). ### Summary - **Multi-tiered Heap Fallback (crates/victory-gpu/src/descriptor/host.rs):** When requested views + dynamic headroom exceed PORTABLE_VIEWS (1,000,000) or heap creation fails, gracefully steps down through [PORTABLE_VIEWS, 500_000, 250_000, MIN_DYNAMIC] with 131_072 dynamic slots on capped 1M heaps. - **Cursor Wraparound & Lifetime-Safe Allocation (descriptor/host.rs, draw.rs):** Fixes free-span search across the ring cursor and keeps occupied dynamic slots strictly reserved until owning command lists release them (incorporating @⁠andrewpozdnakov7-jpg's lifetime fix 280d033 + @⁠MichaelSmithAI's review feedback). - **Safe Out-of-Bounds Mirroring (HostHeap::mirror):** Recovers and returns the underlying title View when index >= self.count so resource transitions and barriers continue cleanly. ### Verification - Synthetic tests: heap_request_over_one_million_caps_gracefully, exhausted_heap_keeps_existing_descriptor_tables_reserved, dynamic_cursor_wraparound_finds_contiguous_span - Independently verified on RTX 5060 / Win10 and WARP (see #902 comments).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:55 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 08:52 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head 7e1292d6 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 704 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2189#issuecomment-7157573989) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `7e1292d6` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 704 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:28 UTC · original · edited 2026-11-25 16:02 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/descriptor/host.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2189#issuecomment-7163829369) · edited 2026-11-25 16:02 UTC <!-- victory-triage v1 head=364c6757c9c4efe799bb66c801ba46331151b4dd verdict=needs-rebase at=2026-11-25T16:11:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/descriptor/host.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 14:16 UTC · original

Addressed the triage points in (364c675):

  1. Hardware Tier 1 Anchor & Removal of Arbitrary Steps:
    Removed the 500k/250k loops. The cap is anchored directly to D3D12 Tier 1 limits (D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1 = 1_000_000) enforced by NVIDIA drivers (Ampere, Ada, Blackwell). Keeping PORTABLE_VIEWS = 1_000_000 preserves the invariant that translated shaders can safely clamp below HEAP_VIEWS.
  2. Order & Error Branch:
    Restored return None on plain allocation failure (Err(e) when count + MIN_DYNAMIC <= PORTABLE_VIEWS), avoiding retrying larger heaps when the device ran out of memory.
  3. Mirror Path Test Coverage:
    Updated heap_request_over_one_million_caps_gracefully to assert both the zero-tag fallback and the VIEW_TAG branch without host heap indexing.

All checks pass cleanly: unit tests 148 passed, Clippy 0 warnings, asset policy ok.

**@⁠Xvania7** on GitHub · 2026-11-25 14:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2189#issuecomment-7165012296) Addressed the triage points in (364c675): 1. **Hardware Tier 1 Anchor & Removal of Arbitrary Steps:** Removed the 500k/250k loops. The cap is anchored directly to D3D12 Tier 1 limits (`D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1 = 1_000_000`) enforced by NVIDIA drivers (Ampere, Ada, Blackwell). Keeping `PORTABLE_VIEWS = 1_000_000` preserves the invariant that translated shaders can safely clamp below `HEAP_VIEWS`. 2. **Order & Error Branch:** Restored `return None` on plain allocation failure (`Err(e)` when `count + MIN_DYNAMIC <= PORTABLE_VIEWS`), avoiding retrying larger heaps when the device ran out of memory. 3. **Mirror Path Test Coverage:** Updated `heap_request_over_one_million_caps_gracefully` to assert both the zero-tag fallback and the `VIEW_TAG` branch without host heap indexing. All checks pass cleanly: unit tests 148 passed, Clippy 0 warnings, asset policy ok.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/draw.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2189'
git switch 'github-bot/gh-2189'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2189'
git switch 'github-bot/gh-2189'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2189'
git switch 'main'
git merge --squash 'github-bot/gh-2189'
git switch 'main'
git merge --ff-only 'github-bot/gh-2189'
git switch 'main'
git merge 'github-bot/gh-2189'
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!2189
No description provided.