tombox-xshader: decode the remaining SOP1 saveexec ops and translate s_andn1/s_andn2_wrexec #242

Closed
github-bot wants to merge 1 commit from gh-pr/242/head into gh-pr/242/base
Owner

@⁠azerioxfr on GitHub · 2026-11-23 07:01 UTC · original
azerioxfr:xshader-sop1-saveexec-variants → main · +74 −3 · 5 files · 1 commits · closed without merging

Library / area: tombox-xshader, SOP1 exec-mask ops (rdna2/mnem.rs, hlsl.rs saveexec / wrexec)

Exports changed (exports.txt rows): none

Source of the behaviour: opcodes from tests/isa_table/gfx1013.txt (SOP1 0x2a, 0x2b, 0x39, 0x3a, 0x41..0x47). Semantics from the RDNA2 ISA.

One topic, +74 / -3: 7 lines in rdna2/mnem.rs, 19 in hlsl.rs, the rest tests.

What was missing

tests/isa_table.rs lists these eleven under "sop1: gfx1013 opcodes not named by the decoder".

The change

opcodes change
s_nor_saveexec_b64, s_xnor_saveexec_b64, s_nand/nor/xnor/andn1/orn1_saveexec_b32 decoder names only. The saveexec lowering already had these operations (D = old EXEC, EXEC = op(S0, EXEC), SCC = EXEC != 0).
s_andn1_wrexec_b32/b64 (EXEC = ~S0 & EXEC), s_andn2_wrexec_b32/b64 (EXEC = S0 & ~EXEC) new lowering: D = the new EXEC, SCC = EXEC != 0. The b64 forms write 0 to the high half, as the b64 saveexec forms do in the one-lane model.

Tests

run (WARP, --release, DXC 1.9.2609) result
scalar_saveexec_lane_model (7 new names added) 18 mnemonics verified, 0 failing, 72 cases (constant and runtime inputs)
new scalar_wrexec_lane_model 4 mnemonics verified, 0 failing, 16 cases (constant and runtime inputs)
mutation: no SCC write in the wrexec lowering 2 verified, 2 failing
--test isa_table / --test opcodes pass

The wrexec helper saves EXEC and SCC before restoring EXEC, so a lane disabled by a zero EXEC cannot hide a result, and it starts from the opposite SCC so a missing SCC write is caught. isa_sweep lists the new ops in its skip list (wave-level EXEC/SCC, covered by the exec tests). On x86_64-pc-windows-gnu that binary also reports floating-point FMA / f64 mismatches (v_fma_f32, v_floor_f64, ...), the GNU fmaf issue (#126). They are unrelated to this change.

  • cargo test -p tombox-xshader --test exec -- scalar_saveexec_lane_model scalar_wrexec_lane_model passes
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
**@⁠azerioxfr** on GitHub · 2026-11-23 07:01 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/242) `azerioxfr:xshader-sop1-saveexec-variants` → `main` · +74 −3 · 5 files · 1 commits · closed without merging **Library / area:** tombox-xshader, SOP1 exec-mask ops (`rdna2/mnem.rs`, `hlsl.rs` saveexec / wrexec) **Exports changed (exports.txt rows):** none **Source of the behaviour:** opcodes from `tests/isa_table/gfx1013.txt` (SOP1 0x2a, 0x2b, 0x39, 0x3a, 0x41..0x47). Semantics from the RDNA2 ISA. One topic, +74 / -3: 7 lines in `rdna2/mnem.rs`, 19 in `hlsl.rs`, the rest tests. ### What was missing `tests/isa_table.rs` lists these eleven under "sop1: gfx1013 opcodes not named by the decoder". ### The change | opcodes | change | |---|---| | `s_nor_saveexec_b64`, `s_xnor_saveexec_b64`, `s_nand/nor/xnor/andn1/orn1_saveexec_b32` | decoder names only. The saveexec lowering already had these operations (D = old EXEC, EXEC = op(S0, EXEC), SCC = EXEC != 0). | | `s_andn1_wrexec_b32/b64` (EXEC = ~S0 & EXEC), `s_andn2_wrexec_b32/b64` (EXEC = S0 & ~EXEC) | new lowering: D = the new EXEC, SCC = EXEC != 0. The b64 forms write 0 to the high half, as the b64 saveexec forms do in the one-lane model. | ### Tests | run (WARP, `--release`, DXC 1.9.2609) | result | |---|---| | `scalar_saveexec_lane_model` (7 new names added) | 18 mnemonics verified, 0 failing, 72 cases (constant and runtime inputs) | | new `scalar_wrexec_lane_model` | 4 mnemonics verified, 0 failing, 16 cases (constant and runtime inputs) | | mutation: no SCC write in the wrexec lowering | 2 verified, 2 failing | | `--test isa_table` / `--test opcodes` | pass | The wrexec helper saves EXEC and SCC before restoring EXEC, so a lane disabled by a zero EXEC cannot hide a result, and it starts from the opposite SCC so a missing SCC write is caught. `isa_sweep` lists the new ops in its skip list (wave-level EXEC/SCC, covered by the exec tests). On `x86_64-pc-windows-gnu` that binary also reports floating-point FMA / f64 mismatches (`v_fma_f32`, `v_floor_f64`, ...), the GNU `fmaf` issue (#126). They are unrelated to this change. - [x] `cargo test -p tombox-xshader --test exec -- scalar_saveexec_lane_model scalar_wrexec_lane_model` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
SOP1 opcodes 0x2a, 0x2b, 0x39, 0x3a and 0x41..0x47 were not decoded
(the isa_table test lists them under "sop1: gfx1013 opcodes not named
by the decoder"):
- s_nor_saveexec_b64, s_xnor_saveexec_b64, s_nand/nor/xnor/andn1/orn1
  _saveexec_b32: the saveexec lowering already had these operations;
  only the decoder names were missing. D = old EXEC,
  EXEC = op(S0, EXEC), SCC = EXEC != 0.
- s_andn1_wrexec_b32/b64 (EXEC = ~S0 & EXEC) and s_andn2_wrexec_b32/b64
  (EXEC = S0 & ~EXEC): new lowering. D = the new EXEC and
  SCC = EXEC != 0, per the RDNA2 ISA; the b64 forms write 0 to the high
  half, as the b64 saveexec forms do in the one-lane model.

Tests: scalar_saveexec_lane_model covers the seven new saveexec names
(18 mnemonics, 72 cases); new scalar_wrexec_lane_model covers the four
wrexec ops (16 cases) and saves EXEC and SCC before restoring EXEC,
starting from the opposite SCC so a missing SCC write is caught. Both
pass on WARP with constant and runtime inputs. Without the SCC write
in the wrexec lowering, 2 of the 4 wrexec mnemonics fail. The
isa_sweep skip list names the new ops, and opcodes.rs checks the
emitted text.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:15:27 +00:00
github-bot closed this pull request 2026-11-26 06:15:27 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 14:08 UTC · original

Applied locally on main with your authorship kept (cherry-picked, 0447a97); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.

**@⁠omonkeyz** on GitHub · 2026-11-23 14:08 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/242#issuecomment-7103529540) Applied locally on main with your authorship kept (cherry-picked, 0447a97); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.
Author
Owner

@⁠kiwe147 on GitHub · 2026-11-23 19:15 UTC · original

Tested head c01af90404, applied with git apply (whitespace ignored, the line endings of my checkout differ) on main f89e410, together with #244, #248 (one tree; the PRs touch different files). It applied without conflicts and built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1.

run result
tombox-xshader lib + opcodes, synthetic, mesh, linkage, mixed_table, ps_linkage, centroid, gcn_dims, amp, xshader_cli, isa_sweep 205 passed, 0 failed
the tests the PRs of this tree add, in the exec suite on WARP 2 passed, 0 failed
the same tests with TOMBOX_EXEC_HW=1 (RTX 3080) 2 passed, 0 failed

No new failure against main f89e410 in any of these. This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

**@⁠kiwe147** on GitHub · 2026-11-23 19:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/242#issuecomment-7111318292) Tested head `c01af90404`, applied with `git apply` (whitespace ignored, the line endings of my checkout differ) on `main` `f89e410`, together with #244, #248 (one tree; the PRs touch different files). It applied without conflicts and built. Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1. | run | result | |---|---| | `tombox-xshader` lib + `opcodes`, `synthetic`, `mesh`, `linkage`, `mixed_table`, `ps_linkage`, `centroid`, `gcn_dims`, `amp`, `xshader_cli`, `isa_sweep` | 205 passed, 0 failed | | the tests the PRs of this tree add, in the `exec` suite on WARP | 2 passed, 0 failed | | the same tests with `TOMBOX_EXEC_HW=1` (RTX 3080) | 2 passed, 0 failed | No new failure against `main` `f89e410` in any of these. This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code)
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:07 UTC · original

Applied on main in 0447a97 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:07 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/242#issuecomment-7163332855) Applied on main in 0447a97 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-24 14:34 UTC · original · approved these changes

I checked this on RDNA2 silicon: a gfx1036 iGPU (Ryzen 5 9600X), ROCm/HIP 5.7.1, raw wave32 kernels, so RDNA2, not gfx1013. Each kernel ran twice with identical results, and I compared against the semantics this PR implements (my own port; I didn't run the PR's code).

  • All 20 SOP1 saveexec ops match on 4,096 random EXEC / S0 pairs each: and, or, xor, andn2, orn2, nand, nor, xnor, andn1 and orn1, each as _b32 and _b64. That covers D (the old EXEC), the new EXEC and SCC.
  • s_andn1_wrexec_b32/_b64 and s_andn2_wrexec_b32/_b64 match too: EXEC = ~S0 & EXEC and S0 & ~EXEC, D = the new EXEC, SCC = (EXEC != 0).
  • For the _b64 forms in wave32 I also set EXEC_HI to random values. The hardware applies the op to all 64 bits. With EXEC_HI = 0, as the lowering assumes, D_hi is 0, as written here.

(Measured with an AI assistant, Claude.)

**@⁠SchmashinPrunes** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/242#pullrequestreview-6041175658) · **approved these changes** I checked this on RDNA2 silicon: a gfx1036 iGPU (Ryzen 5 9600X), ROCm/HIP 5.7.1, raw wave32 kernels, so RDNA2, not gfx1013. Each kernel ran twice with identical results, and I compared against the semantics this PR implements (my own port; I didn't run the PR's code). - All 20 SOP1 saveexec ops match on 4,096 random EXEC / S0 pairs each: `and`, `or`, `xor`, `andn2`, `orn2`, `nand`, `nor`, `xnor`, `andn1` and `orn1`, each as `_b32` and `_b64`. That covers D (the old EXEC), the new EXEC and SCC. - `s_andn1_wrexec_b32/_b64` and `s_andn2_wrexec_b32/_b64` match too: EXEC = ~S0 & EXEC and S0 & ~EXEC, D = the new EXEC, SCC = (EXEC != 0). - For the `_b64` forms in wave32 I also set EXEC_HI to random values. The hardware applies the op to all 64 bits. With EXEC_HI = 0, as the lowering assumes, D_hi is 0, as written here. (Measured with an AI assistant, Claude.)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.