Shaders: bind a zero dword for empty root-constant slices #2473
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2473"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fuzeofficlal on 2026-11-29T13:22:09Z.
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). 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][..]in bothHost::draw(SetGraphicsRoot32BitConstants) andHost::dispatch(SetComputeRoot32BitConstants), keeping every declared root parameter defined with a valid pointer.crates/victory-shader/src/emit/host.rs: addemit::host::tests::empty_root_constants_bind_zero_in_draw_and_dispatchverifying bothHost::dispatchandHost::drawwith emptyRoot::Constants(Vec::new())on NVIDIA hardware and WARP.Verification
cargo test --locked -p victory-shader --lib emit::host::— pass on RTX 5090 (VICTORY_ADAPTER=NVIDIA) and WARP.cargo clippy --locked -p victory-shader --all-targets— 0 new warnings in touched files.cargo run --quiet --locked -p xtask -- policy --staged— pass.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-29T13:23:28Z.
Review: APPROVED
Tested locally merged onto
main(829188e9).crates/victory-shader/src/emit/host.rs.cargo test -p victory-shader --lib emit::host::passed.cargo test -p victory-shader --lib emit::tests::passed (26 passed; 0 failed; 1 ignored).cargo test -p victory-shader --lib emit::lower::tests::passed (25 passed; 0 failed; 1 ignored).Clean fix binding a zero dword for empty root-constant slices in the shader host test runner. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).