shader: lower compute v_xor3_b32 #1566

Merged
Asimmimx merged 1 commit from upstream-pr/1573 into main 2026-11-24 14:46:05 +00:00
Asimmimx commented 2026-11-24 14:30:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T14:30:39Z.


Change

Refs #1546. This lowers v_xor3_b32 in the compute translator, tools/compute_store_aot.py. v_xor3_b32 vD, a, b, c becomes (a ^ b ^ c), following the RDNA2 ISA definition of VOP3 opcode 0x178 (D.u = S0.u ^ S1.u ^ S2.u).

It joins the existing integer ALU subset: one ALU entry, and the opcode appended to the three-source matcher group (v_mad_u32_u24|v_xor3_b32). Sources are those the subset already accepts: a VGPR, an SGPR holding a known word, an inline constant or a 32-bit literal. The result is data only.

The fixture and controls are in a new tests/compute_alu_xor3_check.py, which imports the helpers of tests/compute_store_check.py. That file is unchanged.

Fixture. It is READ_COMPUTE with the v_min_u32 line replaced by two instructions:

v_xor3_b32 v2, v1, s0, v0
v_xor3_b32 v1, 0x2c5a96e1, v2, -16

The sources therefore cover a result, the dispatch index, an SGPR constant, a literal and a negative inline constant. The expected words come from an independent Python model of the definition, and lane 0 is pinned by hand at 0x2d574c65. The fixture runs the three read dispatches (0, 17 and 150 lanes) and compares all 320 words.

Three sets of checks must fail:

  • Wrong references (11). XOR replaced by OR, AND or add; each source dropped; +16 in place of -16; one word off; a lane past the bound. Each must fail at its first differing word.
  • Mutated HLSL sources (6). Each must fail with "Compute readback differs".
  • Translator controls. These are refused with the existing messages:
    • Unsupported compute instruction for v_or3_b32, v_xad_u32, v_xor3_b32_e64, the -v1/|v1|/neg(s0)/clamp forms, a v[2:3] destination, a fourth source, and sources that are not known words;
    • Unverified ALU operand for a v256 destination;
    • Unsupported store address and Unsupported read address when the result is used as an address;
    • Unverified lane guard compare when the result is a guard operand;
    • ALU expression too large for a long chain.

The new CTest compute_store_aot_alu_xor3_${adapter} is registered after compute_store_aot_mubuf_d16. A "Three-input XOR" subsection is added to docs/experiments.md.

Verification

Commit 6c0e5380 (main) plus this change, dev preset, Windows 11 Pro build 26300.9974, DXC 1.8.2502.11.

python -B tests/compute_alu_xor3_check.py controls                                  # pass
python -B tests/compute_alu_xor3_check.py draw <dxc> <offscreen_check.exe> warp     # pass
python -B tests/compute_alu_xor3_check.py draw <dxc> <offscreen_check.exe> hardware # pass
ctest --preset dev --no-tests=error -R '^compute_store_aot_alu_xor3_(warp|hardware)$' -V
Backend Result
WARP 10.0.26100.9818, debug layer enabled 3 dispatches, 320 words each, mismatches 0, debug errors 0
AMD Radeon RX 6600 (RDNA 2, 1002:73ff), driver 32.0.21045.29003, debug layer enabled 3 dispatches, 320 words each, mismatches 0, debug errors 0

Regression with the change: compute_store_check controls (alu_controls, scalar_alu_controls, f32_controls), draw-guard-read and draw-f32 on WARP, and the compile-mimg-atomic-* modes all pass. tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check pass.

Notes

  • Operand fall-through. The shared three-source matcher keeps its and None not in [...] guard, which lets v_mad_u32_u24 fall through to its row-pitch case. A v_xor3_b32 with an unknown source therefore stops with Unsupported compute instruction: … rather than Unverified ALU operand. I left the shared matcher unchanged.
  • Hand-edited fixture. The fixture is a hand edit of the LLVM 15 read fixture, in the same style as READ_VOP2. Its encodings were checked with llvm-mc 19 (-mcpu=gfx1013). No LLVM 15 binary round trip is wired for it.
  • Merge order. Other #1546 PRs append to the same three-source matcher group. Whichever lands second needs a trivial rebase, and I will do it.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584107527 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1573). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T14:30:39Z. --- ## Change Refs #1546. This lowers `v_xor3_b32` in the compute translator, `tools/compute_store_aot.py`. `v_xor3_b32 vD, a, b, c` becomes `(a ^ b ^ c)`, following the RDNA2 ISA definition of VOP3 opcode 0x178 (`D.u = S0.u ^ S1.u ^ S2.u`). It joins the existing integer ALU subset: one `ALU` entry, and the opcode appended to the three-source matcher group `(v_mad_u32_u24|v_xor3_b32)`. Sources are those the subset already accepts: a VGPR, an SGPR holding a known word, an inline constant or a 32-bit literal. The result is data only. The fixture and controls are in a new `tests/compute_alu_xor3_check.py`, which imports the helpers of `tests/compute_store_check.py`. That file is unchanged. **Fixture.** It is `READ_COMPUTE` with the `v_min_u32` line replaced by two instructions: ``` v_xor3_b32 v2, v1, s0, v0 v_xor3_b32 v1, 0x2c5a96e1, v2, -16 ``` The sources therefore cover a result, the dispatch index, an SGPR constant, a literal and a negative inline constant. The expected words come from an independent Python model of the definition, and lane 0 is pinned by hand at `0x2d574c65`. The fixture runs the three read dispatches (0, 17 and 150 lanes) and compares all 320 words. Three sets of checks must fail: - **Wrong references (11).** XOR replaced by OR, AND or add; each source dropped; `+16` in place of `-16`; one word off; a lane past the bound. Each must fail at its first differing word. - **Mutated HLSL sources (6).** Each must fail with "Compute readback differs". - **Translator controls.** These are refused with the existing messages: - `Unsupported compute instruction` for `v_or3_b32`, `v_xad_u32`, `v_xor3_b32_e64`, the `-v1`/`|v1|`/`neg(s0)`/`clamp` forms, a `v[2:3]` destination, a fourth source, and sources that are not known words; - `Unverified ALU operand` for a `v256` destination; - `Unsupported store address` and `Unsupported read address` when the result is used as an address; - `Unverified lane guard compare` when the result is a guard operand; - `ALU expression too large` for a long chain. The new CTest `compute_store_aot_alu_xor3_${adapter}` is registered after `compute_store_aot_mubuf_d16`. A "Three-input XOR" subsection is added to `docs/experiments.md`. ## Verification Commit `6c0e5380` (`main`) plus this change, `dev` preset, Windows 11 Pro build 26300.9974, DXC 1.8.2502.11. ```powershell python -B tests/compute_alu_xor3_check.py controls # pass python -B tests/compute_alu_xor3_check.py draw <dxc> <offscreen_check.exe> warp # pass python -B tests/compute_alu_xor3_check.py draw <dxc> <offscreen_check.exe> hardware # pass ctest --preset dev --no-tests=error -R '^compute_store_aot_alu_xor3_(warp|hardware)$' -V ``` | Backend | Result | |---|---| | WARP 10.0.26100.9818, debug layer enabled | 3 dispatches, 320 words each, mismatches 0, debug errors 0 | | AMD Radeon RX 6600 (RDNA 2, `1002:73ff`), driver 32.0.21045.29003, debug layer enabled | 3 dispatches, 320 words each, mismatches 0, debug errors 0 | Regression with the change: `compute_store_check` controls (`alu_controls`, `scalar_alu_controls`, `f32_controls`), `draw-guard-read` and `draw-f32` on WARP, and the `compile-mimg-atomic-*` modes all pass. `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` pass. ## Notes - **Operand fall-through.** The shared three-source matcher keeps its `and None not in [...]` guard, which lets `v_mad_u32_u24` fall through to its row-pitch case. A `v_xor3_b32` with an unknown source therefore stops with `Unsupported compute instruction: …` rather than `Unverified ALU operand`. I left the shared matcher unchanged. - **Hand-edited fixture.** The fixture is a hand edit of the LLVM 15 read fixture, in the same style as `READ_VOP2`. Its encodings were checked with `llvm-mc` 19 (`-mcpu=gfx1013`). No LLVM 15 binary round trip is wired for it. - **Merge order.** Other #1546 PRs append to the same three-source matcher group. Whichever lands second needs a trivial rebase, and I will do it. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 15:02:05 +00:00
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
R0Y00/Xbox2Windows!1566
No description provided.