tests: draw all overlapping SDWA movrel register pairs #2464

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2472 into main 2026-11-25 19:08:37 +00:00
RavenCurseBurg commented 2026-11-25 17:41:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T17:41:09Z.


Refs #1917. The existing SDWA movrel draw uses separate source and destination banks; the same-bank device-free check has two reachable offsets. This adds a draw that exports every word of one four-register bank after v_movrelsd_2_b32_sdwa copies the indexed source's BYTE_0 to the destination's BYTE_1 with UNUSED_PRESERVE. The fixture checks all 16 pairs against a host bitfield calculation. An exact same-register copy still changes the selected byte.

Verification

  • I assembled the new instruction sequence with LLVM 15 for gfx1013 and gfx1030 wave64. In both cases the 80-byte body (including s_endpgm) has f9 90 30 7e 18 11 00 00 at byte 52, disassembling to the indexed SDWA move in the fixture.
  • The full draw-sdwa-movrel entry passed on Intel UHD 770, GeForce RTX 4060 and Windows WARP with DXC 1.9.2609.5. On each, all 16 four-word references matched and the unchanged-bank control failed.
  • I changed the translator in a temporary experiment to drop the high source-index bit only when the SDWA banks share a base. The previous full host controls and the previous GPU test on all three adapters allowed it. The new draw rejected exactly the eight positive cases using source index 2 or 3 on each adapter.
  • Two independent changed shaders localized the other distinctions: treating a same-register move as a no-op changed exactly the four diagonal cases; swapping the two offsets changed exactly the twelve off-diagonal cases. These measurements exercise translated DXIL on the listed adapters.

AI-assisted with Codex + GPT-6.2 Astra (xhigh).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610228995 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2472). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T17:41:09Z. --- Refs #1917. The existing SDWA movrel draw uses separate source and destination banks; the same-bank device-free check has two reachable offsets. This adds a draw that exports every word of one four-register bank after `v_movrelsd_2_b32_sdwa` copies the indexed source's BYTE_0 to the destination's BYTE_1 with UNUSED_PRESERVE. The fixture checks all 16 pairs against a host bitfield calculation. An exact same-register copy still changes the selected byte. **Verification** - I assembled the new instruction sequence with LLVM 15 for gfx1013 and gfx1030 wave64. In both cases the 80-byte body (including `s_endpgm`) has `f9 90 30 7e 18 11 00 00` at byte 52, disassembling to the indexed SDWA move in the fixture. - The full `draw-sdwa-movrel` entry passed on Intel UHD 770, GeForce RTX 4060 and Windows WARP with DXC 1.9.2609.5. On each, all 16 four-word references matched and the unchanged-bank control failed. - I changed the translator in a temporary experiment to drop the high source-index bit only when the SDWA banks share a base. The previous full host controls and the previous GPU test on all three adapters allowed it. The new draw rejected exactly the eight positive cases using source index 2 or 3 on each adapter. - Two independent changed shaders localized the other distinctions: treating a same-register move as a no-op changed exactly the four diagonal cases; swapping the two offsets changed exactly the twelve off-diagonal cases. These measurements exercise translated DXIL on the listed adapters. AI-assisted with Codex + GPT-6.2 Astra (xhigh).
ChazY11 commented 2026-11-25 19:04:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:34:31Z.


Verified on WARP and on a physical GPU, and the two in-place mutations are real mismatches, not refusals

This is one of the few PRs in this series I could run end to end here, so the numbers below are rendered pixels rather than a refusal string.

python -B tests/pixel_aot_check.py draw-sdwa-movrel <dxc 10.0.26100> <out/build/dev/offscreen_check.exe> warp
    sdwa movrel: (0x008856aa, 0x3600ffbb, 0xffffffdd, 0x332143bb), (0x00cc56aa, 0x3600ffb9, 0x0048ffdd, 0x887743bb)
    control v_movrels_b32_sdwa with the source selection dropped: pixel mismatch, as required
    … five controls …
    exit 0

same command with `hardware` (RTX 5080 Laptop, driver as installed, Windows 11 build 26300.9974)
    exit 0
mutation of the two-word v_movrelsd_2_b32_sdwa path result
UNUSED_PRESERVE lost — the destination keeps the new value instead of prev caught
read-before-write lost — prev taken from the register being written caught

Both were caught as pixel mismatches, which matters: the check compares rendered words, so an in-place mistake shows up as a wrong pixel rather than as a translation refusal. That is the only way this bug class can be caught, because the translator is perfectly happy to emit the wrong thing.

Why the four in-place pairs are the point

Of the 16 index pairs, four have dst == src. With UNUSED_PRESERVE and BYTE_1/BYTE_0, the instruction copies byte 0 of the selected source into byte 1 of the selected destination while keeping the destination's other bytes — so when those are the same register, the "previous value" the preserve keeps is the value the same instruction is reading. Treating it as a no-op, or reading prev after the write, changes exactly those four and leaves the other twelve identical. The PR says so in the docstring and the two mutations confirm the fixture can tell the difference.

What I would add

The docstring says the check covers "all 16 index pairs, including the four in-place writes". The 16 come from s_and_b64 s[84:85], s[84:85], 0x30003 with m0 selecting both offsets, and the exported bank is four words — so the pairs are enumerated by m0, not by 16 separate programs. Worth one sentence saying which enumeration is meant (16 m0 values in one draw), because a reader may expect 16 draws.

Note on the modes

draw-sdwa-movrel now carries this check as an extra function call at the end rather than a new mode. That is fine and keeps the runtime down, but it does mean the new coverage is invisible in ctest -N; if you want it separately skippable, a SKIP_RETURN_CODE 77 mode of its own would show up in the test list.

AI-assisted; both runs and both mutations were executed locally on Windows 11 build 26300.9974, WARP and the installed GPU.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171096588 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2472#issuecomment-7171096588). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:34:31Z. --- ## Verified on WARP **and** on a physical GPU, and the two in-place mutations are real mismatches, not refusals This is one of the few PRs in this series I could run end to end here, so the numbers below are rendered pixels rather than a refusal string. ```text python -B tests/pixel_aot_check.py draw-sdwa-movrel <dxc 10.0.26100> <out/build/dev/offscreen_check.exe> warp sdwa movrel: (0x008856aa, 0x3600ffbb, 0xffffffdd, 0x332143bb), (0x00cc56aa, 0x3600ffb9, 0x0048ffdd, 0x887743bb) control v_movrels_b32_sdwa with the source selection dropped: pixel mismatch, as required … five controls … exit 0 same command with `hardware` (RTX 5080 Laptop, driver as installed, Windows 11 build 26300.9974) exit 0 ``` | mutation of the two-word `v_movrelsd_2_b32_sdwa` path | result | |---|---| | `UNUSED_PRESERVE` lost — the destination keeps the new value instead of `prev` | **caught** | | read-before-write lost — `prev` taken from the register being written | **caught** | Both were caught as **pixel mismatches**, which matters: the check compares rendered words, so an in-place mistake shows up as a wrong pixel rather than as a translation refusal. That is the only way this bug class can be caught, because the translator is perfectly happy to emit the wrong thing. ### Why the four in-place pairs are the point Of the 16 index pairs, four have `dst == src`. With `UNUSED_PRESERVE` and `BYTE_1`/`BYTE_0`, the instruction copies byte 0 of the selected source into byte 1 of the selected destination while keeping the destination's other bytes — so when those are the same register, the "previous value" the preserve keeps is the value the same instruction is reading. Treating it as a no-op, or reading `prev` after the write, changes exactly those four and leaves the other twelve identical. The PR says so in the docstring and the two mutations confirm the fixture can tell the difference. ### What I would add The docstring says the check covers "all 16 index pairs, including the four in-place writes". The 16 come from `s_and_b64 s[84:85], s[84:85], 0x30003` with `m0` selecting both offsets, and the exported bank is four words — so the *pairs* are enumerated by `m0`, not by 16 separate programs. Worth one sentence saying which enumeration is meant (16 `m0` values in one draw), because a reader may expect 16 draws. ### Note on the modes `draw-sdwa-movrel` now carries this check as an extra function call at the end rather than a new mode. That is fine and keeps the runtime down, but it does mean the new coverage is invisible in `ctest -N`; if you want it separately skippable, a `SKIP_RETURN_CODE 77` mode of its own would show up in the test list. AI-assisted; both runs and both mutations were executed locally on Windows 11 build 26300.9974, WARP and the installed GPU.
RavenCurseBurg commented 2026-11-25 19:04:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T18:40:23Z.


The enumeration is documented in 11018033. One shader is compiled and passed to one renderer process. Each of the 16 source/destination pairs gets its own draw and constant-buffer value, with m0 = (dst << 16) | src. A seventeenth draw repeats (3, 3) against the unchanged-bank reference and must mismatch. The existing draw-sdwa-movrel entry ran successfully at this revision on Intel UHD 770, RTX 4060 and WARP. Thanks for the independent RTX 5080 Laptop results.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171233760 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2472#issuecomment-7171233760). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T18:40:23Z. --- The enumeration is documented in 11018033. One shader is compiled and passed to one renderer process. Each of the 16 source/destination pairs gets its own draw and constant-buffer value, with `m0 = (dst << 16) | src`. A seventeenth draw repeats (3, 3) against the unchanged-bank reference and must mismatch. The existing `draw-sdwa-movrel` entry ran successfully at this revision on Intel UHD 770, RTX 4060 and WARP. Thanks for the independent RTX 5080 Laptop results.
upstream-sync closed this pull request 2026-11-25 20:04:21 +00:00
MasterDomino commented 2026-11-25 20:04:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:08:33Z.

Review: APPROVED


Approved at head 11018033. The change is test-only: tests/pixel_aot_check.py gets the same-bank v_movrelsd_2_b32_sdwa overlap draw, plus a docs/experiments.md entry. This adds an AMD adapter and a local run of the description's key mutant to @ChazY11's WARP and RTX 5080 Laptop run.

Environment

Windows 11 build 26300, --preset dev, offscreen_check built at 11018033, and DXC from SDK 10.0.26100.

Commands executed

ctest --preset dev --no-tests=error -R 'sdwa_movrel' -V
  • pixel_aot_sdwa_movrel_hardware (AMD Radeon RX 9070 XT, 1002:7550, driver 32.0.32029.2010) and _warp (10.0.26100.9818): both pass, with no skips.
  • The five existing controls each report pixel mismatch, as required: source selection dropped, PRESERVE changed to PAD, dynamic m0 ignored, wrong byte, and no sext.
  • The new 16-pair overlap batch passes, and its unchanged-bank control mismatches.

Negative control

I mutated the dynamic m0 branch of the SDWA movrel lowering in tools/pixel_aot.py, then ran main's copy of the check and this PR's on both adapters:

mutant main check this PR's check
high source-index bit dropped only when the banks share a base (m0_mask & (0x1 if src_base == dst_base else 0x3ff), and the same in the emitted offset) passes on both adapters fails on both adapters: Expected ['pass', … 'mismatch'], got […]
source and destination offset fields swapped fails fails
source mask limited to bit 0 for all banks fails fails

The first row is the gap the description reports: only the new overlap draw catches it, both on the RX 9070 XT and on WARP. All mutants were reverted, and the clean run passes 2/2.

Merge checks: the branch merges cleanly with current main. Required CI passed at this head. The /O2 and coverage skips come from explicit workflow conditions. There are no review threads.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063426920 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2472#pullrequestreview-6063426920). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T19:08:33Z. **Review:** APPROVED --- Approved at head `11018033`. The change is test-only: `tests/pixel_aot_check.py` gets the same-bank `v_movrelsd_2_b32_sdwa` overlap draw, plus a `docs/experiments.md` entry. This adds an AMD adapter and a local run of the description's key mutant to @ChazY11's WARP and RTX 5080 Laptop run. ### Environment Windows 11 build 26300, `--preset dev`, `offscreen_check` built at `11018033`, and DXC from SDK 10.0.26100. ### Commands executed ```powershell ctest --preset dev --no-tests=error -R 'sdwa_movrel' -V ``` - **`pixel_aot_sdwa_movrel_hardware`** (**AMD Radeon RX 9070 XT**, 1002:7550, driver 32.0.32029.2010) **and `_warp`** (10.0.26100.9818): both pass, with no skips. - **The five existing controls** each report `pixel mismatch, as required`: source selection dropped, PRESERVE changed to PAD, dynamic m0 ignored, wrong byte, and no sext. - **The new 16-pair overlap batch** passes, and its unchanged-bank control mismatches. ### Negative control I mutated the dynamic `m0` branch of the SDWA movrel lowering in `tools/pixel_aot.py`, then ran `main`'s copy of the check and this PR's on both adapters: | mutant | `main` check | this PR's check | |---|---|---| | **high source-index bit dropped only when the banks share a base** (`m0_mask & (0x1 if src_base == dst_base else 0x3ff)`, and the same in the emitted offset) | **passes on both adapters** | **fails on both adapters**: `Expected ['pass', … 'mismatch'], got […]` | | source and destination offset fields swapped | fails | fails | | source mask limited to bit 0 for all banks | fails | fails | The first row is the gap the description reports: only the new overlap draw catches it, both on the RX 9070 XT and on WARP. All mutants were reverted, and the clean run passes 2/2. Merge checks: the branch merges cleanly with current `main`. Required CI passed at this head. The `/O2` and coverage skips come from explicit workflow conditions. There are no review threads. 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!2464
No description provided.