GPU: a sampler heap over 2,048 loses the host heap entirely #65

Open
opened 2026-11-26 03:48:55 +00:00 by github-bot · 5 comments
Owner

@⁠WallasSCRIPTS on GitHub · 2026-11-24 00:04 UTC · original

A sampler heap larger than D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE
(2,048) makes HostHeap::new return None. The heap is lost outright
instead of being capped like a view heap.

Where

crates/victory-gpu/src/descriptor/host.rs, HostHeap::new:

  • make(count + extra) with sampler = true and count > 2,048 fails at
    CreateDescriptorHeap (2,048 is the sampler limit on every binding tier).
  • The fallback arm is guarded by !sampler, so a sampler heap goes to the
    generic Err(e) => { warn; return None; } path.
  • Descriptor::host() caches that None forever with get_or_init.
  • draw::State::bind builds SetDescriptorHeaps with filter_map(...host()),
    so a heap without a host is dropped from the list. That also shifts the
    heap indices the translated root signature expects, not just the missing
    sampler heap.

View heaps behave differently: they cap at PORTABLE_VIEWS (1,000,000) and
keep the title's first PORTABLE_VIEWS - DYNAMIC slots; #21 remaps root
tables that reach past that cap.

Fixing it

Sampler chunks plus a copy path for a table crossing a chunk boundary would
be the complete fix; sampler tables cross more often because the chunks are
small. At minimum the failure should be reported clearly instead of
silently dropping the heap.

Found in static review while discussing #35. I have not seen a title ask
for more than 2,048 samplers; a log line with the title's sampler heap size
would confirm whether this path is live.

**@⁠WallasSCRIPTS** on GitHub · 2026-11-24 00:04 UTC · [original](https://github.com/Marvisak/VIctory/issues/65) A sampler heap larger than `D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE` (2,048) makes `HostHeap::new` return `None`. The heap is lost outright instead of being capped like a view heap. ## Where `crates/victory-gpu/src/descriptor/host.rs`, `HostHeap::new`: - `make(count + extra)` with `sampler = true` and `count > 2,048` fails at `CreateDescriptorHeap` (2,048 is the sampler limit on every binding tier). - The fallback arm is guarded by `!sampler`, so a sampler heap goes to the generic `Err(e) => { warn; return None; }` path. - `Descriptor::host()` caches that `None` forever with `get_or_init`. - `draw::State::bind` builds `SetDescriptorHeaps` with `filter_map(...host())`, so a heap without a host is dropped from the list. That also shifts the heap indices the translated root signature expects, not just the missing sampler heap. View heaps behave differently: they cap at `PORTABLE_VIEWS` (1,000,000) and keep the title's first `PORTABLE_VIEWS - DYNAMIC` slots; #21 remaps root tables that reach past that cap. ## Fixing it Sampler chunks plus a copy path for a table crossing a chunk boundary would be the complete fix; sampler tables cross more often because the chunks are small. At minimum the failure should be reported clearly instead of silently dropping the heap. Found in static review while discussing #35. I have not seen a title ask for more than 2,048 samplers; a log line with the title's sampler heap size would confirm whether this path is live.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:55 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:12 UTC · original

Checked this against main 97c78d1 by code reading (no D3D12 here, so no GPU repro). The report matches the code:

  • HostHeap::new sets extra = if sampler { 0 } else { DYNAMIC } and the cap arm is Err(e) if !sampler && count + extra > PORTABLE_VIEWS, so a sampler heap above 2,048 falls through to the generic Err → None (crates/victory-gpu/src/descriptor/host.rs:68-100).
  • Descriptor::host caches that None with get_or_init (crates/victory-gpu/src/descriptor.rs:79-92).
  • draw.rs:410 builds SetDescriptorHeaps with filter_map(...host()), so the heap also disappears from the list and the indices shift.

A smaller intermediate step than chunking, if you want the heap to survive meanwhile: mirror the view path — on failure with sampler && count > 2048, make(2048) and keep the title's first 2,048 slots, recording count = 2048 so GPU_RANGES and cpu(index) stay consistent. It still needs the #21-style remap once a root table reaches a slot past the cap, but it stops the whole heap (and the root heap indices) from vanishing for titles that only touch the low slots.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:12 UTC · [original](https://github.com/Marvisak/VIctory/issues/65#issuecomment-7117812633) Checked this against `main` `97c78d1` by code reading (no D3D12 here, so no GPU repro). The report matches the code: - `HostHeap::new` sets `extra = if sampler { 0 } else { DYNAMIC }` and the cap arm is `Err(e) if !sampler && count + extra > PORTABLE_VIEWS`, so a sampler heap above 2,048 falls through to the generic `Err` → `None` (`crates/victory-gpu/src/descriptor/host.rs:68-100`). - `Descriptor::host` caches that `None` with `get_or_init` (`crates/victory-gpu/src/descriptor.rs:79-92`). - `draw.rs:410` builds `SetDescriptorHeaps` with `filter_map(...host())`, so the heap also disappears from the list and the indices shift. A smaller intermediate step than chunking, if you want the heap to survive meanwhile: mirror the view path — on failure with `sampler && count > 2048`, `make(2048)` and keep the title's first 2,048 slots, recording `count = 2048` so `GPU_RANGES` and `cpu(index)` stay consistent. It still needs the #21-style remap once a root table reaches a slot past the cap, but it stops the whole heap (and the root heap indices) from vanishing for titles that only touch the low slots. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠WallasSCRIPTS on GitHub · 2026-11-24 00:17 UTC · original

Update from #74: a sampler heap the host refuses is now capped at
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE (2,048) instead of returning
None. That keeps the first 2,048 samplers and, importantly, keeps the heap
in SetDescriptorHeaps: draw::State::bind used to drop a hostless heap with
filter_map, shifting the heap indices the translated root signature expects.

The other half is still open here. HostHeap::dynamic is view-only, so
State::tables cannot remake a sampler table with an entry past 2,048; those
tables are not made at all. A complete fix needs sampler chunks plus a copy
path for a table crossing a chunk boundary. Sampler tables cross more often
because the chunks are small.

One correction to the original report: this is driver-dependent. The RX 7600
here accepts a 2,049-slot sampler heap, so the refusal is not universal —
the test in #74 forces it with u32::MAX so the path is exercised on any
host.

**@⁠WallasSCRIPTS** on GitHub · 2026-11-24 00:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/65#issuecomment-7117910979) Update from #74: a sampler heap the host refuses is now capped at `D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE` (2,048) instead of returning `None`. That keeps the first 2,048 samplers and, importantly, keeps the heap in `SetDescriptorHeaps`: `draw::State::bind` used to drop a hostless heap with `filter_map`, shifting the heap indices the translated root signature expects. The other half is still open here. `HostHeap::dynamic` is view-only, so `State::tables` cannot remake a sampler table with an entry past 2,048; those tables are not made at all. A complete fix needs sampler chunks plus a copy path for a table crossing a chunk boundary. Sampler tables cross more often because the chunks are small. One correction to the original report: this is driver-dependent. The RX 7600 here accepts a 2,049-slot sampler heap, so the refusal is not universal — the test in #74 forces it with `u32::MAX` so the path is exercised on any host.
Author
Owner

@⁠WallasSCRIPTS on GitHub · 2026-11-24 00:23 UTC · original

Follow-up to my earlier comment: the second half is now in #74 too. A capped
sampler heap reserves 256 scratch slots, and HostHeap::dynamic/release
use them like a view heap's. State::tables already remakes a table whose
entries reach 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 title slots.

What remains is only the complete chunked design if a title needs more than
2,048 samplers simultaneously — this gives it the first 1,792 plus a 256-slot
scratch area, not more addressable samplers. #65 can stay open for that, or
be closed if the cap is enough in practice; I cannot tell without a log of
the title's sampler heap size and usage.

cargo test -p victory-gpu: 41 passed; clippy clean.

**@⁠WallasSCRIPTS** on GitHub · 2026-11-24 00:23 UTC · [original](https://github.com/Marvisak/VIctory/issues/65#issuecomment-7118014042) Follow-up to my earlier comment: the second half is now in #74 too. A capped sampler heap reserves 256 scratch slots, and `HostHeap::dynamic`/`release` use them like a view heap's. `State::tables` already remakes a table whose entries reach 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 title slots. What remains is only the complete chunked design if a title needs more than 2,048 samplers simultaneously — this gives it the first 1,792 plus a 256-slot scratch area, not more addressable samplers. #65 can stay open for that, or be closed if the cap is enough in practice; I cannot tell without a log of the title's sampler heap size and usage. `cargo test -p victory-gpu`: 41 passed; clippy clean.
Author
Owner

@⁠WallasSCRIPTS on GitHub · 2026-11-24 00:25 UTC · original

Correction: #74 is closed in favour of #86, which covers the same fix with
a cleaner design — it caps at the spec limit up front rather than only when
the host refuses the larger heap, so behaviour does not depend on the
driver. #86 also gives the capped sampler heap 256 scratch slots for
State::tables, which is the second half of this issue. Please follow #86
instead of my earlier comments.

**@⁠WallasSCRIPTS** on GitHub · 2026-11-24 00:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/65#issuecomment-7118058587) Correction: #74 is closed in favour of #86, which covers the same fix with a cleaner design — it caps at the spec limit up front rather than only when the host refuses the larger heap, so behaviour does not depend on the driver. #86 also gives the capped sampler heap 256 scratch slots for `State::tables`, which is the second half of this issue. Please follow #86 instead of my earlier comments.
Author
Owner

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

Automated triage for the maintainers.

Confirmed on current main. In crates/victory-gpu/src/descriptor/host.rs, HostHeap::new makes a sampler heap with count.max(HEAP_SAMPLERS) slots and has no capped fallback: if the host refuses the size, it logs no host descriptor heap and returns None (the view path caps instead). The heap is then left out of SetDescriptorHeaps in draw::State::bind_heaps (crates/victory-gpu/src/draw.rs, filter_map over host()), so draws run with no sampler heap bound. As noted in the comments, whether the host refuses 2,049+ samplers depends on the driver.

The pull requests linked to this issue (#86, #100) are closed without being merged, and no open pull request found carries the cap. A log line with the title's sampler heap size would show whether this path is reached in practice.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:48 UTC · [original](https://github.com/Marvisak/VIctory/issues/65#issuecomment-7149982643) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T00:25:46Z at=2026-11-25T01:48:40Z --> Automated triage for the maintainers. Confirmed on current `main`. In `crates/victory-gpu/src/descriptor/host.rs`, `HostHeap::new` makes a sampler heap with `count.max(HEAP_SAMPLERS)` slots and has no capped fallback: if the host refuses the size, it logs `no host descriptor heap` and returns `None` (the view path caps instead). The heap is then left out of `SetDescriptorHeaps` in `draw::State::bind_heaps` (`crates/victory-gpu/src/draw.rs`, `filter_map` over `host()`), so draws run with no sampler heap bound. As noted in the comments, whether the host refuses 2,049+ samplers depends on the driver. The pull requests linked to this issue (#86, #100) are closed without being merged, and no open pull request found carries the cap. A log line with the title's sampler heap size would show whether this path is reached in practice. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#65
No description provided.