startup: lower v_mov_b32_sdwa in gfx2hlsl #2278

Merged
NiiRoZz merged 1 commit from upstream-pr/2286 into main 2026-11-25 10:20:48 +00:00
NiiRoZz commented 2026-11-25 10:07:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T10:07:12Z.


Change

tools/startup/gfx2hlsl.py refused every v_mov_b32_sdwa with SDWA form of v_mov_b32. sdwa() now
lowers it through the existing sdwa_source / sdwa_dest helpers as a one-source operation whose result
is the selected source. Refs #2274 (item "SDWA v_mov").

Lowered (each spelling assembles with llvm-mc 15, -mcpu=gfx1013):

  • src0_sel BYTE_0..3, WORD_0..1, DWORD, zero-extended or under sext();
  • dst_sel BYTE_0..3, WORD_0..1, DWORD with dst_unused UNUSED_PAD or UNUSED_PRESERVE;
  • UNUSED_SEXT only with dst_sel:DWORD, where there are no unused bits;
  • VGPR, SGPR and inline-constant sources.

Still refused, with the reason named:

  • dst_unused:UNUSED_SEXT with a byte or word destination: SDWA UNUSED_SEXT (unchanged helper);
  • clamp (llvm-mc assembles it): v_mov_b32 with SDWA modifier clamp;
  • a byte or word of exec/vcc/a tracked mask register: v_mov_b32 SDWA <sel> of lane mask <operand>.
    The translator holds a lane mask as one bit per lane, so a field of it is not the hardware field.
    A DWORD selection of a mask stays the plain move.
  • missing src0_sel or dst_sel.

No shared interface changes; VEC_U and the DPP path are untouched.

Verification

Commit d2f08372 on startup/gfx2hlsl-sdwa-v-mov, Windows 11, Python from out/pe-env.

Command Result
python -B tests/startup_gfx2hlsl_sdwa_check.py exit 0, PASS, 52 of 52 cases ok (12 existing, 40 new)
python -B tests/startup_gfx2hlsl_sdwa_cvt_check.py exit 0, PASS
python -B tests/startup_gfx2hlsl_handler_arity_check.py exit 0
python -B tests/form_coverage_check.py exit 0
python -B tests/pso_readiness_check.py exit 0
python -B tests/startup_translator_check.py exit 0, 0 failed
python -B tests/shader_corpus_report_check.py exit 0
git diff --check origin/main...HEAD exit 0, no output

Negative control: the new check against tools/startup/gfx2hlsl.py from origin/main exits 1 with 38
MISMATCH lines; the first is v_mov source BYTE_0 zero-extended, emitted refused: SDWA form of v_mov_b32.

Not run: CMake/ctest, the draw mode of the SDWA conversion check and any GPU test. The evidence here is
device-free: there is no GPU read-back for this form.

Evidence and follow-up

The new cases are synthetic assembly lines written for this check (MIT, no external input). Each of the 7
source selections (zero- and sign-extended) and 7 destination selections (PAD and PRESERVE) is compared
as a whole statement against a hand-written literal, so a shift, mask or keep-mask off by one fails its
own case. Refusals are matched on their reason text.

Assumptions and gaps another contributor can pick up:

  • Semantics follow the existing helpers, which the check keeps in parity with tools/pixel_aot.py; they
    are not read back from a device for v_mov_b32_sdwa.
  • When dst_unused is not printed, sdwa() assumes UNUSED_PAD, while llvm-mc 15 fills in
    UNUSED_PRESERVE. Pre-existing and not changed here.
  • The other integer SDWA forms (VEC_U) do not refuse a byte or word of a lane mask. Not changed here.
  • startup_gfx2hlsl_sdwa is registered in CMake only, not in the pure-Python lists of
    .github/workflows/windows.yml and AGENTS.md. Left as it was.

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. (none changed)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6602014473 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2286). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T10:07:12Z. --- ## Change `tools/startup/gfx2hlsl.py` refused every `v_mov_b32_sdwa` with `SDWA form of v_mov_b32`. `sdwa()` now lowers it through the existing `sdwa_source` / `sdwa_dest` helpers as a one-source operation whose result is the selected source. Refs #2274 (item "SDWA v_mov"). Lowered (each spelling assembles with llvm-mc 15, `-mcpu=gfx1013`): - `src0_sel` BYTE_0..3, WORD_0..1, DWORD, zero-extended or under `sext()`; - `dst_sel` BYTE_0..3, WORD_0..1, DWORD with `dst_unused` UNUSED_PAD or UNUSED_PRESERVE; - UNUSED_SEXT only with `dst_sel:DWORD`, where there are no unused bits; - VGPR, SGPR and inline-constant sources. Still refused, with the reason named: - `dst_unused:UNUSED_SEXT` with a byte or word destination: `SDWA UNUSED_SEXT` (unchanged helper); - `clamp` (llvm-mc assembles it): `v_mov_b32 with SDWA modifier clamp`; - a byte or word of `exec`/`vcc`/a tracked mask register: `v_mov_b32 SDWA <sel> of lane mask <operand>`. The translator holds a lane mask as one bit per lane, so a field of it is not the hardware field. A DWORD selection of a mask stays the plain move. - missing `src0_sel` or `dst_sel`. No shared interface changes; `VEC_U` and the DPP path are untouched. ## Verification Commit d2f08372 on `startup/gfx2hlsl-sdwa-v-mov`, Windows 11, Python from `out/pe-env`. | Command | Result | |---|---| | `python -B tests/startup_gfx2hlsl_sdwa_check.py` | exit 0, PASS, 52 of 52 cases ok (12 existing, 40 new) | | `python -B tests/startup_gfx2hlsl_sdwa_cvt_check.py` | exit 0, PASS | | `python -B tests/startup_gfx2hlsl_handler_arity_check.py` | exit 0 | | `python -B tests/form_coverage_check.py` | exit 0 | | `python -B tests/pso_readiness_check.py` | exit 0 | | `python -B tests/startup_translator_check.py` | exit 0, 0 failed | | `python -B tests/shader_corpus_report_check.py` | exit 0 | | `git diff --check origin/main...HEAD` | exit 0, no output | Negative control: the new check against `tools/startup/gfx2hlsl.py` from `origin/main` exits 1 with 38 MISMATCH lines; the first is `v_mov source BYTE_0 zero-extended`, emitted `refused: SDWA form of v_mov_b32`. Not run: CMake/ctest, the `draw` mode of the SDWA conversion check and any GPU test. The evidence here is device-free: there is no GPU read-back for this form. ## Evidence and follow-up The new cases are synthetic assembly lines written for this check (MIT, no external input). Each of the 7 source selections (zero- and sign-extended) and 7 destination selections (PAD and PRESERVE) is compared as a whole statement against a hand-written literal, so a shift, mask or keep-mask off by one fails its own case. Refusals are matched on their reason text. Assumptions and gaps another contributor can pick up: - Semantics follow the existing helpers, which the check keeps in parity with `tools/pixel_aot.py`; they are not read back from a device for `v_mov_b32_sdwa`. - When `dst_unused` is not printed, `sdwa()` assumes UNUSED_PAD, while llvm-mc 15 fills in UNUSED_PRESERVE. Pre-existing and not changed here. - The other integer SDWA forms (`VEC_U`) do not refuse a byte or word of a lane mask. Not changed here. - `startup_gfx2hlsl_sdwa` is registered in CMake only, not in the pure-Python lists of `.github/workflows/windows.yml` and `AGENTS.md`. Left as it was. ## 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. (none changed) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 11:02:19 +00:00
tedin7 commented 2026-11-25 11:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:10:48Z.

Review: COMMENTED


Review of head d2f083723b (tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_sdwa_check.py).

Findings: 0 P1, 0 P2.

  • v_mov_b32_sdwa reuses the existing SDWA path with the selected source as the result. Zero-extend, sign-extend (byte/word shifts), dst_sel placement and UNUSED_PAD/UNUSED_PRESERVE keep-masks match the RDNA2 SDWA semantics. UNUSED_SEXT with a sub-dword destination, clamp, missing src0_sel/dst_sel are refused.
  • Sub-dword selections of a per-lane mask (exec/vcc/mask SGPRs) are refused, since the mask is one bit per lane here. Whole DWORD mask move stays a plain move.
  • No competing open or recently merged PR covers v_mov_b32_sdwa.
  • Tests assert literal expected statements for every selection, so a wrong shift/mask fails its own case.

Commands executed locally:

  • python3 tests/startup_gfx2hlsl_sdwa_check.py -> PASS
  • python3 tests/docs_links_check.py -> 18 files, 435 links OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: lane-mask guard disabled (if False and ...) -> new tests FAIL (lane-mask refusal cases), reverted.
  • Mutation 2: v_mov result changed to ({0} ^ 1u) -> new tests FAIL, reverted.
  • CI: Linux checks pass, fixtures pass, Build and test on Windows pass. Py-only change, so the pure-python fast path applies.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6055591927 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2286#pullrequestreview-6055591927). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:10:48Z. **Review:** COMMENTED --- Review of head d2f083723b31cbe76851d0adef0c9000ed769acb (tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_sdwa_check.py). Findings: 0 P1, 0 P2. - `v_mov_b32_sdwa` reuses the existing SDWA path with the selected source as the result. Zero-extend, sign-extend (byte/word shifts), dst_sel placement and UNUSED_PAD/UNUSED_PRESERVE keep-masks match the RDNA2 SDWA semantics. UNUSED_SEXT with a sub-dword destination, clamp, missing src0_sel/dst_sel are refused. - Sub-dword selections of a per-lane mask (exec/vcc/mask SGPRs) are refused, since the mask is one bit per lane here. Whole DWORD mask move stays a plain move. - No competing open or recently merged PR covers `v_mov_b32_sdwa`. - Tests assert literal expected statements for every selection, so a wrong shift/mask fails its own case. Commands executed locally: - `python3 tests/startup_gfx2hlsl_sdwa_check.py` -> PASS - `python3 tests/docs_links_check.py` -> 18 files, 435 links OK - `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean - Mutation 1: lane-mask guard disabled (`if False and ...`) -> new tests FAIL (lane-mask refusal cases), reverted. - Mutation 2: v_mov result changed to `({0} ^ 1u)` -> new tests FAIL, reverted. - CI: Linux checks pass, fixtures pass, `Build and test on Windows` pass. Py-only change, so the pure-python fast path applies. AI-assisted; commands listed were executed locally.
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!2278
No description provided.