GPU: cap a refused sampler heap and remap its past-cap tables #74

Closed
WallasSCRIPTS wants to merge 2 commits from upstream-pr/74 into main
WallasSCRIPTS commented 2026-11-24 00:14:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:14:00Z.


Relates to #65.

What

A sampler heap larger than D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE
(2,048) that the host refused made HostHeap::new return None. The generic
error arm had no fallback, unlike view heaps which cap at 1,000,000.

Losing the heap is worse than losing the slots: draw::State::bind builds
SetDescriptorHeaps with filter_map(...host()), so a heap without a host
is dropped and the heap indices the translated root signature expects shift.

This PR:

  1. Retries a refused sampler heap at 2,048 slots, logging what the title
    asked for, what the host made, and what was lost. The heap stays bound.
  2. Reserves 256 scratch slots only in a capped sampler heap, and lets
    HostHeap::dynamic/release use them. State::tables already remakes a
    table with an entry past host.count(), so sampler tables past the cap
    now take that path instead of being skipped. An uncapped sampler heap
    keeps all 2,048 slots for the title.

count.saturating_add(extra) keeps a title asking for u32::MAX on the cap
path rather than overflowing in a debug build.

Driver note

Some drivers accept a 2,049-slot sampler heap — the RX 7600 here does. The
test forces the refusal with u32::MAX so the path is exercised on any host.

Verification

  • cargo test -p victory-gpu: 41 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets: clean.
  • Changed hunks are rustfmt --edition 2024 clean. The file has
    pre-existing formatting drift elsewhere, untouched here.
  • Allocation and scratch-slot behaviour are tested on a real D3D12 device;
    no title was run.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6571604368 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/74). Originally posted by [WallasSCRIPTS](https://github.com/WallasSCRIPTS) on 2026-11-24T00:14:00Z. --- Relates to #65. ## What A sampler heap larger than `D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE` (2,048) that the host refused made `HostHeap::new` return `None`. The generic error arm had no fallback, unlike view heaps which cap at 1,000,000. Losing the heap is worse than losing the slots: `draw::State::bind` builds `SetDescriptorHeaps` with `filter_map(...host())`, so a heap without a host is dropped and the heap indices the translated root signature expects shift. This PR: 1. Retries a refused sampler heap at 2,048 slots, logging what the title asked for, what the host made, and what was lost. The heap stays bound. 2. Reserves 256 scratch slots **only in a capped sampler heap**, and lets `HostHeap::dynamic`/`release` use them. `State::tables` already remakes a table with an entry past `host.count()`, so sampler tables past the cap now take that path instead of being skipped. An uncapped sampler heap keeps all 2,048 slots for the title. `count.saturating_add(extra)` keeps a title asking for `u32::MAX` on the cap path rather than overflowing in a debug build. ## Driver note Some drivers accept a 2,049-slot sampler heap — the RX 7600 here does. The test forces the refusal with `u32::MAX` so the path is exercised on any host. ## Verification - `cargo test -p victory-gpu`: 41 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets`: clean. - Changed hunks are `rustfmt --edition 2024` clean. The file has pre-existing formatting drift elsewhere, untouched here. - Allocation and scratch-slot behaviour are tested on a real D3D12 device; no title was run.
upstream-sync closed this pull request 2026-11-24 06:51:11 +00:00
WallasSCRIPTS commented 2026-11-24 06:54:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:25:05Z.


Closing in favour of #86, which is the better design and covers the same
ground. #74 only capped when the host refused an over-limit sampler heap;
the RX 7600 here accepts one, so behaviour depended on the driver. #86 caps
at the spec limit up front and gives the capped heap its 256 scratch slots,
so State::tables remaps past-cap sampler tables on every host. It also
fixes the null-sampler fallback and reports an oversized table instead of
dropping it. One PR for #65 is enough.

One suggestion if it helps: the cap warning currently logs only count.
Reporting wanted, made and lost like the view-heap warning in #35
makes a tester's log self-explanatory without a second diagnostic run.

Verified on my branch before closing: cargo test -p victory-gpu 41 passed,
clippy clean. No title run.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118046705 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/74#issuecomment-7118046705). Originally posted by [WallasSCRIPTS](https://github.com/WallasSCRIPTS) on 2026-11-24T00:25:05Z. --- Closing in favour of #86, which is the better design and covers the same ground. #74 only capped when the host *refused* an over-limit sampler heap; the RX 7600 here accepts one, so behaviour depended on the driver. #86 caps at the spec limit up front and gives the capped heap its 256 scratch slots, so `State::tables` remaps past-cap sampler tables on every host. It also fixes the null-sampler fallback and reports an oversized table instead of dropping it. One PR for #65 is enough. One suggestion if it helps: the cap warning currently logs only `count`. Reporting `wanted`, `made` and `lost` like the view-heap warning in #35 makes a tester's log self-explanatory without a second diagnostic run. Verified on my branch before closing: `cargo test -p victory-gpu` 41 passed, clippy clean. No title run.

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!74
No description provided.