GPU: cap oversized sampler heaps at 2,048 with dynamic slots #2451

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

@⁠makmatvey on GitHub · 2026-11-25 13:48 UTC · original
makmatvey:cursor/gpu-sampler-heap-cap-afb6 → main · +84 −13 · 2 files · 1 commits · open

What's wrong

A title sampler heap larger than D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE (2,048) makes HostHeap::new return None on hosts that refuse the larger heap. Descriptor::host() caches that miss, and State::bind builds SetDescriptorHeaps with filter_map(...host()), so the heap disappears from the list and the root-signature heap indices shift (#65).

View heaps already cap at PORTABLE_VIEWS. Sampler heaps had no matching path. Open #1032 (triage: needs rebase) and closed #86 covered the same design; this is a focused re-land on current main.

What the change does

In crates/victory-gpu/src/descriptor/host.rs:

  • Cap past 2,048 up front (every binding tier; not only after a create failure), so behaviour does not depend on the driver.
  • Keep the first 1,792 title slots and reserve 256 dynamic slots so State::tables can remake tables whose entries reach past the cap (same path as capped view heaps).
  • Allow HostHeap::dynamic / release on capped sampler heaps.
  • Leave uncapped sampler heaps (≤ 2,048) with no dynamic slots, as on main.

Comment in draw.rs updated to name the sampler limit next to the view one.

Tests

  • large_sampler_heap_is_capped — requests 4 * HEAP_SAMPLERS, expects 1,792 title slots, a 2,048-descriptor host heap, and working dynamic allocate/release.
  • small_sampler_heap_has_no_dynamic_slots — requests 16, expects no dynamic slots and a host heap sized for HEAP_SAMPLERS.
  • This agent runs Linux without a D3D12 device; Windows CI exercises the new tests.

No game data used.

Fixes #65. Supersedes the needs-rebase approach in #1032 for current main.

**@⁠makmatvey** on GitHub · 2026-11-25 13:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2451) `makmatvey:cursor/gpu-sampler-heap-cap-afb6` → `main` · +84 −13 · 2 files · 1 commits · open ## What's wrong A title sampler heap larger than `D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE` (2,048) makes `HostHeap::new` return `None` on hosts that refuse the larger heap. `Descriptor::host()` caches that miss, and `State::bind` builds `SetDescriptorHeaps` with `filter_map(...host())`, so the heap disappears from the list and the root-signature heap indices shift (#65). View heaps already cap at `PORTABLE_VIEWS`. Sampler heaps had no matching path. Open #1032 (`triage: needs rebase`) and closed #86 covered the same design; this is a focused re-land on current `main`. ## What the change does In `crates/victory-gpu/src/descriptor/host.rs`: - Cap past 2,048 up front (every binding tier; not only after a create failure), so behaviour does not depend on the driver. - Keep the first 1,792 title slots and reserve 256 dynamic slots so `State::tables` can remake tables whose entries reach past the cap (same path as capped view heaps). - Allow `HostHeap::dynamic` / `release` on capped sampler heaps. - Leave uncapped sampler heaps (≤ 2,048) with no dynamic slots, as on `main`. Comment in `draw.rs` updated to name the sampler limit next to the view one. ## Tests - `large_sampler_heap_is_capped` — requests `4 * HEAP_SAMPLERS`, expects 1,792 title slots, a 2,048-descriptor host heap, and working dynamic allocate/release. - `small_sampler_heap_has_no_dynamic_slots` — requests 16, expects no dynamic slots and a host heap sized for `HEAP_SAMPLERS`. - This agent runs Linux without a D3D12 device; Windows CI exercises the new tests. No game data used. Fixes #65. Supersedes the needs-rebase approach in #1032 for current `main`.
A title sampler heap larger than D3D12's shader-visible limit made
HostHeap::new return None, so Descriptor::host cached the miss and
SetDescriptorHeaps dropped the heap (shifting root indices). Cap at
HEAP_SAMPLERS up front, keep the first 1,792 title slots, and reserve
256 dynamic slots so State::tables can remake tables past the cap.

Refs #65. Focused re-land of the design in closed #86 / needs-rebase #1032.

Co-authored-by: Matsvey Makushenka <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:19 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 14:23 UTC · original

Mechanics verified: State::tables already routes any table whose end index is >= host.count() through the fresh-table path (dynamic(n) + make_at), so a capped sampler heap works exactly like a capped view heap — before this, dynamic() unconditionally returned None for samplers and the draw was dropped. Keeping the cap unconditional (not only when creation fails) makes behavior host-independent, matching the comment. The warn-once when a table exceeds the dynamic pool is a good failure signal — a 256-slot dynamic budget is small, so a pathological title table pattern will show in the log rather than silently dropping draws.

**@⁠kotekompotek** on GitHub · 2026-11-25 14:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7165205242) Mechanics verified: `State::tables` already routes any table whose end index is `>= host.count()` through the fresh-table path (`dynamic(n)` + `make_at`), so a capped sampler heap works exactly like a capped view heap — before this, `dynamic()` unconditionally returned `None` for samplers and the draw was dropped. Keeping the cap unconditional (not only when creation fails) makes behavior host-independent, matching the comment. The warn-once when a table exceeds the dynamic pool is a good failure signal — a 256-slot dynamic budget is small, so a pathological title table pattern will show in the log rather than silently dropping draws.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:08 UTC · original

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.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7167633346) <!-- victory-triage v1 head=f1b8dd8ca816ef3105eda5a99ee23e4bbbb3779d verdict=needs-rebase at=2026-11-25T16:08:50Z --> 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`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2451/head:github-bot/gh-2451'
git switch 'github-bot/gh-2451'

Merge

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