Skip to content

Shaders: validate raw fixtures and signed MAD64 with full-word regression - #2774

Open
LogicGrove wants to merge 3 commits into
Marvisak:mainfrom
LogicGrove:validation/nvidia-raw-fixtures-mad64
Open

LogicGrove wants to merge 3 commits into
Marvisak:mainfrom
LogicGrove:validation/nvidia-raw-fixtures-mad64

Conversation

@LogicGrove

Copy link
Copy Markdown

Summary

On RTX 2060, the existing stride/gather fixtures fail because they bind structured views for raw loads. Separately, a negative literal in v_mad_i64_i32 loses its sign. This integrates the small corrections from #2357 (LICObr) and #2254 (BastienRodz), preserving their authors in separate commits, and adds an independent CPU-oracle regression covering both result words.

raw fixtures (#2357) + signed literal extension (#2254)
    -> both-word readback compared with i128/u128 CPU arithmetic

Our additional test covers six dynamic input pairs, three literal bit patterns, signed/unsigned variants, and both 32-bit words: 72 word comparisons per backend. No game files, extracted shaders, console SDK, or proprietary fixtures were used. This changes neither heap limits nor carry-out handling.

This is an integration/validation PR, not a claim to have authored the existing fixes. If the original PRs are preferred, the final commit can be cherry-picked onto #2254 independently.

Evidence

Windows 11 Home build 26200, RTX 2060 6 GB, NVIDIA driver 610.88, Rust 1.98.1 MSVC. Base: 13f91ca.

Full workspace run completed (exit 101): victory-gpu: 193 passed, 2 failed, 1 ignored; victory-shader: 271 passed, 1 failed, 3 ignored. Remaining failures: descriptor::host::tests::dynamic_slots_are_held_until_released; memory::tests::lists_share_a_table_and_copies_keep_their_views; emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros. All three were reproduced before this PR. No additional failure names appeared.

The local full-workspace run also includes the previously validated loader tests/reference fix from #2418, which are not included in this shader-only PR. The four shader files in this PR match those tested locally. No FPS or game-playability claim is made.

AI use: Codex assisted with independent reproduction, the additional CPU-oracle test, validation, and this description. Reused changes are credited above.

Merge Danger

Door: Two-way; revert the commits to restore prior behavior.

Blast Radius: Shaders. The production change affects signed MAD literal extension; other changes are synthetic test fixtures and regression coverage. The remaining NVIDIA heap failures are not fixed here.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent verification of head cca9102f (WARP/CPU): looks good.

  • Diff: v_mad_i64_i32 now sign-extends its 32-bit literal addend (v_mad_u64_u32 still zero-extends, per the new test), plus two fixtures changed from structured to raw buffer views. The change is small and in scope.
  • Tests: victory-shader --lib 269 pass, 3 fail. The same 3 fail on origin/main (WARP has no 32-lane pipeline: gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out, a_mask_joined_with_data_at_a_uniform_loop_is_its_number), so they are baseline WARP failures. Note that gathers_at_a_level... is one of the two fixtures this PR edits, so that edit cannot be checked on WARP. The other fixture edit (stride_tests) passes. Clippy -D warnings is clean.
  • Negative control: with the lower.rs change reverted to origin/main, both new tests (mad_i64_i32_sign_extends_literal_addend, mad_literal_addends_match_cpu_in_both_words) fail. They pass with the fix, and they compare both result words against CPU integer arithmetic.

Method: WARP/CPU only (no physical GPU; VICTORY_WARP=1, VICTORY_D3D12_WARP=1, Windows SDK dxil.dll on PATH, so DXIL validation ran), cargo test -p <crate> --lib --locked and cargo clippy -p <crate> --all-targets --locked -- -D warnings, compared with origin/main 13f91ca. Nothing from the game was used.

AI-assisted review (Claude Code / Claude Sonnet 5.5).

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Reviewed and verified cca9102f on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll) against main (13f91ca).

  • Sign-extending Operand::Literal(x) via i64::from(x as i32) for v_mad_i64_i32 (lower.rs:6487-6489) matches inline-constant behavior, and switching byte-addressed fixtures in stride_tests.rs / synthetic_tests.rs to Stride::Raw fixes the a_heap_buffer_read_by_element_takes_the_views_stride failure on RTX 5090 as well.
  • RTX 5090 + WARP + dxil.dll: mad_ 2/2 passed, valu_tests:: 32/32 passed, synthetic_tests:: 7/7 passed, stride_tests:: 7/8 passed (only the separate pre-existing NVIDIA a_heap_buffer_read_where_no_buffer_view_is_reads_zeros failure remains, as noted in the PR).
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree vs 13f91ca, #2768, and #2766.

@kotekompotek

Copy link
Copy Markdown

Correct: v_mad_i64_i32's name doesn't match the _i64 suffix check so its S2 literal was zero-extended - the explicit-name addition matches LLVM's operand rules (S2.i64 sign-extends). The test splits the cases well (mad_i64 sign-extends -100, mad_u64 zero-extends). Raw-stride fixture changes also fix the tests to match how the host actually views heap buffers.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This PR re-packages changes from other PRs: the lower.rs src64 change and the mad_i64_i32_sign_extends_literal_addend test are those of #2254, which is still open and already marked as a merge candidate, and the stride_tests.rs/synthetic_tests.rs fixture changes are those of #2357. The only new part is mad_literal_addends_match_cpu_in_both_words. That test would be better offered to #2254 (as a suggestion on that PR), and the fixture change can be raised again on its own if a maintainer wants it, so review happens in one place. CI passes on this head.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants