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

Open
github-bot wants to merge 11 commits from github-bot/gh-2185 into main AGit
Owner

@⁠thedanmaor on GitHub · 2026-11-25 07:18 UTC · original
DID-Software-Solutions:fix/nvidia-heap-clamp → main · +433 −80 · 12 files · 11 commits · open

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

**@⁠thedanmaor** on GitHub · 2026-11-25 07:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185) `DID-Software-Solutions:fix/nvidia-heap-clamp` → `main` · +433 −80 · 12 files · 11 commits · open ## 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
NVIDIA caps shader-visible CBV/SRV/UAV heaps at 10^6 slots; the world
indexes past that (slot 1,236,191 and up), and with shaders clamping only
below HEAP_VIEWS (2^21) the device was removed (DXGI_ERROR_INVALID_CALL).

The host probes a HEAP_VIEWS heap at device creation; where it is refused,
emit::set_heap_views(PORTABLE_VIEWS) makes translated shaders clamp below
the cap and put the null buffer views at its last slots. The capped host
heap keeps the title slots below the dynamic range; title slots past it
read null. The heap size keys the shader cache and the pipeline library.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
use_shader_cache hashed heap_views() before the host was made, so the
OnceLock locked at HEAP_VIEWS (2M) and the GTX 1660's 1M cap never took:
no shader-visible view heap, and shaders indexed past it (MMU fault,
nvlddmkm event 13). Make the host first; set_heap_views now reports
whether the cap applied, and the host logs if it came too late.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
NVIDIA caps shader-visible view heaps at 10^6 slots; the test host's
View::NullBuffers needs HEAP_VIEWS (2^21), so the hardware run failed
with E_INVALIDARG instead of testing anything. WARP still runs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Translated shaders read every structured buffer through a raw handle at
index * stride + offset. NVIDIA reads a structured view through a raw
handle wrongly. So structured views with a stride that is a multiple of 4
are now made as R32_TYPELESS raw views, with their range scaled to
4-byte words. Their host copy starts on 16 bytes, which is the raw-view
alignment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
The GTX 1660 has no typed UAV support for B5G5R5A1_UNORM (86).
CreateUnorderedAccessView on an 86 texture removed the device with
DXGI_ERROR_INVALID_CALL about 8 s into the title. Only cross-family casts
were checked. Now every unordered view's final format is checked: the
title's format, or the texture's own. If the host cannot store to it, the
slot stays null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
- Reserve the 3 null-buffer-view slots in every view-heap size, so a title
  count just under the NVIDIA cap falls through to the capped heap instead
  of overlapping the null views.
- Clamp structured-as-raw views to the host's 2^27 buffer elements.
- Refuse typed UAVs unless the format also reports UAV_TYPED_STORE.
- Correct the docs: title indices past the kept slots on a capped heap
  read dynamic or null views, not always empty ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
On a capped heap (GTX 1660: 10^6 views, 934461 title slots kept) the
view-addresses table held only the kept title slots. Translated shaders
read it through a root SRV, which has no bounds, at indices clamped
only below heap_views, up to ~524 KB past the buffer. That hung the
BVH traversal f607780aa8e502d0 (DEVICE_HUNG, no page fault) between
frames ~1340 and ~1603 on Series X and Series S.

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). After review: a capped host keeps a heap of exactly
heap_views unless everything fits under it, and the uncapped fallback
keeps room for the dynamic and null slots again.

Verified on GTX 1660 Super: Series X runs to frame 1699 and Series S to
frame 1929 with no removal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
heap_views() locks on first read: the host must probe before any
translation or cache key. The probe treats any CreateDescriptorHeap
failure as capped (NVIDIA returns E_INVALIDARG or E_OUTOFMEMORY by card).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:44 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 07:45 UTC · original

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 07:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7156217016) 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.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 07:52 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 07:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7156341537) ### 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).
Author
Owner

@⁠thedanmaor on GitHub · 2026-11-25 12:05 UTC · original

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

**@⁠thedanmaor** on GitHub · 2026-11-25 12:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7161905855) 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
Author
Owner

@⁠thedanmaor on GitHub · 2026-11-25 12:30 UTC · original

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

**@⁠thedanmaor** on GitHub · 2026-11-25 12:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7162464225) ## 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
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:28 UTC · original · edited 2026-11-26 00:15 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 13:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7163823210) · edited 2026-11-26 00:15 UTC <!-- 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)_
Author
Owner

@⁠devilbytes on GitHub · 2026-11-25 14:36 UTC · original

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.

**@⁠devilbytes** on GitHub · 2026-11-25 14:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7165536973) 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.
Author
Owner

@⁠xiaotu030202 on GitHub · 2026-11-25 15:35 UTC · original

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.

**@⁠xiaotu030202** on GitHub · 2026-11-25 15:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7167089772) 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.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 16:53 UTC · original

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.

**@⁠Dathinel** on GitHub · 2026-11-25 16:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7168685057) 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.
Author
Owner

@⁠thedanmaor on GitHub · 2026-11-25 20:25 UTC · original

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

**@⁠thedanmaor** on GitHub · 2026-11-25 20:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2185#issuecomment-7173656021) 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 has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2185/head:github-bot/gh-2185'
git switch 'github-bot/gh-2185'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2185'
git switch 'github-bot/gh-2185'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2185'
git switch 'github-bot/gh-2185'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2185'
git switch 'main'
git merge --squash 'github-bot/gh-2185'
git switch 'main'
git merge --ff-only 'github-bot/gh-2185'
git switch 'main'
git merge 'github-bot/gh-2185'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!2185
No description provided.