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

Closed
makmatvey wants to merge 2 commits from upstream-pr/2451 into main
makmatvey commented 2026-11-25 13:48:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:48:19Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5492589986 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-25T13:48:19Z. --- ## 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)
DenRakEiw commented 2026-11-25 13:55:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:55:23Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6058901639 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#pullrequestreview-6058901639). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T13:55:23Z. **Review:** APPROVED --- 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).
catminou4 commented 2026-11-25 14:11:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:23Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059179188 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#pullrequestreview-6059179188). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:23Z. **Review:** COMMENTED --- 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.
kotekompotek commented 2026-11-25 15:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:23:29Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165205242 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7165205242). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:23:29Z. --- 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.
Marvisak commented 2026-11-25 16:09:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:08:48Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167633346 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7167633346). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:08:48Z. --- <!-- 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)_
kalberts0089-hash commented 2026-11-27 10:57:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kalberts0089-hash on 2026-11-27T10:57:47Z.


RTX 4070 Ti (Ada), driver 621.01, Windows 11: tests at head cb36a9a

Head cb36a9a1f2b1ad13aae272ad2e8f6986bfcd935e, which sits directly on current main (63bcca4), so it was tested as is with nothing merged locally. The only hardware run at this head so far was the author's RTX 3060.

Confirmed

Suite main 63bcca4 #2451 cb36a9a
cargo test -p victory-gpu --lib -- --test-threads=1 229 passed, 2 failed, 1 ignored 231 passed, 2 failed, 1 ignored
cargo test -p victory-shader --lib --no-fail-fast (one test skipped, below) 298 passed, 3 failed, 3 ignored 298 passed, 3 failed, 3 ignored
  • The only difference from main is the two new tests, both passing: large_sampler_heap_is_capped and small_sampler_heap_has_no_dynamic_slots. Each also passes 3/3 alone with --exact --nocapture.
  • The failures are the known NVIDIA ones on main, same assertions on both sides, unrelated to this change: victory-gpu dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views; victory-shader a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and gathers_at_a_level_match_the_hardware. heap_direct_texture_reads_mark_their_heap_index was skipped on both sides (#2571).

Negative control, with the cap reverted locally

Not a change to the PR: an uncommitted local edit that put the sampler branch of HostHeap::new back to main's form (make(count.max(samplers)), None on error), with the PR's tests kept, plus one line printing the error. It was restored afterwards.

Tree large_sampler_heap_is_capped
cb36a9a passes, 3/3
cb36a9a with the cap reverted locally fails, 3/3: "an oversized sampler heap is capped, not dropped"
restored passes
  • This card refuses the oversized heap the same way the RTX 3060 does: CreateDescriptorHeap for 8,192 samplers returns 0x80070057 (the parameter is incorrect). It comes back as an ordinary error return, and small_sampler_heap_has_no_dynamic_slots still passes in the reverted tree.
  • So on Ada too, the test at this head fails without the cap and passes with it.

Not tested

  • The title, or any run beyond the test suites.
  • A draw whose sampler table reaches past the 1,792 title slots a capped heap keeps: the two tests cover the heap's size and its dynamic slot bookkeeping, not the fresh-table path in State::tables.
  • A table larger than the 256 dynamic slots (the warn-once path).
  • The debug layer, clippy, cargo xtask policy, other crates.

Synthetic tests only, no game files. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7216516032 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7216516032). Originally posted by [kalberts0089-hash](https://github.com/kalberts0089-hash) on 2026-11-27T10:57:47Z. --- **RTX 4070 Ti (Ada), driver 621.01, Windows 11: tests at head `cb36a9a`** Head `cb36a9a1f2b1ad13aae272ad2e8f6986bfcd935e`, which sits directly on current `main` (`63bcca4`), so it was tested as is with nothing merged locally. The only hardware run at this head so far was the author's RTX 3060. ### Confirmed | Suite | `main` `63bcca4` | #2451 `cb36a9a` | |---|---|---| | `cargo test -p victory-gpu --lib -- --test-threads=1` | 229 passed, 2 failed, 1 ignored | 231 passed, 2 failed, 1 ignored | | `cargo test -p victory-shader --lib --no-fail-fast` (one test skipped, below) | 298 passed, 3 failed, 3 ignored | 298 passed, 3 failed, 3 ignored | - The only difference from `main` is the two new tests, both passing: `large_sampler_heap_is_capped` and `small_sampler_heap_has_no_dynamic_slots`. Each also passes 3/3 alone with `--exact --nocapture`. - The failures are the known NVIDIA ones on `main`, same assertions on both sides, unrelated to this change: victory-gpu `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`; victory-shader `a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` and `gathers_at_a_level_match_the_hardware`. `heap_direct_texture_reads_mark_their_heap_index` was skipped on both sides (#2571). ### Negative control, with the cap reverted locally Not a change to the PR: an uncommitted local edit that put the sampler branch of `HostHeap::new` back to `main`'s form (`make(count.max(samplers))`, `None` on error), with the PR's tests kept, plus one line printing the error. It was restored afterwards. | Tree | `large_sampler_heap_is_capped` | |---|---| | `cb36a9a` | passes, 3/3 | | `cb36a9a` with the cap reverted locally | **fails, 3/3**: "an oversized sampler heap is capped, not dropped" | | restored | passes | - This card refuses the oversized heap the same way the RTX 3060 does: `CreateDescriptorHeap` for 8,192 samplers returns `0x80070057` (the parameter is incorrect). It comes back as an ordinary error return, and `small_sampler_heap_has_no_dynamic_slots` still passes in the reverted tree. - So on Ada too, the test at this head fails without the cap and passes with it. ### Not tested - The title, or any run beyond the test suites. - A draw whose sampler table reaches past the 1,792 title slots a capped heap keeps: the two tests cover the heap's size and its dynamic slot bookkeeping, not the fresh-table path in `State::tables`. - A table larger than the 256 dynamic slots (the warn-once path). - The debug layer, clippy, `cargo xtask policy`, other crates. Synthetic tests only, no game files. AI-assisted (Claude Code).
upipibi commented 2026-11-28 04:48:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T04:48:28Z.


For whoever picks: #1032 (divyeshganta) is a second open PR for #65 (read from both diffs, not run).

  • #1032 at b38a3c9: caps oversized sampler heaps at D3D12's 2,048 and logs that the higher slots are unavailable. Tables that reach past them get no slots. It touches descriptor/host.rs only and needs a rebase.
  • This PR at cb36a9a: the same cap, plus 256 dynamic sampler slots (SAMPLER_DYNAMIC), so tables past the kept title slots are made afresh. It also has the corrected test, which fails with the cap removed.

So this one covers #1032 and goes further. If this lands, #1032 can be closed.

AI-assisted (Claude Code, Claude Opus 5.5 read both diffs).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234271556 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2451#issuecomment-7234271556). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T04:48:28Z. --- For whoever picks: #1032 (divyeshganta) is a second open PR for #65 (read from both diffs, not run). - **#1032 at `b38a3c9`:** caps oversized sampler heaps at D3D12's 2,048 and logs that the higher slots are unavailable. Tables that reach past them get no slots. It touches `descriptor/host.rs` only and needs a rebase. - **This PR at `cb36a9a`:** the same cap, plus 256 dynamic sampler slots (`SAMPLER_DYNAMIC`), so tables past the kept title slots are made afresh. It also has the corrected test, which fails with the cap removed. So this one covers #1032 and goes further. If this lands, #1032 can be closed. AI-assisted (Claude Code, Claude Opus 5.5 read both diffs).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2449
No description provided.