tombox-xshader: fix SCC and 64-bit mask handling in s_lshl_b64, s_bfm_b64, s_addk_i32 #29

Closed
artareias wants to merge 0 commits from upstream-pr/29 into main
artareias commented 2026-11-21 18:12:42 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by artareias on 2026-11-21T18:12:42Z.


Problem

vop::basic::salu_basic (tests/exec_vop/basic.rs) fails with 55 cases on both a hardware adapter and WARP. 43 of them are three scalar ops in the HLSL emitter (crates/tombox-xshader/src/hlsl.rs):

Op What the emitter did Expected
s_lshl_b64 never updated SCC SCC = (result != 0), like the other SOP2 shifts
s_bfm_b64 produced only the low word, high word forced to 0 64-bit mask ((1 << S0[5:0]) - 1) << S1[5:0]
s_addk_i32 added the immediate, SCC untouched SCC = signed overflow of D + signext(SIMM16)

The oracles in tests/exec_vop/basic.rs already encode the expected behaviour, so no test change is needed.

Change

  • s_lshl_b64: set scc after writing both words (s_bfm_b64 and s_cselect_b64 still leave SCC alone).
  • s_bfm_b64: build the 64-bit mask from two words, then shift the pair left by S1[5:0].
  • s_addk_i32: compute D + imm into a temp, set SCC with the same overflow expression s_add_i32 already uses, then write D.

Testing

Windows 10 19045, MSVC 14.44, rustc 1.100.0, AMD Radeon RX 7600 (TOMBOX_EXEC_HW=1) and WARP:

  • salu_basic: 55 failing cases before, 12 after, on both adapters. All 43 s_lshl_b64 / s_bfm_b64 / s_addk_i32 cases pass.
  • Per-test run of all 61 exec tests on the RX 7600 before and after: no other test changes status.
  • cargo test -p tombox-xshader --lib --test synthetic --test opcodes: pass. (amp and fixtures fail on this base because they need local fixtures, see #13.)

Not changed

The remaining 12 salu_basic failures are all s_bfe_i32. The emitter's tb_bfe_i32 uses a 7-bit width ((b >> 16) & 127), while s_bfe_u32 in the same file and the test oracle use 5 bits (& 31). I could not tell which side matches hardware, so I left it. vop3_basic (55 failing cases: v_bfe_i32, v_fma_mix*) is a separate group.

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6532587702 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/29). Originally posted by [artareias](https://github.com/artareias) on 2026-11-21T18:12:42Z. --- ## Problem `vop::basic::salu_basic` (tests/exec_vop/basic.rs) fails with 55 cases on both a hardware adapter and WARP. 43 of them are three scalar ops in the HLSL emitter (`crates/tombox-xshader/src/hlsl.rs`): | Op | What the emitter did | Expected | |---|---|---| | `s_lshl_b64` | never updated SCC | `SCC = (result != 0)`, like the other SOP2 shifts | | `s_bfm_b64` | produced only the low word, high word forced to 0 | 64-bit mask `((1 << S0[5:0]) - 1) << S1[5:0]` | | `s_addk_i32` | added the immediate, SCC untouched | `SCC` = signed overflow of `D + signext(SIMM16)` | The oracles in `tests/exec_vop/basic.rs` already encode the expected behaviour, so no test change is needed. ## Change - `s_lshl_b64`: set `scc` after writing both words (`s_bfm_b64` and `s_cselect_b64` still leave SCC alone). - `s_bfm_b64`: build the 64-bit mask from two words, then shift the pair left by `S1[5:0]`. - `s_addk_i32`: compute `D + imm` into a temp, set SCC with the same overflow expression `s_add_i32` already uses, then write D. ## Testing Windows 10 19045, MSVC 14.44, rustc 1.100.0, AMD Radeon RX 7600 (`TOMBOX_EXEC_HW=1`) and WARP: - `salu_basic`: 55 failing cases before, 12 after, on both adapters. All 43 `s_lshl_b64` / `s_bfm_b64` / `s_addk_i32` cases pass. - Per-test run of all 61 `exec` tests on the RX 7600 before and after: no other test changes status. - `cargo test -p tombox-xshader --lib --test synthetic --test opcodes`: pass. (`amp` and `fixtures` fail on this base because they need local fixtures, see #13.) ## Not changed The remaining 12 `salu_basic` failures are all `s_bfe_i32`. The emitter's `tb_bfe_i32` uses a 7-bit width (`(b >> 16) & 127`), while `s_bfe_u32` in the same file and the test oracle use 5 bits (`& 31`). I could not tell which side matches hardware, so I left it. `vop3_basic` (55 failing cases: `v_bfe_i32`, `v_fma_mix*`) is a separate group. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-11-21 18:12:52 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-21T18:12:52Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:review:6007209599 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/29#pullrequestreview-6007209599). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-21T18:12:52Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
omonkeyz commented 2026-11-22 13:13:08 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:13:08Z.


Main's history was rewritten, which auto-closed this PR (sorry for the noise). Already on main (64-bit s_bfm_b64, s_lshl_b64 SCC and s_addk_i32 overflow SCC). Thanks!

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7079651650 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/29#issuecomment-7079651650). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T13:13:08Z. --- Main's history was rewritten, which auto-closed this PR (sorry for the noise). Already on main (64-bit s_bfm_b64, s_lshl_b64 SCC and s_addk_i32 overflow SCC). Thanks!

Pull request closed

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
omonkeyz/xbox-emulator!29
No description provided.