GPU: reserve 2^18 dynamic slots on capped view heaps and trim fresh tables (#747) #1349

Open
github-bot wants to merge 1 commit from github-bot/gh-1349 into main AGit
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:34 UTC · original
wbkepler:gpu/nvidia-dynamic-view-heap → main · +145 −32 · 2 files · 1 commits · open

Summary

Implements #747:

  • Reserves the full DYNAMIC (2^18 = 262,144) dynamic view slots on capped 1M heaps via capped_split() (737,856 mirrored + 262,144 dynamic, safe for small limits) so NVIDIA world indirect/mesh tables do not starve.
  • Trims fresh dynamic descriptor tables in draw.rs to [first_used, last_used] (clamped to mirrored count so base = first - start never underflows) and includes (start, end) in the per-list cache key.
  • Adds unit and live-device tests covering capped dynamic reservation and first-used-entry fresh-table indexing.

Verification

  • cargo clippy -p victory-gpu --all-targets -- -D warnings — passed
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test -p victory-gpu — passed
  • cargo xtask policy — passed
**@⁠wbkepler** on GitHub · 2026-11-24 17:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349) `wbkepler:gpu/nvidia-dynamic-view-heap` → `main` · +145 −32 · 2 files · 1 commits · open ## Summary Implements #747: - Reserves the full `DYNAMIC` (`2^18` = 262,144) dynamic view slots on capped 1M heaps via `capped_split()` (`737,856` mirrored + `262,144` dynamic, safe for small limits) so NVIDIA world indirect/mesh tables do not starve. - Trims fresh dynamic descriptor tables in `draw.rs` to `[first_used, last_used]` (clamped to mirrored count so `base = first - start` never underflows) and includes `(start, end)` in the per-list cache key. - Adds unit and live-device tests covering capped dynamic reservation and first-used-entry fresh-table indexing. ## Verification - `cargo clippy -p victory-gpu --all-targets -- -D warnings` — passed - `cargo clippy -p victory --features diagnostics --all-targets` — passed - `cargo test -p victory-gpu` — passed - `cargo xtask policy` — passed
Implements #747:
- Reserve the full DYNAMIC (2^18 = 262,144) dynamic view slots on capped 1M
  heaps via capped_split() (737,856 mirrored + 262,144 dynamic, safe for
  small limits) so NVIDIA world indirect/mesh tables do not starve.
- Trim fresh dynamic descriptor tables in draw.rs to [first_used, last_used]
  (clamped to mirrored count so base = first - start never underflows) and
  include (start, end) in the per-list cache key.
- Add unit and live-device tests covering capped dynamic reservation and
  first-used-entry fresh-table indexing.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:22 +00:00
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 19:32 UTC · original

For triage: this conflicts with #955 (git merge-tree against the current heads, in descriptor/host.rs), and the two make incompatible choices about the same slots.

  • Here, capped_split(PORTABLE_VIEWS) gives (1_000_000 - 262_144, 262_144) = (737_856, 262_144), the whole 1M heap, and the uncapped path keeps count + DYNAMIC with all DYNAMIC slots dynamic.
  • #955 (which fixes the AMD >1M heap black screen) reserves the last slot of every view heap as a permanently-null guard that shaders clamp to: dynamic = DYNAMIC - 1 (or MIN_DYNAMIC - 1 when capped) and guard = total - 1.

Merged as they are, there is no slot left for #955's guard on a capped heap. Whichever lands second needs one slot less in one of the two ranges (e.g. DYNAMIC - 1 dynamic slots) so the guard stays outside both.

This PR on its own, at eb5fea7 on main ffe310e, isolated target directory, Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT: workspace 345 passed, 0 failed, including its three new tests; both clippy runs clean.

**@⁠shortselow-byte** on GitHub · 2026-11-24 19:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7142235499) For triage: this conflicts with #955 (`git merge-tree` against the current heads, in `descriptor/host.rs`), and the two make incompatible choices about the same slots. - Here, `capped_split(PORTABLE_VIEWS)` gives `(1_000_000 - 262_144, 262_144)` = `(737_856, 262_144)`, the whole 1M heap, and the uncapped path keeps `count + DYNAMIC` with all `DYNAMIC` slots dynamic. - #955 (which fixes the AMD >1M heap black screen) reserves the last slot of every view heap as a permanently-null guard that shaders clamp to: `dynamic = DYNAMIC - 1` (or `MIN_DYNAMIC - 1` when capped) and `guard = total - 1`. Merged as they are, there is no slot left for #955's guard on a capped heap. Whichever lands second needs one slot less in one of the two ranges (e.g. `DYNAMIC - 1` dynamic slots) so the guard stays outside both. This PR on its own, at `eb5fea7` on `main` `ffe310e`, isolated target directory, Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT: workspace 345 passed, 0 failed, including its three new tests; both clippy runs clean.
Author
Owner

@⁠devgosling on GitHub · 2026-11-24 20:48 UTC · original

Tested on an RTX 5080: the PR fixes the dynamic-slot starvation, but the world still hangs (0x887A0006) about as soon as before.

Setup

  • NVIDIA GeForce RTX 5080, driver 32.0.16.1088, Ryzen 9 9950X3D (its Radeon iGPU is also present; the RTX drives the display and nvlddmkm logs the errors), Windows 11 Pro 26200
  • Title 7952987A
  • diag profile with --features diagnostics, VICTORY_D3D12_DRED=1, default loop limit, no TDR registry changes. The D3D12 debug layer isn't installed, so this is DRED-only.
  • Baseline: main at ffe310e. PR: eb5fea7, which sits directly on ffe310e. One run each, same settings.
  • cargo test -p victory-gpu passes on this GPU with the PR: 53 passed, including the three new tests.

Results

ffe310e eb5fea7 (this PR)
View heap capped at 1000000 count=1245184 capped at 1000000 count=1245184 mirrored=737856 dynamic=262144
no free dynamic descriptor slots / no dynamic slots for its tables yes, from the first world frame on (dropped=1024 before the hang) none
title slot past the host heap none none
Hang after the first world frame ~22 s ~27 s
Last submission ms=5648 lists=27 ms=4730 lists=31
DRED page fault none none
DRED stop command 3 of 70 (op 42), mesh 159 [mesh 4adfa13bea1c556a] command 1391 of 1612 (op 42), commands 1390..1392 between barriers, mesh 50 [mesh 29f7805ffefc2e63, pixel 19acd330dacc8f32]

A third baseline run with VICTORY_SHADER_LOOP_LIMIT=4096 (ffe310e) also starved the dynamic slots (dropped=16384) and then hung on a single list (ms=4683 lists=1).

So on this GPU the dynamic-slot exhaustion comes with the hang, but it isn't what causes it. With the starvation gone, the hang is still a DispatchMesh hang with no page fault, and the mesh shader changes from run to run. That looks like the same thing as #1216 and #1670. These are single runs, so the timing difference between them doesn't mean much.

**@⁠devgosling** on GitHub · 2026-11-24 20:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7144083193) Tested on an RTX 5080: the PR fixes the dynamic-slot starvation, but the world still hangs (0x887A0006) about as soon as before. **Setup** - NVIDIA GeForce RTX 5080, driver 32.0.16.1088, Ryzen 9 9950X3D (its Radeon iGPU is also present; the RTX drives the display and `nvlddmkm` logs the errors), Windows 11 Pro 26200 - Title `7952987A` - `diag` profile with `--features diagnostics`, `VICTORY_D3D12_DRED=1`, default loop limit, no TDR registry changes. The D3D12 debug layer isn't installed, so this is DRED-only. - Baseline: `main` at `ffe310e`. PR: `eb5fea7`, which sits directly on `ffe310e`. One run each, same settings. - `cargo test -p victory-gpu` passes on this GPU with the PR: 53 passed, including the three new tests. **Results** | | `ffe310e` | `eb5fea7` (this PR) | |---|---|---| | View heap | `capped at 1000000 count=1245184` | `capped at 1000000 count=1245184 mirrored=737856 dynamic=262144` | | `no free dynamic descriptor slots` / `no dynamic slots for its tables` | yes, from the first world frame on (`dropped=1024` before the hang) | **none** | | `title slot past the host heap` | none | none | | Hang after the first world frame | ~22 s | ~27 s | | Last submission | `ms=5648 lists=27` | `ms=4730 lists=31` | | DRED page fault | none | none | | DRED stop | command 3 of 70 (op 42), `mesh 159 [mesh 4adfa13bea1c556a]` | command 1391 of 1612 (op 42), commands 1390..1392 between barriers, `mesh 50 [mesh 29f7805ffefc2e63, pixel 19acd330dacc8f32]` | A third baseline run with `VICTORY_SHADER_LOOP_LIMIT=4096` (`ffe310e`) also starved the dynamic slots (`dropped=16384`) and then hung on a single list (`ms=4683 lists=1`). So on this GPU the dynamic-slot exhaustion comes with the hang, but it isn't what causes it. With the starvation gone, the hang is still a `DispatchMesh` hang with no page fault, and the mesh shader changes from run to run. That looks like the same thing as #1216 and #1670. These are single runs, so the timing difference between them doesn't mean much.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 21:00 UTC · original

In-world evidence for keeping 2^18 on capped heaps, from a fork that runs main into the world on NVIDIA (RTX 4070, capped at 1,000,000 views): fxceless/victory-gta6, the comment on DYNAMIC in descriptor/host.rs.

  • main's capped fallback, 2^16 (MIN_DYNAMIC, from #336), ran out in the world: "no free dynamic descriptor slots".
  • 2^17 ran out in the opening cutscene. A frame asks for up to 16,000 tables while the frame before still holds its own. A draw whose table was refused read slots never made for it, and the card stopped within frames.
  • 2^18 on the capped heap (about 737,000 title slots left; the highest title slot seen is about 720,000) is what the fork keeps, as this PR does.

The fork also found a second cost, which may matter for @⁠devgosling's hang above. With slots free but in pieces, each refused table searched the whole ring before giving up: 0.33 ms each with 131,072 slots, and 1.0 s of the recording threads in a frame that refused 3,143 tables, all under the lock every table takes. It keeps a free-slot count, plus the shortest table length that last found no run, and refuses longer tables without searching until slots are given back.

Reading only, nothing run. AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 21:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7144345045) In-world evidence for keeping 2^18 on capped heaps, from a fork that runs `main` into the world on NVIDIA (RTX 4070, capped at 1,000,000 views): [fxceless/victory-gta6](https://github.com/fxceless/victory-gta6), the comment on `DYNAMIC` in `descriptor/host.rs`. - `main`'s capped fallback, 2^16 (`MIN_DYNAMIC`, from #336), ran out in the world: "no free dynamic descriptor slots". - **2^17 ran out in the opening cutscene.** A frame asks for up to 16,000 tables while the frame before still holds its own. A draw whose table was refused read slots never made for it, and the card stopped within frames. - 2^18 on the capped heap (about 737,000 title slots left; the highest title slot seen is about 720,000) is what the fork keeps, as this PR does. The fork also found a second cost, which may matter for @⁠devgosling's hang above. With slots free but in pieces, each refused table searched the whole ring before giving up: 0.33 ms each with 131,072 slots, and **1.0 s of the recording threads in a frame that refused 3,143 tables**, all under the lock every table takes. It keeps a free-slot count, plus the shortest table length that last found no run, and refuses longer tables without searching until slots are given back. Reading only, nothing run. AI-assisted (Claude Code).
Author
Owner

@⁠adnanoos on GitHub · 2026-11-24 22:08 UTC · original

RTX 5060 Laptop GPU: this PR stops every "no dynamic slots" drop and the world reaches the G-buffer

Setup. NVIDIA GeForce RTX 5060 Laptop GPU (heap capped at 1,000,000; the title asks 1,245,184), driver 32.0.16.2124, Windows 11 Pro 26200, title 1.0.2.1, Series X mode. Release build with --features diagnostics. The base is #1520 (2190efe) + the resync_title_writes bound from #994's thread + #452 + #1010. Compute eeed82b877b44b5f is skipped (VICTORY_SKIP_PIPELINES) in both runs, because it hangs the GPU here otherwise. Targets were dumped with VICTORY_DUMP_TARGETS at world frames. 8-minute runs, one each.

base base + this PR (eb5fea7)
host view heap 934,464 mirrored + 2^16 dynamic mirrored=672320 dynamic=262144 (see the merge note)
a draw or dispatch dropped: no dynamic slots for its tables over 1,048,576 in ~5.5 min of world 0
draws/frame in the world 897 2,401
indirect draws dropped/frame 2,665 926
draws dropped without a host pipeline/frame 2,233 1,206
device removal none none

Render targets.

  • Before: the 2560x1440 G-buffer colour targets (formats 27, 28, 34) held two specks. Only a later depth and mask pass had a few large shapes.
  • With this PR: the same targets hold the scene: a picnic table and bench, a plastic chair, a trash can, a sign, overhead lines. One target holds what looks like normals or material data, another albedo.
  • Unchanged: the final 3840x2160 output is still flat (this frame was a letterboxed cutscene: flat grey).

So on this GPU the PR takes the world from "not drawn" to "drawn but not lit". The remaining black is the lighting stage, as in #1317 and #638.

Merge note. On #1520, HostHeap::new also reserves aliases slots. To merge this PR there, I used count + DYNAMIC + aliases for the wanted size and capped_split(PORTABLE_VIEWS - aliases) for the capped case. The mirrored=672320 above comes from that.

Frame rate in the world drops (1.19 → 0.37 fps) because far more is drawn. No device removal in either run.

**@⁠adnanoos** on GitHub · 2026-11-24 22:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7145852899) **RTX 5060 Laptop GPU: this PR stops every "no dynamic slots" drop and the world reaches the G-buffer** **Setup.** NVIDIA GeForce RTX 5060 Laptop GPU (heap capped at 1,000,000; the title asks 1,245,184), driver 32.0.16.2124, Windows 11 Pro 26200, title 1.0.2.1, Series X mode. Release build with `--features diagnostics`. The base is #1520 (`2190efe`) + the `resync_title_writes` bound from #994's thread + #452 + #1010. Compute `eeed82b877b44b5f` is skipped (`VICTORY_SKIP_PIPELINES`) in both runs, because it hangs the GPU here otherwise. Targets were dumped with `VICTORY_DUMP_TARGETS` at world frames. 8-minute runs, one each. | | base | **base + this PR** (`eb5fea7`) | |---|---:|---:| | host view heap | 934,464 mirrored + 2^16 dynamic | `mirrored=672320 dynamic=262144` (see the merge note) | | `a draw or dispatch dropped: no dynamic slots for its tables` | **over 1,048,576** in ~5.5 min of world | **0** | | draws/frame in the world | 897 | **2,401** | | indirect draws dropped/frame | 2,665 | 926 | | draws dropped without a host pipeline/frame | 2,233 | 1,206 | | device removal | none | none | **Render targets.** - **Before:** the 2560x1440 G-buffer colour targets (formats 27, 28, 34) held two specks. Only a later depth and mask pass had a few large shapes. - **With this PR:** the same targets hold the scene: a picnic table and bench, a plastic chair, a trash can, a sign, overhead lines. One target holds what looks like normals or material data, another albedo. - **Unchanged:** the final 3840x2160 output is still flat (this frame was a letterboxed cutscene: flat grey). So on this GPU the PR takes the world from "not drawn" to "drawn but not lit". The remaining black is the lighting stage, as in #1317 and #638. **Merge note.** On #1520, `HostHeap::new` also reserves `aliases` slots. To merge this PR there, I used `count + DYNAMIC + aliases` for the wanted size and `capped_split(PORTABLE_VIEWS - aliases)` for the capped case. The `mirrored=672320` above comes from that. Frame rate in the world drops (1.19 → 0.37 fps) because far more is drawn. No device removal in either run.
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 22:25 UTC · original

Superseded by #1779, which redoes this on current main (70564ae).

main changed around this since the branch was cut: heaps are now at least HEAP_VIEWS (2^21) slots and translated shaders clamp to that and read the null buffer views at 2^21 - 2, neither of which exists in a capped 1,000,000-slot heap. #1779 keeps what this PR did (the full 2^18 dynamic range on a capped heap, tables made afresh trimmed to their first used entry) and adds the part this one could not cover: the clamp bound and the null buffer views fitted to the heap the host actually makes.

Leaving this open for the maintainers to close; it conflicts with main and will not be rebased.

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-24 22:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7146206874) Superseded by #1779, which redoes this on current `main` (70564ae). `main` changed around this since the branch was cut: heaps are now at least `HEAP_VIEWS` (2^21) slots and translated shaders clamp to that and read the null buffer views at `2^21 - 2`, neither of which exists in a capped 1,000,000-slot heap. #1779 keeps what this PR did (the full 2^18 dynamic range on a capped heap, tables made afresh trimmed to their first used entry) and adds the part this one could not cover: the clamp bound and the null buffer views fitted to the heap the host actually makes. Leaving this open for the maintainers to close; it conflicts with `main` and will not be rebased. _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:23 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7149499292) <!-- victory-triage v1 head=eb5fea7359f32c44a6bb7f57e5c6e2f2da00d071 verdict=needs-rebase at=2026-11-25T01:23:39Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/draw.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kais7654 on GitHub · 2026-11-25 14:20 UTC · original

Rebased and opened for review at the linked PR (author preserved on the
commit, @⁠wbkepler / @⁠wrothgaril credited). Main moved since ffe310e
(the marks upload, the tests module in draw.rs), so the conflicts are
resolved keeping main's flow — the 2M mirrored floor, the
MIN_DYNAMIC middle branch — and only the deeply capped path changes
to capped_split(PORTABLE_VIEWS). Verified on an RTX 5070 Laptop GPU
(driver 616.87) whose host refuses the 2M heap right now: the capped
path runs live with the full 2^18 reserve, and the whole victory-gpu
suite passes.

AI-assisted (Mistral Vibe).

**@⁠kais7654** on GitHub · 2026-11-25 14:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1349#issuecomment-7165135351) Rebased and opened for review at the linked PR (author preserved on the commit, @⁠wbkepler / @⁠wrothgaril credited). Main moved since ffe310e (the marks upload, the tests module in draw.rs), so the conflicts are resolved keeping main's flow — the 2M mirrored floor, the `MIN_DYNAMIC` middle branch — and only the deeply capped path changes to `capped_split(PORTABLE_VIEWS)`. Verified on an RTX 5070 Laptop GPU (driver 616.87) whose host refuses the 2M heap right now: the capped path runs live with the full 2^18 reserve, and the whole victory-gpu suite passes. AI-assisted (Mistral Vibe).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.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/1349/head:github-bot/gh-1349'
git switch 'github-bot/gh-1349'

Merge

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