fix: clamp shader heap indices to the host's view-heap cap (NVIDIA) #2183

Open
thedanmaor wants to merge 11 commits from upstream-pr/2185 into main
thedanmaor commented 2026-11-25 07:18:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by thedanmaor on 2026-11-25T07:18:34Z.


Problem

NVIDIA caps shader-visible CBV/SRV/UAV heaps at 10^6 slots. The world uses title slots past that (1,236,191 and up; title slot past the host heap warnings), and translated shaders clamp only below HEAP_VIEWS (2^21), so on NVIDIA the run ends with device removed (DXGI_ERROR_INVALID_CALL). Removing the pre-built pipeline library did not change that.

Change

  • host::create probes a HEAP_VIEWS shader-visible heap. Where it is refused, emit::set_heap_views(PORTABLE_VIEWS) sets the clamp to the cap.
  • heap_handle and buffer_guard clamp below emit::heap_views(), and the null buffer views move to emit::null_buffer_view() (the cap's last slots).
  • descriptor::host: on a capped host, the heap is views slots. Title slots come first, then MIN_DYNAMIC dynamic slots, then the null views. Title slots past that read as null (a shortcut: drawing may be missing or wrong).
  • heap_views() keys the shader cache and the pipeline-library tag, so AMD and NVIDIA translations never mix. host_shader creates the host device first, so the probe runs before any translation. As a result victory translate (including --cache warming) now creates a D3D12 device (GPU or WARP) before it translates; it did not need one before.
  • README: a note about NVIDIA.

Hosts that take a 2^21 heap (AMD) are unchanged.

Later commits on this branch

  • Structured buffer views are raw on the host (16580cd), and texture UAVs in formats the host cannot store are refused (a81ee21). Both were NVIDIA removals.
  • DEVICE_HUNG fix (b66fb0f). The per-slot view-addresses table held only a capped heap's kept title slots (934461). Shaders read it through an unbounded root SRV at indices up to 999999, so reads went up to ~524 KB past the buffer and hung the BVH traversal f607780aa8e502d0. The strides, marks and view-address tables now share indexed_slots(). Heap-direct title indices past the kept slots go to the null last slot (title_guard).
  • Review fixes: a capped host keeps a heap of exactly heap_views slots unless the title fits under it, and the uncapped fallback keeps room for the dynamic and null slots.
  • docs/gpu-hang-investigation.md records the cause and the eight leads ruled out.

Checks

  • Clippy is clean on victory-gpu and victory-shader.
  • victory-gpu lib tests: 145 pass, including the new per_slot_tables_cover_every_index_a_shader_reads.
  • victory-shader lib tests: 248 pass.
  • Live world run on a GTX 1660 Super, diag build with DRED: no device removal in any run after the fix (Series X to frames 1699 and 1797, Series S to 1929). Before the fix every run hung between frames 1340 and 1603.
    • Both Series X runs then ended in separate crashes, which are open: title int3s and WER at frame 1699, and an AV inside the NVIDIA driver (nvwgf2umx.dll) on the build after the review fixes at frame 1797. See docs/gpu-hang-investigation.md.
  • Not tested on AMD after the review layout change; the uncapped path is the same as before.
  • Open, not addressed: a clamped texture or UAV handle reads the Texture2D null SRV in the last slot (a type mismatch; no hang seen).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr

<!-- greyfinch-sync:Marvisak/VIctory:issue:6599340381 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185). Originally posted by [thedanmaor](https://github.com/thedanmaor) on 2026-11-25T07:18:34Z. --- ## Problem NVIDIA caps shader-visible CBV/SRV/UAV heaps at 10^6 slots. The world uses title slots past that (1,236,191 and up; `title slot past the host heap` warnings), and translated shaders clamp only below `HEAP_VIEWS` (2^21), so on NVIDIA the run ends with device removed (`DXGI_ERROR_INVALID_CALL`). Removing the pre-built pipeline library did not change that. ## Change - `host::create` probes a `HEAP_VIEWS` shader-visible heap. Where it is refused, `emit::set_heap_views(PORTABLE_VIEWS)` sets the clamp to the cap. - `heap_handle` and `buffer_guard` clamp below `emit::heap_views()`, and the null buffer views move to `emit::null_buffer_view()` (the cap's last slots). - `descriptor::host`: on a capped host, the heap is `views` slots. Title slots come first, then `MIN_DYNAMIC` dynamic slots, then the null views. Title slots past that read as null (a shortcut: drawing may be missing or wrong). - `heap_views()` keys the shader cache and the pipeline-library tag, so AMD and NVIDIA translations never mix. `host_shader` creates the host device first, so the probe runs before any translation. As a result `victory translate` (including `--cache` warming) now creates a D3D12 device (GPU or WARP) before it translates; it did not need one before. - README: a note about NVIDIA. Hosts that take a 2^21 heap (AMD) are unchanged. ## Later commits on this branch - Structured buffer views are raw on the host (16580cd), and texture UAVs in formats the host cannot store are refused (a81ee21). Both were NVIDIA removals. - **DEVICE_HUNG fix (b66fb0f).** The per-slot view-addresses table held only a capped heap's kept title slots (934461). Shaders read it through an unbounded root SRV at indices up to 999999, so reads went up to ~524 KB past the buffer and hung the BVH traversal `f607780aa8e502d0`. The strides, marks and view-address tables now share `indexed_slots()`. Heap-direct title indices past the kept slots go to the null last slot (`title_guard`). - Review fixes: a capped host keeps a heap of exactly `heap_views` slots unless the title fits under it, and the uncapped fallback keeps room for the dynamic and null slots. - `docs/gpu-hang-investigation.md` records the cause and the eight leads ruled out. ## Checks - [x] Clippy is clean on `victory-gpu` and `victory-shader`. - [x] `victory-gpu` lib tests: 145 pass, including the new `per_slot_tables_cover_every_index_a_shader_reads`. - [x] `victory-shader` lib tests: 248 pass. - [x] Live world run on a GTX 1660 Super, diag build with DRED: no device removal in any run after the fix (Series X to frames 1699 and 1797, Series S to 1929). Before the fix every run hung between frames 1340 and 1603. - Both Series X runs then ended in separate crashes, which are open: title int3s and WER at frame 1699, and an AV inside the NVIDIA driver (nvwgf2umx.dll) on the build after the review fixes at frame 1797. See docs/gpu-hang-investigation.md. - [ ] Not tested on AMD after the review layout change; the uncapped path is the same as before. - [ ] Open, not addressed: a clamped texture or UAV handle reads the Texture2D null SRV in the last slot (a type mismatch; no hang seen). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
DenRakEiw commented 2026-11-25 08:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T07:24:30Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 143 passed, 0 failed (2 ignored) on NVIDIA RTX 5090 (resolves both 1M view-heap cap failures on main 940d32f)
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean clamping of shader heap indices to the host's view-heap cap with cache-key inclusion. (Note for triage: overlaps #2177 and #2121 on the NVIDIA 1M view-heap cap.)

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6053417882 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#pullrequestreview-6053417882). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T07:24:30Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — **143 passed, 0 failed** (2 ignored) on NVIDIA RTX 5090 (resolves both 1M view-heap cap failures on `main` `940d32f`) - `cargo clippy -p victory-gpu -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean clamping of shader heap indices to the host's view-heap cap with cache-key inclusion. (Note for triage: overlaps #2177 and #2121 on the NVIDIA 1M view-heap cap.) AI-assisted (Gemini 4 Neon).
kotekompotek commented 2026-11-25 08:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T07:45:25Z.


Reviewed the mechanism end-to-end — it is sound, and complementary to the remapping PRs rather than a duplicate.

Why it stops the removal: on main, translated shaders clamp below HEAP_VIEWS (2M) but NVIDIA's heap is ≤1M, so indices 1M..2M index past the heap and fault the device. Clamping to the probed cap means those indices are never emitted; past-cap title slots read null. #2121/#2189 make those slots actually work (paging/recycling); this makes the device survive until then. Landing this first would get NVIDIA users to menus, with remapping as the follow-up for correct content.

Verified in the code:

  • translate --cache on NVIDIA keys entries under the 1M clamp because host_shader creates the host device (and runs the probe) before translating — ordering is correct, though it does mean victory translate now creates a D3D12 device (WARP or GPU) even when invoked only for cache warming; worth a line in the PR description since translate previously did not need a device.
  • The OnceLock in emit is set-once: any translation that reads heap_views() before host::create probes locks in 2M. host_shader covers the run/cache paths; anything else translating first (e.g. a future call site) would silently disable the fix. A debug_assert or a comment at every heap_views() producer might help future contributors not break the ordering.
  • pairs_end/null views moved below heap_views() correctly; on a capped heap pairs still get room past the dynamic range since the heap is exactly 1M.

Tests on NVIDIA: the 3 victory-shader failures you list are pre-existing environment assumptions, same class as victory-gpu's dynamic_slots_are_held_until_released / lists_share_a_table... / a_texture_written_in_one_format... which also fail on any heap-capped host — worth a separate test PR, not a blocker here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156217016 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7156217016). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T07:45:25Z. --- Reviewed the mechanism end-to-end — it is sound, and complementary to the remapping PRs rather than a duplicate. **Why it stops the removal:** on main, translated shaders clamp below `HEAP_VIEWS` (2M) but NVIDIA's heap is ≤1M, so indices 1M..2M index past the heap and fault the device. Clamping to the probed cap means those indices are never emitted; past-cap title slots read null. #2121/#2189 make those slots actually work (paging/recycling); this makes the device survive until then. Landing this first would get NVIDIA users to menus, with remapping as the follow-up for correct content. **Verified in the code:** - `translate --cache` on NVIDIA keys entries under the 1M clamp because `host_shader` creates the host device (and runs the probe) before translating — ordering is correct, though it does mean `victory translate` now creates a D3D12 device (WARP or GPU) even when invoked only for cache warming; worth a line in the PR description since translate previously did not need a device. - The `OnceLock` in emit is set-once: any translation that reads `heap_views()` before `host::create` probes locks in 2M. `host_shader` covers the run/cache paths; anything else translating first (e.g. a future call site) would silently disable the fix. A debug_assert or a comment at every `heap_views()` producer might help future contributors not break the ordering. - `pairs_end`/null views moved below `heap_views()` correctly; on a capped heap pairs still get room past the dynamic range since the heap is exactly 1M. **Tests on NVIDIA:** the 3 `victory-shader` failures you list are pre-existing environment assumptions, same class as `victory-gpu`'s `dynamic_slots_are_held_until_released` / `lists_share_a_table...` / `a_texture_written_in_one_format...` which also fail on any heap-capped host — worth a separate test PR, not a blocker here.
sinan-cmyk commented 2026-11-25 08:06:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T07:52:05Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 4d91d9d2 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156341537 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7156341537). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T07:52:05Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 4d91d9d2 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
catminou4 commented 2026-11-25 09:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:10:09Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Shader heap indices clamped to the host's view-heap cap — bounds safety for heap indexing; mixed docs+gpu+shader.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053922928 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#pullrequestreview-6053922928). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:10:09Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. Shader heap indices clamped to the host's view-heap cap — bounds safety for heap indexing; mixed docs+gpu+shader.
thedanmaor commented 2026-11-25 13:02:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by thedanmaor on 2026-11-25T12:05:27Z.


Update (8d5eaaa): the heap cap from 4d91d9d never took effect. use_shader_cache hashed heap_views() before the host was created, which locked the OnceLock at 2M, so the 1M heap was never created on the GTX 1660. The host is now created first. Log check: host view heap capped at 1000000 count=1245184 kept=934461.

Result: the MMU fault (nvlddmkm event 13) is gone.

Still open, and separate from this: with the heap in place the title renders far more, and about 10 s in the device is removed with DXGI_ERROR_INVALID_CALL (0x887A0001). DRED breadcrumbs are empty, and turning off depth twins doesn't change it. Diagnosing it needs the D3D12 debug layer (Graphics Tools), which this machine doesn't have.

Pre-existing, not from this PR: 3 victory-shader hardware tests fail on this GPU (stride_tests x2, synthetic gathers). The test host in emit/host.rs still uses the 2M HEAP_VIEWS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161905855 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7161905855). Originally posted by [thedanmaor](https://github.com/thedanmaor) on 2026-11-25T12:05:27Z. --- Update (8d5eaaa): the heap cap from 4d91d9d never took effect. `use_shader_cache` hashed `heap_views()` before the host was created, which locked the OnceLock at 2M, so the 1M heap was never created on the GTX 1660. The host is now created first. Log check: `host view heap capped at 1000000 count=1245184 kept=934461`. Result: the MMU fault (nvlddmkm event 13) is gone. Still open, and separate from this: with the heap in place the title renders far more, and about 10 s in the device is removed with DXGI_ERROR_INVALID_CALL (0x887A0001). DRED breadcrumbs are empty, and turning off depth twins doesn't change it. Diagnosing it needs the D3D12 debug layer (Graphics Tools), which this machine doesn't have. Pre-existing, not from this PR: 3 victory-shader hardware tests fail on this GPU (stride_tests x2, synthetic gathers). The test host in emit/host.rs still uses the 2M `HEAP_VIEWS`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
thedanmaor commented 2026-11-25 13:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by thedanmaor on 2026-11-25T12:30:21Z.


GTX 1660 Super (6 GB): what is left after the heap cap

The heap cap fixes the MMU fault. The title now runs about 10 s on hardware, then the device is removed with DXGI_ERROR_INVALID_CALL (0x887A0001). DRED has no breadcrumbs, and the debug layer is not installed.

Cause: local VRAM overcommit. I polled IDXGIAdapter3::QueryVideoMemoryInfo every 50 ms during a run (--console series-x):

TEMPBUDGET local 4989/4817 MB ...
TEMPBUDGET local 4989/4865 MB nonlocal 1836/48286 MB
host GPU device removed after a submission of 1 lists
  • Usage climbs from 1.8 GB to 5 GB within 10 s. That is above the OS budget, with no eviction.
  • Under WARP the same scene holds about 4.6 GB of host textures: 1527 of them, many 3840x2160.
  • The heap cap is not the cause. On WARP with a hardware-identical cap (forced), the title ran 2.5 min without removal.
  • --console series-s was removed once at 2.5 GB used (sampled every 0.5 s, so a short spike may have been missed). The next run crashed on startup instead, so this is still open.

Fix options (not in this PR):

  • Residency management, via SetResidencyPriority / MakeResident / Evict or D3D12MA-style budgeting.
  • Free released title textures sooner. One log line: "a title texture was released while a list not yet reset names its host copy".
  • Report a clear error when over budget.

Other findings

  • 89 compute pipelines are refused on every run with E_INVALIDARG, on hardware and on WARP (430+), with or without the cap. This predates this PR and leaves most dispatches unrun.
  • Two victory-shader tests fail on NVIDIA only:
    • a_heap_buffer_read_by_element_takes_the_views_stride
    • gathers_at_a_level_match_the_hardware
    • Cause: the emitter reads heap-indexed buffers through raw-buffer handles, but the host heap holds the title's structured views (StructureByteStride > 0, kept as-is by buffer_srv). That handle/descriptor mismatch is undefined behaviour. WARP tolerates it; NVIDIA does not.
    • With the test views switched to raw, both tests pass on the 1660. This is a real runtime bug for titles that read structured buffers by heap index. It needs either raw host views (16-byte aligned starts) or structured handles in the emitter. Out of scope here.
  • a_heap_buffer_read_where_no_buffer_view_is_reads_zeros needs a 2^21-slot heap. NVIDIA caps heaps at 10^6, so the test now skips hardware where the heap is refused (9252c34).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162464225 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7162464225). Originally posted by [thedanmaor](https://github.com/thedanmaor) on 2026-11-25T12:30:21Z. --- ## GTX 1660 Super (6 GB): what is left after the heap cap **The heap cap fixes the MMU fault.** The title now runs about 10 s on hardware, then the device is removed with `DXGI_ERROR_INVALID_CALL` (0x887A0001). DRED has no breadcrumbs, and the debug layer is not installed. **Cause: local VRAM overcommit.** I polled `IDXGIAdapter3::QueryVideoMemoryInfo` every 50 ms during a run (`--console series-x`): ``` TEMPBUDGET local 4989/4817 MB ... TEMPBUDGET local 4989/4865 MB nonlocal 1836/48286 MB host GPU device removed after a submission of 1 lists ``` - Usage climbs from 1.8 GB to 5 GB within 10 s. That is above the OS budget, with no eviction. - Under WARP the same scene holds about 4.6 GB of host textures: 1527 of them, many 3840x2160. - The heap cap is not the cause. On WARP with a hardware-identical cap (forced), the title ran 2.5 min without removal. - `--console series-s` was removed once at 2.5 GB used (sampled every 0.5 s, so a short spike may have been missed). The next run crashed on startup instead, so this is still open. **Fix options (not in this PR):** - Residency management, via `SetResidencyPriority` / `MakeResident` / `Evict` or D3D12MA-style budgeting. - Free released title textures sooner. One log line: "a title texture was released while a list not yet reset names its host copy". - Report a clear error when over budget. ### Other findings - **89 compute pipelines are refused on every run** with `E_INVALIDARG`, on hardware and on WARP (430+), with or without the cap. This predates this PR and leaves most dispatches unrun. - **Two victory-shader tests fail on NVIDIA only:** - `a_heap_buffer_read_by_element_takes_the_views_stride` - `gathers_at_a_level_match_the_hardware` - Cause: the emitter reads heap-indexed buffers through raw-buffer handles, but the host heap holds the title's *structured* views (`StructureByteStride > 0`, kept as-is by `buffer_srv`). That handle/descriptor mismatch is undefined behaviour. WARP tolerates it; NVIDIA does not. - With the test views switched to raw, both tests pass on the 1660. This is a real runtime bug for titles that read structured buffers by heap index. It needs either raw host views (16-byte aligned starts) or structured handles in the emitter. Out of scope here. - **`a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`** needs a 2^21-slot heap. NVIDIA caps heaps at 10^6, so the test now skips hardware where the heap is refused (9252c34). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Marvisak commented 2026-11-25 14:07:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:28:13Z.


Automated triage for the maintainers.

This pull request conflicts with main (conflicting files: crates/victory-gpu/src/descriptor/host.rs). It will be reviewed once it is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163823210 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7163823210). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:28:13Z. --- <!-- victory-triage v1 head=3417025c9448302171a4d90d2c0709053ef47ea6 verdict=needs-rebase at=2026-11-26T00:15:28Z --> Automated triage for the maintainers. This pull request conflicts with `main` (conflicting files: `crates/victory-gpu/src/descriptor/host.rs`). It will be reviewed once it is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
devilbytes commented 2026-11-25 15:04:22 +00:00 (Migrated from github.com)

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


Test report on NVIDIA: which part of this PR fixes which test (for the split the triage asks for)

Tested on: NVIDIA GeForce RTX 5060 8 GB, driver 616.56 (32.0.16.1656); AMD Ryzen 7 9700X; Windows 11 Pro 26300; rustc 1.98.1 (msvc). Base: main 940d32f. Each row is cargo test --workspace --no-fail-fast on that commit, with nothing changed locally.

On main, 5 tests fail on this card:

Commit Contains Workspace dynamic_slots_are_held_until_released lists_share_a_table_and_copies_keep_their_views a_heap_buffer_read_where_no_buffer_view_is_reads_zeros a_heap_buffer_read_by_element_takes_the_views_stride gathers_at_a_level_match_the_hardware
main 940d32f — 696 passed, 5 failed FAIL FAIL FAIL FAIL FAIL
9252c34 heap cap only 699 passed, 2 failed ok ok ok (skipped) FAIL FAIL
16580cd + raw structured views 701 passed, 0 failed ok ok ok (skipped) ok ok
a81ee21 + refused UAV formats 701 passed, 0 failed ok ok ok (skipped) ok ok
739a589 (head) + review fixes, docs 702 passed, 0 failed ok ok ok (skipped) ok ok
#2461 9921b93 heap cap (other PR) 699 passed, 2 failed ok ok ok (skipped) FAIL FAIL

What this shows:

  • The heap cap on its own fixes the two descriptor tests. The null-view test passes only because 9252c34 skips it here (it prints hardware view heaps stop below HEAP_VIEWS; skipped). It does not run on this card. #2461 gives the same result as the heap-cap commits.
  • The raw-view commit (16580cd) is what fixes the other two tests on NVIDIA: a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware. Without it they fail the same way on both 9252c34 and #2461. The stride test reads [101, 104, 107, ...] (stride 3) and then zeros, where [200, 201, 202, ...] is expected:
    panicked at crates\victory-shader\src\emit\stride_tests.rs:295:9: hardware
      left: [101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 0, 0, ...]
     right: [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, ...]
    panicked at crates\victory-shader\src\emit\synthetic_tests.rs:263:13: hardware: lane 0
    
  • The UAV-format commit (a81ee21) changes no test result here, either way.
  • No commit in this PR breaks any other test on this card.

So if the PR is split, the heap-cap part alone leaves two NVIDIA failures, and the raw-view part is the one that fixes them. These are test-suite results only. I did not run the title.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165536973 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7165536973). Originally posted by [devilbytes](https://github.com/devilbytes) on 2026-11-25T14:36:23Z. --- Test report on NVIDIA: which part of this PR fixes which test (for the split the triage asks for) **Tested on:** NVIDIA GeForce RTX 5060 8 GB, driver 616.56 (32.0.16.1656); AMD Ryzen 7 9700X; Windows 11 Pro 26300; rustc 1.98.1 (msvc). Base: main 940d32f. Each row is `cargo test --workspace --no-fail-fast` on that commit, with nothing changed locally. On main, 5 tests fail on this card: | Commit | Contains | Workspace | dynamic_slots_are_held_until_released | lists_share_a_table_and_copies_keep_their_views | a_heap_buffer_read_where_no_buffer_view_is_reads_zeros | a_heap_buffer_read_by_element_takes_the_views_stride | gathers_at_a_level_match_the_hardware | |---|---|---|---|---|---|---|---| | main 940d32f | — | 696 passed, 5 failed | FAIL | FAIL | FAIL | FAIL | FAIL | | 9252c34 | heap cap only | 699 passed, 2 failed | ok | ok | ok (skipped) | FAIL | FAIL | | 16580cd | + raw structured views | 701 passed, 0 failed | ok | ok | ok (skipped) | ok | ok | | a81ee21 | + refused UAV formats | 701 passed, 0 failed | ok | ok | ok (skipped) | ok | ok | | 739a589 (head) | + review fixes, docs | 702 passed, 0 failed | ok | ok | ok (skipped) | ok | ok | | #2461 9921b93 | heap cap (other PR) | 699 passed, 2 failed | ok | ok | ok (skipped) | FAIL | FAIL | **What this shows:** - **The heap cap on its own** fixes the two descriptor tests. The null-view test passes only because 9252c34 skips it here (it prints `hardware view heaps stop below HEAP_VIEWS; skipped`). It does not run on this card. #2461 gives the same result as the heap-cap commits. - **The raw-view commit (16580cd)** is what fixes the other two tests on NVIDIA: `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware`. Without it they fail the same way on both 9252c34 and #2461. The stride test reads `[101, 104, 107, ...]` (stride 3) and then zeros, where `[200, 201, 202, ...]` is expected: ``` panicked at crates\victory-shader\src\emit\stride_tests.rs:295:9: hardware left: [101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 0, 0, ...] right: [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, ...] panicked at crates\victory-shader\src\emit\synthetic_tests.rs:263:13: hardware: lane 0 ``` - **The UAV-format commit (a81ee21)** changes no test result here, either way. - No commit in this PR breaks any other test on this card. So if the PR is split, the heap-cap part alone leaves two NVIDIA failures, and the raw-view part is the one that fixes them. These are test-suite results only. I did not run the title.
xiaotu030202 commented 2026-11-25 16:09:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xiaotu030202 on 2026-11-25T15:35:56Z.


A third data point for the ceiling this PR is built on. I closed #2315 (my own patch for the same mismatch) after the triage there showed it turned a clamp into a refusal; this PR's runtime probe is the shape that works, so the measurement belongs here instead of in a diff.

Direct CreateDescriptorHeap on an RTX 5070 Ti, driver 32.0.16.2140, Windows 11 22631

Shader-visible CBV/SRV/UAV, one heap per size, no debug layer:

view    1000 -> OK
view   10000 -> OK
view   65536 -> OK
view  100000 -> OK
view  262144 -> OK
view  500000 -> OK
view  524288 -> OK
view 1000000 -> OK
view 1048576 -> FAIL 0x8007000E   (E_OUTOFMEMORY)
view 1310720 -> FAIL 0x8007000E
view 2097152 -> FAIL 0x8007000E
sampler   2048 -> OK
sampler   4096 -> FAIL 0x8007025D  (E_INVALIDARG)

1,000,000 is exact and it is a hard wall — 1,000,000 succeeds, 1,048,576 does not, and the failure is E_OUTOFMEMORY rather than E_INVALIDARG. That distinction may matter for how you detect it: @Dathinel's run on an RTX 3050 with the debug layer on got E_INVALIDARG instead, with the layer naming "the limit for shader visible view heaps is 1000000". So the code is not stable across debug-layer state on the same class of hardware — worth treating "the heap did not fit" as any failure from CreateDescriptorHeap, not as one specific HRESULT.

The sampler ceiling is a different number entirely: 2,048 takes, 4,096 does not. If indexed_slots() feeds the sampler path too, that one is not 1,000,000.

The two-sided table, from the closed PR

For the invariant "the bound must not exceed the slots the heap actually got", both directions are violated on main:

head shader clamp bound new(false, 4) new(false, 1_245_184)
main (my machine, RTX 5070 Ti) 2,097,152 65,540 slots —
main (@Dathinel, RTX 3050) 2,097,152 65,540 1,000,000
main (WARP Tier 3, @andrewpozdnakov7-jpg) 2,097,152 2,097,152 2,097,152
#2315 (closed) 524,288 / 1,000,000 851,968 None

The None row is why I closed it: a title declaring 1,236,191 slots (#2185's figure) got no view heap at all where main caps at 1,000,000. A fixed constant cannot satisfy the invariant in both directions because the slot count is a property of the driver and the binding tier — which is the argument for what this PR does.

What I did not test

A shader reading past the cap on any head — same gap @Dathinel reported. My numbers are all CreateDescriptorHeap; I never ran the device-removal case end to end, and that is the consequence that actually matters.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167089772 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7167089772). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T15:35:56Z. --- A third data point for the ceiling this PR is built on. I closed #2315 (my own patch for the same mismatch) after the triage there showed it turned a clamp into a refusal; this PR's runtime probe is the shape that works, so the measurement belongs here instead of in a diff. ## Direct `CreateDescriptorHeap` on an RTX 5070 Ti, driver 32.0.16.2140, Windows 11 22631 Shader-visible CBV/SRV/UAV, one heap per size, no debug layer: ``` view 1000 -> OK view 10000 -> OK view 65536 -> OK view 100000 -> OK view 262144 -> OK view 500000 -> OK view 524288 -> OK view 1000000 -> OK view 1048576 -> FAIL 0x8007000E (E_OUTOFMEMORY) view 1310720 -> FAIL 0x8007000E view 2097152 -> FAIL 0x8007000E sampler 2048 -> OK sampler 4096 -> FAIL 0x8007025D (E_INVALIDARG) ``` **1,000,000 is exact and it is a hard wall** — 1,000,000 succeeds, 1,048,576 does not, and the failure is `E_OUTOFMEMORY` rather than `E_INVALIDARG`. That distinction may matter for how you detect it: @Dathinel's run on an RTX 3050 with the debug layer on got `E_INVALIDARG` instead, with the layer naming "the limit for shader visible view heaps is 1000000". So **the code is not stable across debug-layer state on the same class of hardware** — worth treating "the heap did not fit" as *any* failure from `CreateDescriptorHeap`, not as one specific `HRESULT`. The sampler ceiling is a different number entirely: 2,048 takes, 4,096 does not. If `indexed_slots()` feeds the sampler path too, that one is not 1,000,000. ## The two-sided table, from the closed PR For the invariant "the bound must not exceed the slots the heap actually got", both directions are violated on `main`: | head | shader clamp bound | `new(false, 4)` | `new(false, 1_245_184)` | |---|---|---|---| | `main` (my machine, RTX 5070 Ti) | 2,097,152 | 65,540 slots | — | | `main` (@Dathinel, RTX 3050) | 2,097,152 | 65,540 | 1,000,000 | | `main` (WARP Tier 3, @andrewpozdnakov7-jpg) | 2,097,152 | 2,097,152 | 2,097,152 | | #2315 (closed) | 524,288 / 1,000,000 | 851,968 | **`None`** | The `None` row is why I closed it: a title declaring 1,236,191 slots (#2185's figure) got no view heap at all where `main` caps at 1,000,000. A fixed constant cannot satisfy the invariant in both directions because the slot count is a property of the driver and the binding tier — which is the argument for what this PR does. ## What I did not test **A shader reading past the cap** on any head — same gap @Dathinel reported. My numbers are all `CreateDescriptorHeap`; I never ran the device-removal case end to end, and that is the consequence that actually matters.
Dathinel commented 2026-11-25 17:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T16:53:24Z.


Follow-up to the error-code question above: I reran the direct CreateDescriptorHeap probe on the RTX 3050 Laptop (driver 610.62, Windows 11 26200, binding tier 3) without the debug layer (victory-gpu built without diagnostics; the probe prints that the device has no ID3D12InfoQueue), on main 67e8ae1.

debug_layer_active=false
view  999999 -> OK
view 1000000 -> OK
view 1000001 -> FAIL 0x80070057
view 1048576 -> FAIL 0x80070057
view 1245184 -> FAIL 0x80070057
view 2097152 -> FAIL 0x80070057
sampler 2048 -> OK
sampler 2049 -> OK
sampler 4096 -> FAIL 0x80070057

So on this card the code is E_INVALIDARG with and without the layer; the E_OUTOFMEMORY on the RTX 5070 Ti is a driver or generation difference, not a debug-layer one. The conclusion for the probe stands either way: treat any failure of the large heap as "did not fit" rather than matching one HRESULT. The ceiling itself is the same, exactly 1,000,000.

AI-assisted; synthetic probe only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168685057 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7168685057). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T16:53:24Z. --- Follow-up to the error-code question above: I reran the direct `CreateDescriptorHeap` probe on the RTX 3050 Laptop (driver 610.62, Windows 11 26200, binding tier 3) **without** the debug layer (`victory-gpu` built without `diagnostics`; the probe prints that the device has no `ID3D12InfoQueue`), on `main` `67e8ae1`. ``` debug_layer_active=false view 999999 -> OK view 1000000 -> OK view 1000001 -> FAIL 0x80070057 view 1048576 -> FAIL 0x80070057 view 1245184 -> FAIL 0x80070057 view 2097152 -> FAIL 0x80070057 sampler 2048 -> OK sampler 2049 -> OK sampler 4096 -> FAIL 0x80070057 ``` So on this card the code is `E_INVALIDARG` with and without the layer; the `E_OUTOFMEMORY` on the RTX 5070 Ti is a driver or generation difference, not a debug-layer one. The conclusion for the probe stands either way: treat any failure of the large heap as "did not fit" rather than matching one HRESULT. The ceiling itself is the same, exactly 1,000,000. AI-assisted; synthetic probe only.
thedanmaor commented 2026-11-25 21:03:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by thedanmaor on 2026-11-25T20:25:42Z.


Rebased onto main 13f91ca (head 3417025). Conflicts in descriptor/host.rs, draw.rs, emit/mod.rs and README resolved. Upstream's 16-byte-per-slot view-address table is now sized by indexed_slots() too (indexed_slots(count) * 16). cargo test -p victory-gpu -p victory-shader passes, clippy is clean, xtask policy is ok.

Review points:

  • Any CreateDescriptorHeap failure counts as "did not fit" (@xiaotu030202, @Dathinel). The probe already matched Err(_), not one HRESULT. A comment now says so.
  • Sampler heaps do not use indexed_slots(). Strides and marks are view-heap only (!sampler), and the sampler heap is still count.max(HEAP_SAMPLERS) with HEAP_SAMPLERS = 2048, matching the ceiling you measured.
  • heap_views() ordering (@kotekompotek). There is now a doc note on heap_views() and a comment at the probe: the first read locks the value, so the host must probe before any translation or cache key. A late set_heap_views is still logged as an error. I left out a debug_assert, because tests that translate before creating a host would panic on capped hardware.
  • translate now creates a D3D12 device. This is noted in the PR description.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173656021 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7173656021). Originally posted by [thedanmaor](https://github.com/thedanmaor) on 2026-11-25T20:25:42Z. --- Rebased onto main 13f91ca (head 3417025). Conflicts in `descriptor/host.rs`, `draw.rs`, `emit/mod.rs` and README resolved. Upstream's 16-byte-per-slot view-address table is now sized by `indexed_slots()` too (`indexed_slots(count) * 16`). `cargo test -p victory-gpu -p victory-shader` passes, clippy is clean, `xtask policy` is ok. Review points: - **Any `CreateDescriptorHeap` failure counts as "did not fit"** (@xiaotu030202, @Dathinel). The probe already matched `Err(_)`, not one HRESULT. A comment now says so. - **Sampler heaps** do not use `indexed_slots()`. Strides and marks are view-heap only (`!sampler`), and the sampler heap is still `count.max(HEAP_SAMPLERS)` with `HEAP_SAMPLERS = 2048`, matching the ceiling you measured. - **`heap_views()` ordering** (@kotekompotek). There is now a doc note on `heap_views()` and a comment at the probe: the first read locks the value, so the host must probe before any translation or cache key. A late `set_heap_views` is still logged as an error. I left out a `debug_assert`, because tests that translate before creating a host would panic on capped hardware. - **`translate` now creates a D3D12 device.** This is noted in the PR description. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2185:upstream-pr/2185'
git switch 'upstream-pr/2185'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2185'
git switch 'upstream-pr/2185'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2185'
git switch 'upstream-pr/2185'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2185'
git switch 'main'
git merge --squash 'upstream-pr/2185'
git switch 'main'
git merge --ff-only 'upstream-pr/2185'
git switch 'main'
git merge 'upstream-pr/2185'
git push origin 'main'
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!2183
No description provided.