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

Open
github-bot wants to merge 2 commits 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 · +91 −13 · 2 files · 2 commits · open

Rebased onto current main

Unchanged in content: this is the same patch, re-landed on 63bcca4. The one
conflict was not semantic — main and this branch each appended a test to the
end of mod tests in descriptor/host.rs; all three are kept.

A test defect fixed on top

Reviewing this by the method the triage here applies — revert the fix, keep the
test, watch it fail — large_sampler_heap_is_capped did not test the fix it
exists to guard
. It opened with:

let Some(heap) = HostHeap::new(true, 4 * HEAP_SAMPLERS) else {
    return; // no host GPU
};

new returning None is the bug. On a host that refuses
make(4 * HEAP_SAMPLERS) — an RTX 3060 here — the tree without the cap takes
that "no host GPU" return and the test passes. Measured rather than read:

PROBE: new(true, 8192) -> None        # cap removed
test result: ok. 1 passed             # ...and still green

So the test was green before and after the change it was written to protect.

It now asks the host for the skip and then expects the heap, so a missing cap
panics here instead of passing quietly:

if crate::host::host().is_none() {
    return; // no host GPU
}
let heap = HostHeap::new(true, 4 * victory_shader::emit::HEAP_SAMPLERS)
    .expect("an oversized sampler heap is capped, not dropped");

Negative control, on the rebased tree:

Tree Result
cap removed, test kept FAILS at descriptor/host.rs:2501 — "an oversized sampler heap is capped, not dropped"
cap present passes

Verified on Windows 11, RTX 3060, Rust 1.98.1

Check Result
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings clean
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean
cargo test -p victory-gpu --lib --locked 231 passed, 2 failed, 1 ignored
cargo xtask policy 204 files ok

The two failures are pre-existing on main and unrelated to this change: the
capped-heap assertions descriptor::host::tests::dynamic_slots_are_held_until_released
and memory::tests::lists_share_a_table_and_copies_keep_their_views (issue #3178).
The count is 231 rather than the previous 229 because of the two new tests.

cargo fmt --check reports diffs elsewhere in the tree (crates/victory-formats/src/texture.rs
and others) on unmodified main; the two files this PR touches are clean, and
no unrelated reflow is included.

No game data used. make(4 * HEAP_SAMPLERS) is refused on this host, which is
what makes the first branch of HostHeap::new reachable here.

🤖 Generated with Claude Code

**@⁠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` · +91 −13 · 2 files · 2 commits · open ## Rebased onto current `main` Unchanged in content: this is the same patch, re-landed on `63bcca4`. The one conflict was not semantic — `main` and this branch each appended a test to the end of `mod tests` in `descriptor/host.rs`; all three are kept. ## A test defect fixed on top Reviewing this by the method the triage here applies — revert the fix, keep the test, watch it fail — `large_sampler_heap_is_capped` **did not test the fix it exists to guard**. It opened with: ```rust let Some(heap) = HostHeap::new(true, 4 * HEAP_SAMPLERS) else { return; // no host GPU }; ``` `new` returning `None` *is* the bug. On a host that refuses `make(4 * HEAP_SAMPLERS)` — an RTX 3060 here — the tree without the cap takes that "no host GPU" return and the test passes. Measured rather than read: ``` PROBE: new(true, 8192) -> None # cap removed test result: ok. 1 passed # ...and still green ``` So the test was green before and after the change it was written to protect. It now asks the host for the skip and then `expect`s the heap, so a missing cap panics here instead of passing quietly: ```rust if crate::host::host().is_none() { return; // no host GPU } let heap = HostHeap::new(true, 4 * victory_shader::emit::HEAP_SAMPLERS) .expect("an oversized sampler heap is capped, not dropped"); ``` Negative control, on the rebased tree: | Tree | Result | |------|--------| | cap removed, test kept | **FAILS** at `descriptor/host.rs:2501` — "an oversized sampler heap is capped, not dropped" | | cap present | passes | ## Verified on Windows 11, RTX 3060, Rust 1.98.1 | Check | Result | |-------|--------| | `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` | clean | | `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` | clean | | `cargo test -p victory-gpu --lib --locked` | 231 passed, 2 failed, 1 ignored | | `cargo xtask policy` | 204 files ok | The two failures are pre-existing on `main` and unrelated to this change: the capped-heap assertions `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views` (issue #3178). The count is 231 rather than the previous 229 because of the two new tests. `cargo fmt --check` reports diffs elsewhere in the tree (`crates/victory-formats/src/texture.rs` and others) on unmodified `main`; the two files this PR touches are clean, and no unrelated reflow is included. No game data used. `make(4 * HEAP_SAMPLERS)` is refused on this host, which is what makes the first branch of `HostHeap::new` reachable here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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)_
github-bot force-pushed github-bot/gh-2451 from f1b8dd8ca8 to cb36a9a1f2 2026-11-27 01:08:03 +00:00 Compare
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 13:55 UTC · original · approved these changes

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

  • Capping oversized sampler heaps at 2,048 with dynamic slots cleanly handles D3D12's sampler heap limit.
  • cargo test -p victory-gpu descriptor::host::tests -- --skip dynamic_slots_are_held_until_released: 6/6 passed on RTX 5090, 6/6 passed on WARP (including large_sampler_heap_is_capped and small_sampler_heap_has_no_dynamic_slots).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 13:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2451#pullrequestreview-6058901639) · **approved these changes** Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Capping oversized sampler heaps at 2,048 with dynamic slots cleanly handles D3D12's sampler heap limit. - `cargo test -p victory-gpu descriptor::host::tests -- --skip dynamic_slots_are_held_until_released`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `large_sampler_heap_is_capped` and `small_sampler_heap_has_no_dynamic_slots`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 14:11 UTC · original · reviewed

Cap oversized sampler heaps at 2,048 with dynamic slots. 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. Same heap-capping theme as #2461 — overlaps in descriptor/host.rs; whichever merges second conflicts.

**@⁠catminou4** on GitHub · 2026-11-25 14:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2451#pullrequestreview-6059179188) · **reviewed** Cap oversized sampler heaps at 2,048 with dynamic slots. 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. Same heap-capping theme as #2461 — overlaps in descriptor/host.rs; whichever merges second conflicts.
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/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.