Skip to content

Shaders: hardware probes for the 64-bit scalar logic and shift ops - #2570

Open
LouisRiverstone wants to merge 1 commit into
Marvisak:mainfrom
LouisRiverstone:shaders/s-logic-shift-b64-probes
Open

LouisRiverstone wants to merge 1 commit into
Marvisak:mainfrom
LouisRiverstone:shaders/s-logic-shift-b64-probes

Conversation

@LouisRiverstone

Copy link
Copy Markdown
Contributor

Adds probes for s_and/or/xor/andn2/orn2/nand/nor/xnor_b64 (SOP2 0x0F-0x1D) and s_lshl_b64, s_lshr_b64, s_ashr_i64 (0x1F, 0x21, 0x23) to scalar_probes: both result dwords and SCC, over 64-bit edge values, with shift counts that pin the six-bit mask (63, 64, 65, garbage in the high bits). Only a single s_ashr_i64 case was tested before. Test-only.

@fyernald fyernald left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on real NVIDIA hardware: RTX 3080 (617.42), Windows 10 (19045), plus WARP, main 67e8ae1 + #486 + #2596 (without #2596 the suite crashes on NVIDIA, #2571). cargo test -p victory-shader --lib --locked -- --test-threads=1 gives 267 passed, 3 failed, the same as the base. The 3 are the #1835 failures. The new probes agree with the model on both adapters.

The SOP2 opcodes match RDNA2: the _b64 logic ops at 0x0F to 0x1D (odd), then s_lshl_b64/s_lshr_b64/s_ashr_i64 at 0x1F/0x21/0x23. The shift references mask the count to 6 bits as the hardware does.

@Mericas77

Copy link
Copy Markdown

Tested on NVIDIA: RTX 4070, driver 621.01, Windows 11, rustc 1.100.0. Head f70c8c4 against main 67e8ae1.

No game data; the title was not run.

AI-assisted.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. This is a recommendation to look, not an approval. It merges cleanly into main. CI: check passing.

The PR adds scalar_64_probes to scalar_probes in crates/victory-shader/src/emit/semantics_tests.rs. It covers the 64-bit SOP2 ops s_and/or/xor/andn2/orn2/nand/nor/xnor_b64 and s_lshl/lshr_b64/s_ashr_i64 over 64-bit edge pairs, checking both result dwords and SCC. The opcodes (0x0F–0x23, odd) match the SOP2 table in gfx10/opcodes.rs. The model's six-bit shift count and SCC = result != 0 match the RDNA2 ISA and the existing lowering arms in lower.rs. Register use fits program(): inputs in s16–s19, the result in s[20:21], SCC to s22 via s_cselect, and outputs from v5–v7. main has no probe for these ops yet.


Generated by Claude Code

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me — clean test-only expansion of scalar_probes covering all eight 64-bit SOP2 bitwise ops and all three 64-bit scalar shifts, including SCC (!= 0) and 6-bit shift-count masking.

Verified locally on Windows 11 with head f70c8c4e cleanly merged onto main (63bcca43):

  • Audited all 11 SOP2 opcodes in scalar_64_probes (crates/victory-shader/src/emit/semantics_tests.rs:2816-2878): 0x0F..=0x1D (odd: s_and/or/xor/andn2/orn2/nand/nor/xnor_b64) and 0x1F/0x21/0x23 (s_lshl_b64, s_lshr_b64, s_ashr_i64) match gfx10/opcodes.rs and RDNA2 semantics, capturing s[20:21] and SCC via s_cselect_b32.
  • Formatting check (rustfmt --edition 2024 --config skip_children=true) shows no diffs on the added lines.
  • cargo run -p xtask -- policy (191 files ok) and cargo clippy --locked -p victory-shader --all-targets -- -D warnings (both default and --all-features) pass.
  • cargo test --locked -p victory-shader --lib scalar_alu_matches_the_hardware -- --nocapture passes on both VICTORY_WARP=0 (2.41s) and VICTORY_WARP=1 (0.22s): all 39 probes (including all 11 new probes across 64 logic pairs / 72 shift inputs) report model mismatches ["hardware 0", "warp 0"], hardware/warp differ on 0.

Tiny non-blocking doc-comment nit: semantics_tests.rs:2813-2814 mentions s[16:17] and s[18:19] as operands for all 11 ops, whereas the three shift ops only read scalar s18[5:0] (with s19 holding OLD and unused).

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Adding 64-bit scalar logic and shift probes to scalar_alu_matches_the_hardware expands hardware-verified coverage cleanly on both RTX 5090 and WARP.
  • cargo test -p victory-shader --lib emit::semantics_tests::scalar_alu_matches_the_hardware -- --test-threads=1: passed on RTX 5090 and VICTORY_WARP=1.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

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.

6 participants