shader: lower DPP16 quad_perm in the direct C++ compute path #2937

Merged
Leyukaka merged 1 commit from upstream-pr/2937 into cpp-migration 2026-11-26 22:40:12 +00:00
Leyukaka commented 2026-11-26 22:18:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T22:18:06Z.


Fixes #2936 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch cpp-migration.

Change:

  • src/gfx1013_compute_native.cpp: the DPP16 decoder accepted pattern values 0-255 (quad_perm) only for graphics. Compute now accepts them as well. Patterns above 255 that are not row mirrors stay refused ("unsupported DPP lane selection").
  • src/gfx1013_direct_compute.inl: mirror() becomes lower_dpp() and handles both forms.
    • Every instruction that carries a DPP16 control is routed to it.
    • For quad_perm, the source is read with waveReadLaneAt from lane (lane & ~3) | ((pattern >> 2 * (lane & 3)) & 3).
    • The row mirror's rules are kept as they were:
      • a disabled source lane gives 0 under bound_ctrl, keeps the old destination otherwise, and is read anyway under fetch-inactive;
      • the operand-modifier rules;
      • the two-source ALU limit.
    • A thread count that is not a multiple of four is refused.
  • tests/native_dpp_quad_check.py, tests/cmake/native_dpp_quad.cmake, docs/experiments/native-dpp-quad-compute.md and a docs/experiments.md entry.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on e97c5c7c plus this commit.

  • native_dpp_quad_hardware passed. It covers 8 source-built compute programs, two groups of 32 lanes each, with guard words checked, against an independent CPU model of lanes, EXEC and the DPP rules:
    • v_or_b32 and v_add_f32 with quad_perm:[1,0,3,2];
    • v_subrev_f32 with [0,0,0,0];
    • the identity [0,1,2,3];
    • the rotation [1,2,3,0];
    • a disabled source lane under bound_ctrl, under the default (keep the old value) and under fetch-inactive.
  • native_dpp_quad_controls passed. [1,0,3,2] compiles, while row_shl:1 and a 30-thread group are refused with their messages.
  • native_dpp_mirror_hardware still passes.

Mutation checks, run by hand; each fails the hardware test:

  • reading the permutation in reversed lane order: fails at the first case, or swap;
  • ignoring bound_ctrl: the "disabled source, zero" case fails.

Measured on a local capture of 2,689 compute requests, with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests (counts and instruction shape only). The request reader was locally patched to main's 28cs revision, which is tracked in #2933.

  • 705 requests stopped at "unsupported DPP lane selection" before this change. After it, 625 of them get past it.
  • The remaining 80 stop at a row form (row_ror:8, row_shr:1), which stays refused: 43 at the same instruction as before, and 37 after getting past an earlier quad_perm.
  • The 625 now stop next at v_readlane_b32 with vcc_lo as its destination ("invalid scalar lane read destination"), so the compiled total is unchanged at 243.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5517909460 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2937). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T22:18:06Z. --- Fixes #2936 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch `cpp-migration`. **Change:** - `src/gfx1013_compute_native.cpp`: the DPP16 decoder accepted pattern values 0-255 (`quad_perm`) only for graphics. Compute now accepts them as well. Patterns above 255 that are not row mirrors stay refused ("unsupported DPP lane selection"). - `src/gfx1013_direct_compute.inl`: `mirror()` becomes `lower_dpp()` and handles both forms. - Every instruction that carries a DPP16 control is routed to it. - For `quad_perm`, the source is read with `waveReadLaneAt` from lane `(lane & ~3) | ((pattern >> 2 * (lane & 3)) & 3)`. - The row mirror's rules are kept as they were: - a disabled source lane gives 0 under `bound_ctrl`, keeps the old destination otherwise, and is read anyway under fetch-inactive; - the operand-modifier rules; - the two-source ALU limit. - A thread count that is not a multiple of four is refused. - `tests/native_dpp_quad_check.py`, `tests/cmake/native_dpp_quad.cmake`, `docs/experiments/native-dpp-quad-compute.md` and a `docs/experiments.md` entry. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `e97c5c7c` plus this commit. - `native_dpp_quad_hardware` passed. It covers 8 source-built compute programs, two groups of 32 lanes each, with guard words checked, against an independent CPU model of lanes, EXEC and the DPP rules: - `v_or_b32` and `v_add_f32` with `quad_perm:[1,0,3,2]`; - `v_subrev_f32` with `[0,0,0,0]`; - the identity `[0,1,2,3]`; - the rotation `[1,2,3,0]`; - a disabled source lane under `bound_ctrl`, under the default (keep the old value) and under fetch-inactive. - `native_dpp_quad_controls` passed. `[1,0,3,2]` compiles, while `row_shl:1` and a 30-thread group are refused with their messages. - `native_dpp_mirror_hardware` still passes. **Mutation checks**, run by hand; each fails the hardware test: - reading the permutation in reversed lane order: fails at the first case, `or swap`; - ignoring `bound_ctrl`: the "disabled source, zero" case fails. **Measured on a local capture** of 2,689 compute requests, with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` (counts and instruction shape only). The request reader was locally patched to main's `28cs` revision, which is tracked in #2933. - 705 requests stopped at "unsupported DPP lane selection" before this change. After it, 625 of them get past it. - The remaining 80 stop at a row form (`row_ror:8`, `row_shr:1`), which stays refused: 43 at the same instruction as before, and 37 after getting past an earlier `quad_perm`. - The 625 now stop next at `v_readlane_b32` with `vcc_lo` as its destination ("invalid scalar lane read destination"), so the compiled total is unchanged at 243. AI-assisted.
MasterDomino commented 2026-11-26 22:40:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T22:40:09Z.

Review: APPROVED


Review of head 1053cd71, tested merged onto cpp-migration 7beb331d (after #2939). It merges cleanly. Approving and merging.

Code:

  • The decoder change admits patterns 0–255 in compute and still refuses everything above 255 that is not a row mirror.
  • lower_dpp() computes the source lane as (lane & ~3) | ((pattern >> 2*(lane & 3)) & 3).
  • It keeps the mirror's disabled-source, modifier and two-source rules.
  • It refuses thread counts that are not a multiple of 4.
  • The dispatch now keys on i.dpp_control having a value, so quad_perm:[0,0,0,0] (pattern 0) still takes the DPP path.

Run on AMD, which these tests had not seen before: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release, debug layer off. ctest --preset release --no-tests=error -R '^native_' gives 34 tests, 33 passed and 1 skipped (77, native_comparison_pso_warp), including native_dpp_quad_hardware, native_dpp_quad_controls and native_dpp_mirror_hardware.

Mutation: I made the source lane read the permutation in reversed lane order (quad_lane ^ 3) and rebuilt. native_dpp_quad_hardware fails with a lane mismatch, and the mirror and control tests still pass. After restoring and rebuilding, everything passes again.

Nit, not blocking: docs/experiments.md gains a 6-line pointer section right under the line saying new notes go in docs/experiments/<topic>.md. The topic file alone would follow that convention and avoid edit conflicts at the top of the file. docs_links_check passes (33 files, 548 links).

I will close #2936 by hand after the merge, since the base is not the default branch.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6081193226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2937#pullrequestreview-6081193226). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T22:40:09Z. **Review:** APPROVED --- Review of head `1053cd71`, tested merged onto `cpp-migration` `7beb331d` (after #2939). It merges cleanly. Approving and merging. **Code:** - The decoder change admits patterns 0–255 in compute and still refuses everything above 255 that is not a row mirror. - `lower_dpp()` computes the source lane as `(lane & ~3) | ((pattern >> 2*(lane & 3)) & 3)`. - It keeps the mirror's disabled-source, modifier and two-source rules. - It refuses thread counts that are not a multiple of 4. - The dispatch now keys on `i.dpp_control` having a value, so `quad_perm:[0,0,0,0]` (pattern 0) still takes the DPP path. **Run on AMD**, which these tests had not seen before: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release, debug layer off. `ctest --preset release --no-tests=error -R '^native_'` gives 34 tests, 33 passed and 1 skipped (77, `native_comparison_pso_warp`), including `native_dpp_quad_hardware`, `native_dpp_quad_controls` and `native_dpp_mirror_hardware`. **Mutation:** I made the source lane read the permutation in reversed lane order (`quad_lane ^ 3`) and rebuilt. `native_dpp_quad_hardware` **fails** with a lane mismatch, and the mirror and control tests still pass. After restoring and rebuilding, everything passes again. **Nit, not blocking:** `docs/experiments.md` gains a 6-line pointer section right under the line saying new notes go in `docs/experiments/<topic>.md`. The topic file alone would follow that convention and avoid edit conflicts at the top of the file. `docs_links_check` passes (33 files, 548 links). I will close #2936 by hand after the merge, since the base is not the default branch. AI-assisted; the commands above were run locally.
thepatrickworld commented 2026-11-26 22:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T22:48:43Z.


Post-merge receipt on 1053cd717e (the head this was merged from): a per-case mutation map for the eight quad_perm cases, and a negative control on the decoder line. Not a code change; measurements only.

Environment

  • Windows 10.0.26200.9974, MSVC cl 19.44.35230 with BuildTools 14.44.35207, DXC 1.9.2602.17 from SDK 10.0.26100.0
  • AMD Radeon RX 9070 XT, vendor 1002 device 7550, driver 32.0.32029.2010
  • preset dev, debug layer not installed, so there is no validation output
  • head 1053cd717efcfb69f60d1f5902511be0c2fce732, git status --porcelain --untracked-files=no empty, src/gfx1013_direct_compute.inl sha256 a77267b2e0597abbe88d494eaba3bbcd20b2bf23c88e6073bbc6c4d943a30be6 (CRLF worktree copy; the LF blob of the same revision is 80ee9c65…)

Which adapter these entries actually use

tests/native_store_replay.cpp:45 creates its device with D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_12_0, …) and prints no adapter line, so "on hardware" is otherwise unobservable for this fixture. A throwaway probe (not part of the repo; ID3D12Device::GetAdapterLuid() matched against an IDXGIFactory6 enumeration) says which adapter the null argument resolves to on this machine:

enum 0: AMD Radeon RX 9070 XT | vendor=1002 device=7550 | flags=0000 | luid=00000000:0001fe8b
enum 1: AMD Radeon RX 9070 XT | vendor=1002 device=7550 | flags=0000 | luid=00000000:00012605
enum 2: Microsoft Basic Render Driver | vendor=1414 device=008c | flags=0002 | luid=00000000:0001484e
create(nullptr) matches enum 0: AMD Radeon RX 9070 XT vendor=1002 device=7550 flags=0000
shader_model=0066 waveops=1 waves=32..64

The null-adapter path is the card (flags=0000), not the software adapter (flags=0002, Microsoft Basic Render Driver). That is a statement about this run on this machine, not a guarantee about nullptr elsewhere.

Commands

ctest --preset dev --no-tests=error -R "^native_dpp_quad_controls$" -V
ctest --preset dev --no-tests=error -R "^native_dpp_quad_hardware$" -V
ctest --preset dev --no-tests=error -R "^native_dpp_mirror_hardware$" -V

Observed

native_dpp_quad_controls: passed, 0.57 s — unsupported DPP lane selection, DPP quad_perm needs a thread count divisible by four, plus the accepted 0xB1 program.

native_dpp_quad_hardware: passed, 1.81 s, eight replay invocations (0 32 7 4 1 is the replay's binding dump: root parameter, byte offset, view kind, stride, write), eight readbacks of 2,064 words each (8 guard + 64 results + 1,992 guard):

or swap: 64 results and guards matched
add swap: 64 results and guards matched
subrev broadcast: 64 results and guards matched
or identity: 64 results and guards matched
or rotation: 64 results and guards matched
add disabled source, zero: 64 results and guards matched
add disabled source, preserve: 64 results and guards matched
add disabled source, fetch: 64 results and guards matched

native_dpp_mirror_hardware (non-regression for the DPP16 entry that mirror and quad_perm now share): passed, 4.59 s, including PS unsigned min/max, two 32-lane halves and final wave64 reduction matched [3,39,1,255].

Mutation map

Four mutants of lower_dpp, each rebuilt, run, then restored byte-for-byte (file sha256 back to a77267b2…, git status empty, same run green again at 8/8). The first case that fails:

mutant first failing case word actual vs expected
quad_base = lane & ~3 → lane or swap 9 (result lane 1) 82 vs 81
EXEC bit tested on the destination lane, not the source lane add disabled source, zero 8 (result lane 0) 38.0 vs 20.0
disabled source keeps the computed value (preserve dropped) add disabled source, preserve 8 38.0 vs 17.0
fetch-inactive ignored add disabled source, fetch 8 17.0 vs 38.0

The four mutants pass 0, 5, 6 and 7 cases before dying, so each fails first in a different case. The runner stops at the first failure, so a mutant that breaks more than one case only reports the earliest (the EXEC mutant fails zero first; whether it would also fail preserve is not measured here), and no mutant targets the bound-zero branch on its own. The map shows each case is armed; it does not show the branches are disjoint.

Negative control on the decoder line

src/gfx1013_compute_native.cpp:326 reverted to the base expression if (!i.mirror_mask() && (pattern > 255 || !graphics)) makes both entries fail: controls stops on the first case with native compute +0x2c: unsupported DPP lane selection, and the hardware fixture returns 1 on its first replay. After restoring the line, controls return 0 and hardware returns 8/8.

Both entries depend on the added gate: with the base line the direct-compute path refuses every non-mirror pattern, and unsupported DPP lane selection is printed only by that refuse (:327). The four mutants above are what show the comparison is not vacuous.

What runs where (receipt, not a complaint)

GET /commits/1053cd717e/check-runs returns total_count: 0 and /status returns no statuses: no CI ran on this head. The workflow triggers are push, pull_request and workflow_dispatch, with branches: [main] on the first two, while this PR's base is cpp-migration; the pr test preset's include regex names no native_dpp* entry; and the pr build preset's target list builds neither compile_dxil nor native_store_replay. After a future merge into main, the push sweep runs native_dpp_quad_controls and excludes native_dpp_quad_hardware through -E '_hardware$' (windows.yml:494, :614). Both entries stay hand-run on pull requests until the filter, and the two targets, are added there.

Limits

  • One adapter, one driver, one OS build; dev preset only; no debug layer, so nothing here validates API use.
  • One dispatch shape: 32 threads per group with Dispatch(2,1,1), and the same seven-word user block in all eight cases (0, 0, 0, threads | 1 << 16, 1, 0, 0x8A); what varies is the DPP control word and EXEC.
  • The tool does not report the chosen wave size, and the adapter advertises 32..64 lanes, so this run cannot say which one the driver compiled the shader for.
  • The 64 result words are compared against the fixture's own CPU model, so this is a differential against that model, not an independent ISA oracle; the model itself is not audited here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7205005290 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2937#issuecomment-7205005290). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-26T22:48:43Z. --- **Post-merge receipt on `1053cd717e` (the head this was merged from): a per-case mutation map for the eight `quad_perm` cases, and a negative control on the decoder line. Not a code change; measurements only.** ### Environment - Windows `10.0.26200.9974`, MSVC `cl` 19.44.35230 with BuildTools 14.44.35207, DXC 1.9.2602.17 from SDK 10.0.26100.0 - AMD Radeon RX 9070 XT, vendor `1002` device `7550`, driver `32.0.32029.2010` - preset `dev`, debug layer not installed, so there is no validation output - head `1053cd717efcfb69f60d1f5902511be0c2fce732`, `git status --porcelain --untracked-files=no` empty, `src/gfx1013_direct_compute.inl` sha256 `a77267b2e0597abbe88d494eaba3bbcd20b2bf23c88e6073bbc6c4d943a30be6` (CRLF worktree copy; the LF blob of the same revision is `80ee9c65…`) ### Which adapter these entries actually use `tests/native_store_replay.cpp:45` creates its device with `D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_12_0, …)` and prints no adapter line, so "on hardware" is otherwise unobservable for this fixture. A throwaway probe (not part of the repo; `ID3D12Device::GetAdapterLuid()` matched against an `IDXGIFactory6` enumeration) says which adapter the null argument resolves to on this machine: ``` enum 0: AMD Radeon RX 9070 XT | vendor=1002 device=7550 | flags=0000 | luid=00000000:0001fe8b enum 1: AMD Radeon RX 9070 XT | vendor=1002 device=7550 | flags=0000 | luid=00000000:00012605 enum 2: Microsoft Basic Render Driver | vendor=1414 device=008c | flags=0002 | luid=00000000:0001484e create(nullptr) matches enum 0: AMD Radeon RX 9070 XT vendor=1002 device=7550 flags=0000 shader_model=0066 waveops=1 waves=32..64 ``` The null-adapter path is the card (`flags=0000`), not the software adapter (`flags=0002`, `Microsoft Basic Render Driver`). That is a statement about this run on this machine, not a guarantee about `nullptr` elsewhere. ### Commands ``` ctest --preset dev --no-tests=error -R "^native_dpp_quad_controls$" -V ctest --preset dev --no-tests=error -R "^native_dpp_quad_hardware$" -V ctest --preset dev --no-tests=error -R "^native_dpp_mirror_hardware$" -V ``` ### Observed `native_dpp_quad_controls`: passed, 0.57 s — `unsupported DPP lane selection`, `DPP quad_perm needs a thread count divisible by four`, plus the accepted `0xB1` program. `native_dpp_quad_hardware`: passed, 1.81 s, eight replay invocations (`0 32 7 4 1` is the replay's binding dump: root parameter, byte offset, view kind, stride, write), eight readbacks of 2,064 words each (8 guard + 64 results + 1,992 guard): ``` or swap: 64 results and guards matched add swap: 64 results and guards matched subrev broadcast: 64 results and guards matched or identity: 64 results and guards matched or rotation: 64 results and guards matched add disabled source, zero: 64 results and guards matched add disabled source, preserve: 64 results and guards matched add disabled source, fetch: 64 results and guards matched ``` `native_dpp_mirror_hardware` (non-regression for the DPP16 entry that mirror and `quad_perm` now share): passed, 4.59 s, including `PS unsigned min/max, two 32-lane halves and final wave64 reduction matched [3,39,1,255]`. ### Mutation map Four mutants of `lower_dpp`, each rebuilt, run, then restored byte-for-byte (file sha256 back to `a77267b2…`, `git status` empty, same run green again at 8/8). The first case that fails: | mutant | first failing case | word | actual vs expected | |---|---|---|---| | `quad_base = lane & ~3` → `lane` | `or swap` | 9 (result lane 1) | 82 vs 81 | | EXEC bit tested on the destination lane, not the source lane | `add disabled source, zero` | 8 (result lane 0) | 38.0 vs 20.0 | | disabled source keeps the computed value (preserve dropped) | `add disabled source, preserve` | 8 | 38.0 vs 17.0 | | fetch-inactive ignored | `add disabled source, fetch` | 8 | 17.0 vs 38.0 | The four mutants pass 0, 5, 6 and 7 cases before dying, so each fails first in a different case. The runner stops at the first failure, so a mutant that breaks more than one case only reports the earliest (the EXEC mutant fails `zero` first; whether it would also fail `preserve` is not measured here), and no mutant targets the bound-zero branch on its own. The map shows each case is armed; it does not show the branches are disjoint. ### Negative control on the decoder line `src/gfx1013_compute_native.cpp:326` reverted to the base expression `if (!i.mirror_mask() && (pattern > 255 || !graphics))` makes **both** entries fail: controls stops on the first case with `native compute +0x2c: unsupported DPP lane selection`, and the hardware fixture returns 1 on its first replay. After restoring the line, controls return 0 and hardware returns 8/8. Both entries depend on the added gate: with the base line the direct-compute path refuses every non-mirror pattern, and `unsupported DPP lane selection` is printed only by that refuse (`:327`). The four mutants above are what show the comparison is not vacuous. ### What runs where (receipt, not a complaint) `GET /commits/1053cd717e/check-runs` returns `total_count: 0` and `/status` returns no statuses: no CI ran on this head. The workflow triggers are `push`, `pull_request` and `workflow_dispatch`, with `branches: [main]` on the first two, while this PR's base is `cpp-migration`; the `pr` test preset's include regex names no `native_dpp*` entry; and the `pr` build preset's target list builds neither `compile_dxil` nor `native_store_replay`. After a future merge into `main`, the push sweep runs `native_dpp_quad_controls` and excludes `native_dpp_quad_hardware` through `-E '_hardware$'` (`windows.yml:494`, `:614`). Both entries stay hand-run on pull requests until the filter, and the two targets, are added there. ### Limits - One adapter, one driver, one OS build; `dev` preset only; no debug layer, so nothing here validates API use. - One dispatch shape: 32 threads per group with `Dispatch(2,1,1)`, and the same seven-word user block in all eight cases (`0, 0, 0, threads | 1 << 16, 1, 0, 0x8A`); what varies is the DPP control word and EXEC. - The tool does not report the chosen wave size, and the adapter advertises 32..64 lanes, so this run cannot say which one the driver compiled the shader for. - The 64 result words are compared against the fixture's own CPU model, so this is a differential against that model, not an independent ISA oracle; the model itself is not audited here. _AI-assisted._
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!2937
No description provided.