Skip to content

shader: add hardware semantics tests for SAD/MSAD, 64-bit MAD, and v_perm_b32 (T12) - #51

Merged
DesertGamer merged 1 commit into
DesertGamer:mainfrom
Lewandox:test/semantics-t12
Nov 26, 2026
Merged

DesertGamer merged 1 commit into
DesertGamer:mainfrom
Lewandox:test/semantics-t12

Conversation

@Lewandox

Copy link
Copy Markdown
Contributor

What

Implements T12 from #29: adds hardware + WARP semantics tests in crates/viport-shader/src/emit/semantics_tests.rs for three lowered arithmetic instruction families that previously had no hardware semantics probes:

  1. sad_and_msad_match_the_hardware — v_sad_u8 (0x15A), v_sad_hi_u8 (0x15B), v_sad_u16 (0x15C), v_sad_u32 (0x15D), and v_msad_u8 (0x171) across 600 edge inputs each (zero mask bytes for v_msad_u8, max byte/half/dword differences, a < b vs a > b, and 32-bit wrapping accumulators).
  2. wide_mad_matches_the_hardware — v_mad_u64_u32 (0x176, checking both 64-bit v[5:6] and carry-out in VCC via v_cndmask_b32) and v_mad_i64_i32 (0x177, signed 32×32 → 64 product plus 64-bit addend) across 384 edge inputs each (0, 1, i32::MAX, i32::MIN, u32::MAX, and 64-bit carry boundaries).
  3. byte_permute_matches_the_hardware — v_perm_b32 (0x344) across both the runtime VGPR selector path (216 inputs covering 0..=3 src1 bytes, 4..=7 src0 bytes, 8..=11 sign-fill of bytes 1 & 3 for both positive and negative sign bits, 12 → 0x00, and 13..=255 → 0xFF) and the literal constant selector path (36 inputs with 0x0D0C_0904).

Tested

Windows 11, Rust 1.100.0 (stable-x86_64-pc-windows-gnu, no game data), on main 7f8320c plus this commit:

  • cargo fmt --all -- --check: passed.
  • cargo xtask policy: passed (asset policy: 220 files ok).
  • cargo clippy -p viport-shader --no-deps --all-targets: zero warnings in semantics_tests.rs.
  • cargo test -p viport-shader --lib -- --nocapture sad_and_msad_match_the_hardware wide_mad_matches_the_hardware byte_permute_matches_the_hardware: 3 passed, 0 failed (all 9 probes ran on both the hardware adapter and WARP with 0 model mismatches on hardware, 0 on WARP, and 0 hardware/WARP disagreements).
  • Not tested: full --workspace suite.

Checklist

  • cargo fmt --all -- --check and cargo xtask policy pass; no game files or data from them.
  • AI-assisted: written with Antigravity; compiled and verified on hardware + WARP locally.

@DesertGamer
DesertGamer merged commit 59b7938 into DesertGamer:main Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants