Shaders: bind a zero dword for empty root-constant slices #2473

Merged
fuzeofficlal merged 1 commit from upstream-pr/2473 into main 2026-11-30 14:12:02 +00:00
fuzeofficlal commented 2026-11-29 13:22:09 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fuzeofficlal on 2026-11-29T13:22:09Z.


Summary

Host::root_signature_for in crates/victory-shader/src/emit/host.rs always declares Num32BitValues: 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). Passing 0x4 with count 0 to SetComputeRoot32BitConstants / SetGraphicsRoot32BitConstants crashes NVIDIA's D3D12 driver (nvwgf2umx.dll) with STATUS_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: when Root::Constants(data) is empty, bind &[0u32][..] in both Host::draw (SetGraphicsRoot32BitConstants) and Host::dispatch (SetComputeRoot32BitConstants), keeping every declared root parameter defined with a valid pointer.
  • crates/victory-shader/src/emit/host.rs: add emit::host::tests::empty_root_constants_bind_zero_in_draw_and_dispatch verifying both Host::dispatch and Host::draw with empty Root::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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551122867 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2473). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-29T13:22:09Z. --- ## Summary `Host::root_signature_for` in `crates/victory-shader/src/emit/host.rs` always declares `Num32BitValues: 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`). Passing `0x4` with count `0` to `SetComputeRoot32BitConstants` / `SetGraphicsRoot32BitConstants` crashes NVIDIA's D3D12 driver (`nvwgf2umx.dll`) with `STATUS_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`: when `Root::Constants(data)` is empty, bind `&[0u32][..]` in both `Host::draw` (`SetGraphicsRoot32BitConstants`) and `Host::dispatch` (`SetComputeRoot32BitConstants`), keeping every declared root parameter defined with a valid pointer. - `crates/victory-shader/src/emit/host.rs`: add `emit::host::tests::empty_root_constants_bind_zero_in_draw_and_dispatch` verifying both `Host::dispatch` and `Host::draw` with empty `Root::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.
Dukestar69 commented 2026-11-29 13:23:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-29T13:23:28Z.

Review: APPROVED


Tested locally merged onto main (829188e9).

  • Merge: Clean merge in crates/victory-shader/src/emit/host.rs.
  • Tests (RTX 5090):
    • 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).
  • 0 new warnings.

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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6103059855 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2473#pullrequestreview-6103059855). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-29T13:23:28Z. **Review:** APPROVED --- Tested locally merged onto `main` (`829188e9`). - **Merge**: Clean merge in `crates/victory-shader/src/emit/host.rs`. - **Tests (RTX 5090)**: - `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`). - 0 new warnings. 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).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!2473
No description provided.