Repository navigation
fix: clamp shader heap indices to the host's view-heap cap (NVIDIA) - #2185
thedanmaor wants to merge 11 commits into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
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 onmain940d32f)cargo clippy -p victory-gpu -p victory-shader --all-targets— 0 warningscargo 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).
|
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 Verified in the code:
Tests on NVIDIA: the 3 |
Offline measurement on a retail dumpResult: no count change against I merged head 4d91d9d onto 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
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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.
|
Update (8d5eaaa): the heap cap from 4d91d9d never took effect. 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 🤖 Generated with Claude Code |
GTX 1660 Super (6 GB): what is left after the heap capThe heap cap fixes the MMU fault. The title now runs about 10 s on hardware, then the device is removed with Cause: local VRAM overcommit. I polled
Fix options (not in this PR):
Other findings
🤖 Generated with Claude Code |
|
Automated triage for the maintainers. This pull request conflicts with Generated by Claude Code |
|
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 On main, 5 tests fail on this card:
What this shows:
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. |
|
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
|
| 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.
|
Follow-up to the error-code question above: I reran the direct So on this card the code is AI-assisted; synthetic probe only. |
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 <noreply@anthropic.com>
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
…op below HEAP_VIEWS 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
…oval) 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
… hang) 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr
009277b to
3417025
Compare
|
Rebased onto main 13f91ca (head 3417025). Conflicts in Review points:
🤖 Generated with Claude Code |
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 heapwarnings), and translated shaders clamp only belowHEAP_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::createprobes aHEAP_VIEWSshader-visible heap. Where it is refused,emit::set_heap_views(PORTABLE_VIEWS)sets the clamp to the cap.heap_handleandbuffer_guardclamp belowemit::heap_views(), and the null buffer views move toemit::null_buffer_view()(the cap's last slots).descriptor::host: on a capped host, the heap isviewsslots. Title slots come first, thenMIN_DYNAMICdynamic 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_shadercreates the host device first, so the probe runs before any translation. As a resultvictory translate(including--cachewarming) now creates a D3D12 device (GPU or WARP) before it translates; it did not need one before.Hosts that take a 2^21 heap (AMD) are unchanged.
Later commits on this branch
f607780aa8e502d0. The strides, marks and view-address tables now shareindexed_slots(). Heap-direct title indices past the kept slots go to the null last slot (title_guard).heap_viewsslots unless the title fits under it, and the uncapped fallback keeps room for the dynamic and null slots.docs/gpu-hang-investigation.mdrecords the cause and the eight leads ruled out.Checks
victory-gpuandvictory-shader.victory-gpulib tests: 145 pass, including the newper_slot_tables_cover_every_index_a_shader_reads.victory-shaderlib tests: 248 pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01YN3qACnpWeybNLkKL5h5jr