Repository navigation
fix: clamp shader heap indices to the host's view-heap cap (NVIDIA) - #2185
thedanmaor wants to merge 5 commits into
Conversation
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>
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.
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
|
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 |
…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
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 |
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
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.Hosts that take a 2^21 heap (AMD) are unchanged.
Checks
victory-gpulib tests: 143 pass. The shader-cache key test now covers the heap size.victory-shaderlib tests: 244 pass. 3 fail on an NVIDIA machine (stride_tests×2 need a 2^21 heap;gathers_at_a_level_match_the_hardware). They fail the same way on main.🤖 Generated with Claude Code