GPU: back host sampler heaps with 2,048 slots and reserve slot 2,047 as null sentinel #121

Manually merged
github merged 1 commit from github-bot/gh-121 into main 2026-11-26 08:21:46 +00:00 AGit
Owner

@⁠ESAT586 on GitHub · 2026-11-26 04:44 UTC · original
ESAT586:avatarmanz/sampler-heap-sentinel → main · +30 −2 · 1 files · 1 commits · merged 2026-11-26 08:17 UTC

### Problem
victory-shader (emit/shader.rs:498) clamps all direct sampler heap indices via umin(index, 2047) with the explicit shortcut comment:

// shortcut: not the bound heap's own count, which a title heap smaller than 2,048 would need.

However, HostHeap::new(true, count) in crates/victory-gpu/src/descriptor/host.rs allocated only count sampler descriptors (leaving null = 0). When a title creates a sampler heap smaller than 2,048 descriptors, a wild sampler index clamped to 2047 reads past the end of SamplerDescriptorHeap (GPU page fault); and when count == 2048, title mirroring could overwrite slot 2047 instead of keeping it as a null point sampler.

Change

  • Always back host shader-visible sampler heaps with SAMPLERS = 2048 descriptors (~32 KiB each) and cap mirrored title slots to count.min(SAMPLERS - 1) (2047).
  • fill_null(kind, size) already initializes every slot in 0..2048 with a valid null point sampler, so slot 2047 (and all slots count..2048) are permanently safe null sentinels.
  • Added unit test sampler_heaps_back_2048_slots_and_reserve_null_sentinel.

Verification

  • cargo test -p victory-gpu --locked -- descriptor::host::tests::sampler_heaps_back_2048_slots_and_reserve_null_sentinel --test-threads=1 on NVIDIA GeForce RTX 3060 Ti 8 GB: 1 passed, 0 failed.
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- descriptor::host::tests::sampler_heaps_back_2048_slots_and_reserve_null_sentinel --test-threads=1: 1 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in descriptor/host.rs.
  • cargo xtask policy --staged: asset policy: 1 files ok.
**@⁠ESAT586** on GitHub · 2026-11-26 04:44 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/121) `ESAT586:avatarmanz/sampler-heap-sentinel` → `main` · +30 −2 · 1 files · 1 commits · merged 2026-11-26 08:17 UTC ### Problem `victory-shader` (`emit/shader.rs:498`) clamps all direct sampler heap indices via `umin(index, 2047)` with the explicit shortcut comment: > `// shortcut: not the bound heap's own count, which a title heap smaller than 2,048 would need.` However, `HostHeap::new(true, count)` in `crates/victory-gpu/src/descriptor/host.rs` allocated only `count` sampler descriptors (leaving `null = 0`). When a title creates a sampler heap smaller than 2,048 descriptors, a wild sampler index clamped to `2047` reads past the end of `SamplerDescriptorHeap` (GPU page fault); and when `count == 2048`, title mirroring could overwrite slot `2047` instead of keeping it as a null point sampler. ### Change - Always back host shader-visible sampler heaps with `SAMPLERS = 2048` descriptors (~32 KiB each) and cap mirrored title slots to `count.min(SAMPLERS - 1)` (`2047`). - `fill_null(kind, size)` already initializes every slot in `0..2048` with a valid null point sampler, so slot `2047` (and all slots `count..2048`) are permanently safe null sentinels. - Added unit test `sampler_heaps_back_2048_slots_and_reserve_null_sentinel`. ### Verification - `cargo test -p victory-gpu --locked -- descriptor::host::tests::sampler_heaps_back_2048_slots_and_reserve_null_sentinel --test-threads=1` on **NVIDIA GeForce RTX 3060 Ti 8 GB**: **1 passed, 0 failed**. - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- descriptor::host::tests::sampler_heaps_back_2048_slots_and_reserve_null_sentinel --test-threads=1`: **1 passed, 0 failed**. - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: **0 warnings** in `descriptor/host.rs`. - `cargo xtask policy --staged`: **`asset policy: 1 files ok`**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:24:53 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:55 UTC · original

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/121#issuecomment-7185992019) Merged into main in the next push (tests pass); thanks.
github manually merged commit 932929089b into main 2026-11-26 08:21:46 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.