Repository navigation
Shaders: bind a zero dword for empty root-constant slices - #2587
fuzeofficlal wants to merge 1 commit into
Conversation
|
#2596 addresses the same crash in #2571 by writing one zero. Could we keep this PR’s synthetic draw/dispatch coverage and use the one-zero binding from #2596? That would preserve the regression test and populate the declared slot. Static review only. I didn’t run either patch. AI-assisted with Codex. |
fyernald
left a comment
There was a problem hiding this comment.
This fixes the crash here too: RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1 + #486. main dies with 0xc0000005 after 65 tests; with this PR it's 268 passed, 3 failed (the #1835 ones), and the new test passes.
One problem with skipping the call, though. The root signature declares at least one constant whatever the shader uses: Num32BitValues: s.user_data_dwords().max(1) at host.rs:162. If Set*Root32BitConstants isn't called, that declared parameter is never set in the list, and root arguments are undefined until they are set. It doesn't matter for this shader, which reads no user data, but the harness then dispatches with an unset root parameter that the signature declares. #2596 fixes the same crash by setting that one constant to 0, which keeps every declared parameter defined.
Could this set [0] for an empty list instead of skipping, or be closed in favour of #2596? The new empty_root_constants_are_skipped_in_draw_and_dispatch test is worth keeping either way, renamed to match.
8ceeb01 to
df8ee8e
Compare
|
Thanks @fyernald and @DrDarkDK — good catch on the declared Updated ( Re-verified on RTX 5090 + WARP ( |
|
Verification of
Overlap with #2596 (same issue, #2571): the two PRs now make the same code change, setting Independent verification by Claude Code (Claude Sonnet 5.5), an AI assistant, run for oni-swr. No game files, dumps, or shader names were used. |
fyernald
left a comment
There was a problem hiding this comment.
Thanks for the change. Retested df8ee8e on the same RTX 3080 (617.42), Windows 10 (19045), main 67e8ae1 + #486 (without #2596): main still crashes after 65 tests (0xc0000005). With this head, cargo test -p victory-shader --lib --locked -- --test-threads=1 gives 268 passed, 3 failed (the #1835 ones). Every declared constant is now defined.
It now does the same thing as #2596, so only one of the two needs to land. This one adds the dedicated test.
|
RTX 4060 test (AI-assisted)
|
|
Tested on NVIDIA Ada: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged onto main Plain main With this PR:
#2596 fixes the crash on this card as well. This PR also covers the draw path and adds a regression test. AI-assisted (Claude). |
|
Automated triage for the maintainers. Verdict: merge candidate. Re-reviewed at CI: passing. Recommending a look, not approving. Generated by Claude Code |
root_signature_for declares user_data_dwords().max(1) root constants even when a shader reads no user data. Passing Vec::new().as_ptr() (0x4) with count 0 to SetComputeRoot32BitConstants or SetGraphicsRoot32BitConstants causes NVIDIA's D3D12 driver to dereference 0x4 (STATUS_ACCESS_VIOLATION), while skipping the call leaves the declared slot unset. Bind &[0u32] when the slice is empty and test both Host::dispatch and Host::draw on hardware and WARP.
df8ee8e to
8aae7ab
Compare
|
Measured against the other #2571 PRs on an RTX 4060 (where |
|
Confirmed on an RTX 3060 (Ampere, driver 610.88, Windows 11 26200). On AI use: Claude Code ran the tests on this machine and drafted this comment. |
Summary
Host::root_signature_forincrates/victory-shader/src/emit/host.rsalways declaresNum32BitValues: s.user_data_dwords().max(1)for each shader stage, even when a shader reads zero user-data dwords.When a test passes an empty
Root::Constants(Vec::new()),Vec::new().as_ptr()is a dangling aligned pointer (0x4). Passing0x4with count0toSetComputeRoot32BitConstants/SetGraphicsRoot32BitConstantscrashes NVIDIA's D3D12 driver (nvwgf2umx.dll) withSTATUS_ACCESS_VIOLATION (0xc0000005)(reproducing onemit::memory_tests::heap_direct_texture_reads_mark_their_heap_index). Skipping the call avoids the crash, but leaves the declared 1-dword root parameter unbound.Changes
crates/victory-shader/src/emit/host.rs: whenRoot::Constants(data)is empty, bind&[0u32](let words = if data.is_empty() { &[0u32][..] } else { data.as_slice() };) in bothHost::draw(SetGraphicsRoot32BitConstants) andHost::dispatch(SetComputeRoot32BitConstants), keeping every declared root parameter defined with a valid pointer.crates/victory-shader/src/emit/synthetic_tests.rs: addempty_root_constants_bind_zero_in_draw_and_dispatchverifying bothHost::dispatchandHost::drawwith emptyRoot::Constants(Vec::new())on hardware and WARP.Verification
cargo test -p victory-shader --lib emit::synthetic_tests::empty_root_constants_bind_zero_in_draw_and_dispatch -- --exact— pass on RTX 5090 and WARP.cargo test -p victory-shader --lib emit::memory_tests— 4/4 pass on RTX 5090 (previously crashed with0xc0000005).cargo clippy -p victory-shader --all-targets -- -D warnings— pass (0 warnings).cargo xtask policy— pass (184 files ok).