shader: lower DPP16 row_shl, row_shr and row_ror in direct compute #3010

Merged
Leyukaka merged 1 commit from upstream-pr/3010 into main 2026-11-27 12:11:45 +00:00
Leyukaka commented 2026-11-27 04:55:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T04:55:37Z.


Fixes #3008. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl): direct compute lowered DPP16 quad_perm and the two mirrors only. It now also lowers row_shl:N, row_shr:N and row_ror:N for N = 1..15 (0x101..0x10f, 0x111..0x11f, 0x121..0x12f), with full row and bank masks.

  • Source lane, inside the lane's 16-lane row: row_shl:N reads r + N, row_shr:N reads r - N, row_ror:N reads (r - N) mod 16. A row never crosses a physical wave32, so a split guest wave64 needs no exchange.
  • A source is usable when it is inside the row and either FI is set or the source lane is active in guest EXEC. For an unusable source, BOUND_CTRL supplies 0; otherwise the destination keeps its old value. lower_dpp used to apply that rule only when FI was clear. It now also covers an out-of-row source with FI set, which the measured row_shr:1 form uses. quad_perm and the mirrors keep their behavior, since their source is always in range.
  • Row operations need a thread count divisible by 16.
  • These stay refused: row_share, row_xmask, the pre-GFX10 controls (0x130..0x13c, 0x142, 0x143) and partial masks.
  • native_dpp_quad_check.py used row_shl:1 as its unsupported-control case. It now uses row_share:0.

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

  • native_dpp_row_hardware passed. 16 programs ran in two 64-thread groups, with guest lanes 1 and 8 of each wave32 inactive, and all 2,064 output words matched a CPU reference, sentinels included. The programs are:
    • v_mov_b32_dpp with row_shl, row_shr and row_ror by 1 and 15, each with and without BOUND_CTRL;
    • v_mov_b32_dpp row_shr:1 with FI and BOUND_CTRL;
    • the measured forms: v_add_nc_u32_dpp row_shr:1 with FI, and v_add_f32_dpp/v_min_f32_dpp row_ror:8 with BOUND_CTRL.
  • native_dpp_row_controls passed. One valid shift compiles, and four controls are refused: row_share:0, control 0x142, row mask 0x7 and a 24-thread group.
  • The 7 native_dpp*, native_lane*, native_wave* and native_readlane* tests pass.
  • Not covered: a split guest wave64. The fixture runs wave32 requests, so the claim that rows need no exchange there rests on construction (a row never crosses a physical wave32).

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

  • rotating left instead of right, which fails the shift 1 and 15 cases (row_ror:8 is its own inverse);
  • treating an out-of-row source as usable;
  • ignoring BOUND_CTRL.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.

  • Of 2,689 compute requests, 80 stopped first at "unsupported DPP lane selection": 62 with row_ror:8, 18 with row_shr:1.
  • With this change, the compiled count goes from 392 to 393, and none that compiled before stops. The requests of one start-up run go from 405 to 406; that one request was not dispatched in the run.
  • Of the other 79, 32 now stop first at v_permlane16_b32/v_permlanex16_b32 and 25 at "SDWA or DPP vector operands". So this mostly removes the first blocker in front of those requests; it completes one by itself.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5521423886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3010). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T04:55:37Z. --- Fixes #3008. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`): direct compute lowered DPP16 `quad_perm` and the two mirrors only. It now also lowers `row_shl:N`, `row_shr:N` and `row_ror:N` for N = 1..15 (`0x101..0x10f`, `0x111..0x11f`, `0x121..0x12f`), with full row and bank masks. - Source lane, inside the lane's 16-lane row: `row_shl:N` reads `r + N`, `row_shr:N` reads `r - N`, `row_ror:N` reads `(r - N) mod 16`. A row never crosses a physical wave32, so a split guest wave64 needs no exchange. - A source is usable when it is inside the row and either FI is set or the source lane is active in guest EXEC. For an unusable source, BOUND_CTRL supplies 0; otherwise the destination keeps its old value. `lower_dpp` used to apply that rule only when FI was clear. It now also covers an out-of-row source with FI set, which the measured `row_shr:1` form uses. `quad_perm` and the mirrors keep their behavior, since their source is always in range. - Row operations need a thread count divisible by 16. - These stay refused: `row_share`, `row_xmask`, the pre-GFX10 controls (`0x130..0x13c`, `0x142`, `0x143`) and partial masks. - `native_dpp_quad_check.py` used `row_shl:1` as its unsupported-control case. It now uses `row_share:0`. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `cpp-migration` `999e17cd` plus this commit. - `native_dpp_row_hardware` passed. 16 programs ran in two 64-thread groups, with guest lanes 1 and 8 of each wave32 inactive, and all 2,064 output words matched a CPU reference, sentinels included. The programs are: - `v_mov_b32_dpp` with `row_shl`, `row_shr` and `row_ror` by 1 and 15, each with and without BOUND_CTRL; - `v_mov_b32_dpp row_shr:1` with FI and BOUND_CTRL; - the measured forms: `v_add_nc_u32_dpp row_shr:1` with FI, and `v_add_f32_dpp`/`v_min_f32_dpp row_ror:8` with BOUND_CTRL. - `native_dpp_row_controls` passed. One valid shift compiles, and four controls are refused: `row_share:0`, control `0x142`, row mask `0x7` and a 24-thread group. - The 7 `native_dpp*`, `native_lane*`, `native_wave*` and `native_readlane*` tests pass. - Not covered: a split guest wave64. The fixture runs wave32 requests, so the claim that rows need no exchange there rests on construction (a row never crosses a physical wave32). **Mutation checks**, run by hand; each fails the hardware check: - rotating left instead of right, which fails the shift 1 and 15 cases (`row_ror:8` is its own inverse); - treating an out-of-row source as usable; - ignoring BOUND_CTRL. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`. - Of 2,689 compute requests, 80 stopped first at "unsupported DPP lane selection": 62 with `row_ror:8`, 18 with `row_shr:1`. - With this change, the compiled count goes from 392 to 393, and none that compiled before stops. The requests of one start-up run go from 405 to 406; that one request was not dispatched in the run. - Of the other 79, 32 now stop first at `v_permlane16_b32`/`v_permlanex16_b32` and 25 at "SDWA or DPP vector operands". So this mostly removes the first blocker in front of those requests; it completes one by itself. AI-assisted.
KelboLive commented 2026-11-27 05:16:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:16:49Z.

Review: COMMENTED


PR #3010 by @Leyukaka — shader: lower DPP16 row_shl, row_shr and row_ror in direct compute

What works

  • New DppRow struct with DppRowOp enum cleanly separates row ops from quad_perm and mirrors
  • dpp_row() method correctly detects 0x101..0x10f (shl), 0x111..0x11f (shr), 0x121..0x12f (ror)
  • group_size=16 for row ops is correct (rows never cross physical wave32 boundaries)
  • Source usability logic: FI or EXEC-active source is usable; BOUND_CTRL zero for unusable
  • Good refusal checks: 16-thread divisibility, unsupported controls, partial masks, row_share, row_xmask
  • Test suite covers shift amounts 1 and 15 (min/max), BC and no-BC, FI with arithmetic ops
  • Measured forms from real captures (62 row_ror:8, 18 row_shr:1) justify the addition
  • Mutation checks confirm correctness: wrong rotation direction, out-of-row usable, BC ignored all fail
  • Updated native_dpp_quad_check.py correctly replaced row_shl:1 with row_share:0
  • Documentation in native-dpp-row.md is comprehensive and consistent with project style
  • Error message updated from quad permutation to mask is appropriately generic

Issues

  • The dpp_row() switch uses (control & ~15u) but the pattern mask extraction already has the pattern bits (0x100..0x12f range). The amount is correctly extracted with (control & 15), and the switch correctly filters patterns 0x100, 0x110, 0x120 with amount nonzero — but control value 0x100 has amount=0 which would return None. The pattern 0x100..0x10f includes 0x100 (shl:0) which should be a no-op or invalid. The check if (amount) correctly skips this, which is right behavior.
  • For row_ror, the peer calculation uses sub(row_lane, amount) without explicit wrapping — the peer must wrap as ((row_lane - amount) + 16) % 16 for negative results. The code truncation means I cannot see the full wrapping implementation in lower_dpp(). Please verify this wraps correctly in the IR, since lane arithmetic in HLSL/DXIL does not auto-wrap.
  • The mirror_mask() function was not updated alongside the dpp_row() addition. While mirrors and row ops currently have disjoint control values, adding a dpp_row() fallback in mirror_mask() would future-proof the pattern classification.

Recommendations

  • Consider adding a debug-mode assertion: group_size must evenly divide threads before lowering, to catch malformed pipeline configs.
  • In the hardware test native_dpp_row_hardware, consider adding a wave64 partial mask (e.g., bank=1 only) to exercise the 16-lane row inside a wave64 subgroup, even if the PR says wave64 exchange is not needed.
  • Add a compile-time check: static_assert(dpp_control_max <= 0x12f) to ensure no row op values are silently accepted beyond the supported range.

Overall

Solid extension to the direct compute DPP support. The DppRow struct is clean, the source-usability tracking follows the existing lower_dpp pattern, and the mutation checks give confidence. The key item to verify before merge is the ror wrapping behavior in the IR generation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083789397 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3010#pullrequestreview-6083789397). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T05:16:49Z. **Review:** COMMENTED --- PR #3010 by @Leyukaka — shader: lower DPP16 row_shl, row_shr and row_ror in direct compute ## What works - New DppRow struct with DppRowOp enum cleanly separates row ops from quad_perm and mirrors - dpp_row() method correctly detects 0x101..0x10f (shl), 0x111..0x11f (shr), 0x121..0x12f (ror) - group_size=16 for row ops is correct (rows never cross physical wave32 boundaries) - Source usability logic: FI or EXEC-active source is usable; BOUND_CTRL zero for unusable - Good refusal checks: 16-thread divisibility, unsupported controls, partial masks, row_share, row_xmask - Test suite covers shift amounts 1 and 15 (min/max), BC and no-BC, FI with arithmetic ops - Measured forms from real captures (62 row_ror:8, 18 row_shr:1) justify the addition - Mutation checks confirm correctness: wrong rotation direction, out-of-row usable, BC ignored all fail - Updated native_dpp_quad_check.py correctly replaced row_shl:1 with row_share:0 - Documentation in native-dpp-row.md is comprehensive and consistent with project style - Error message updated from quad permutation to mask is appropriately generic ## Issues - The dpp_row() switch uses (control & ~15u) but the pattern mask extraction already has the pattern bits (0x100..0x12f range). The amount is correctly extracted with (control & 15), and the switch correctly filters patterns 0x100, 0x110, 0x120 with amount nonzero — but control value 0x100 has amount=0 which would return None. The pattern 0x100..0x10f includes 0x100 (shl:0) which should be a no-op or invalid. The check if (amount) correctly skips this, which is right behavior. - For row_ror, the peer calculation uses sub(row_lane, amount) without explicit wrapping — the peer must wrap as ((row_lane - amount) + 16) % 16 for negative results. The code truncation means I cannot see the full wrapping implementation in lower_dpp(). Please verify this wraps correctly in the IR, since lane arithmetic in HLSL/DXIL does not auto-wrap. - The mirror_mask() function was not updated alongside the dpp_row() addition. While mirrors and row ops currently have disjoint control values, adding a dpp_row() fallback in mirror_mask() would future-proof the pattern classification. ## Recommendations - Consider adding a debug-mode assertion: group_size must evenly divide threads before lowering, to catch malformed pipeline configs. - In the hardware test native_dpp_row_hardware, consider adding a wave64 partial mask (e.g., bank=1 only) to exercise the 16-lane row inside a wave64 subgroup, even if the PR says wave64 exchange is not needed. - Add a compile-time check: static_assert(dpp_control_max <= 0x12f) to ensure no row op values are silently accepted beyond the supported range. ## Overall Solid extension to the direct compute DPP support. The DppRow struct is clean, the source-usability tracking follows the existing lower_dpp pattern, and the mutation checks give confidence. The key item to verify before merge is the ror wrapping behavior in the IR generation.
KelboLive commented 2026-11-27 05:32:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:32:45Z.

Review: COMMENTED


PR #3010 by @Leyukaka -- shader: lower DPP16 row_shl, row_shr and row_ror in direct compute

What works

  • Clean, focused extension of the existing DPP16 quad_perm lowering to row shifts and rotates
  • The dpp_row() helper cleanly extracts op type and amount from the control code using bitwise logic
  • Correct group_size check: 16 for row ops vs. 4/8/16 for quad/mirror ops
  • Row lane peer calculation is correct: add for shift, subtract for row_ror, with modulo via row_lane arithmetic
  • Good test coverage in native_dpp_row_check.py with 14 cases including boundary amounts, FI, BOUND_CTRL, and sparse EXEC
  • Experiment documentation is thorough and includes three intentional mutant failures

Issues

  • The peer calculation uses shl ? "sub" : "add" in the row op case, which seems inverted -- for row_shl we want source = lane + amount (add), and for row_shr we want source = lane - amount (sub). The current code uses shl ? "add" : "sub" but the comment says shl toggles between them. Verify this is correct: row_shl reads from r+N (add), row_shr reads from r-N (sub), row_ror reads from (r-N)%16 (sub with wrap)
  • The row_ror case uses the same peer formula with sub, but doesn't handle the modulo explicitly -- the % is implicit in the unsigned ring buffer layout, but a comment clarifying this would help future maintainers

Recommendations

  • The refusal of partial row/bank masks is correct for safety
  • Consider filing a follow-up for row_broadcast support (refused by name today)

Overall

A well-scoped, well-tested addition. The row shift/rotate lowering follows the same patterns as the existing quad_perm path. No blocking issues.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6083894110 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3010#pullrequestreview-6083894110). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T05:32:45Z. **Review:** COMMENTED --- PR #3010 by @Leyukaka -- shader: lower DPP16 row_shl, row_shr and row_ror in direct compute ## What works - Clean, focused extension of the existing DPP16 quad_perm lowering to row shifts and rotates - The dpp_row() helper cleanly extracts op type and amount from the control code using bitwise logic - Correct group_size check: 16 for row ops vs. 4/8/16 for quad/mirror ops - Row lane peer calculation is correct: add for shift, subtract for row_ror, with modulo via row_lane arithmetic - Good test coverage in native_dpp_row_check.py with 14 cases including boundary amounts, FI, BOUND_CTRL, and sparse EXEC - Experiment documentation is thorough and includes three intentional mutant failures ## Issues - The peer calculation uses `shl ? "sub" : "add"` in the row op case, which seems inverted -- for row_shl we want source = lane + amount (add), and for row_shr we want source = lane - amount (sub). The current code uses `shl ? "add" : "sub"` but the comment says `shl` toggles between them. Verify this is correct: row_shl reads from r+N (add), row_shr reads from r-N (sub), row_ror reads from (r-N)%16 (sub with wrap) - The `row_ror` case uses the same `peer` formula with sub, but doesn't handle the modulo explicitly -- the `%` is implicit in the unsigned ring buffer layout, but a comment clarifying this would help future maintainers ## Recommendations - The refusal of partial row/bank masks is correct for safety - Consider filing a follow-up for row_broadcast support (refused by name today) ## Overall A well-scoped, well-tested addition. The row shift/rotate lowering follows the same patterns as the existing quad_perm path. No blocking issues.
SimSalabimse commented 2026-11-27 11:47:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-27T11:47:36Z.


Second-site hardware result for this PR at 7325dd17 (base 999e17cd on cpp-migration). No game files involved.

Environment (the Windows test PC): RTX 4070 Ti, driver 621.35, Windows 11 25H2 (build 26200), MSVC 19.44, cmake --preset dev. Configure and build exit 0.

  • ctest --preset dev --no-tests=error -j 1 -R dpp -E "startup_audio_output|startup_audio_pacing|startup_audio_provider", run twice: 29 of 29 passed both times, exit 0, no skips. This includes the PR's own native_dpp_row_controls and native_dpp_row_hardware (about 5 s on hardware), plus native_dpp_quad_*, native_dpp_mirror_hardware and the compute_store_aot_dpp_row_shr_* pair.
  • -R "^native_" regression check: 74 tests, 70 passed, 3 WARP-only skips (exit 77), 1 failure: native_cvt_pk_u8_hardware, which is not touched by this PR. It also fails on cpp-migration at f6cdee10 and the current tip, so it is not caused by the DPP16 change.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7217481061 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3010#issuecomment-7217481061). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-27T11:47:36Z. --- Second-site hardware result for this PR at `7325dd17` (base `999e17cd` on `cpp-migration`). No game files involved. Environment (the Windows test PC): RTX 4070 Ti, driver 621.35, Windows 11 25H2 (build 26200), MSVC 19.44, `cmake --preset dev`. Configure and build exit 0. - `ctest --preset dev --no-tests=error -j 1 -R dpp -E "startup_audio_output|startup_audio_pacing|startup_audio_provider"`, run twice: 29 of 29 passed both times, exit 0, no skips. This includes the PR's own `native_dpp_row_controls` and `native_dpp_row_hardware` (about 5 s on hardware), plus `native_dpp_quad_*`, `native_dpp_mirror_hardware` and the `compute_store_aot_dpp_row_shr_*` pair. - `-R "^native_"` regression check: 74 tests, 70 passed, 3 WARP-only skips (exit 77), 1 failure: `native_cvt_pk_u8_hardware`, which is not touched by this PR. It also fails on `cpp-migration` at `f6cdee10` and the current tip, so it is not caused by the DPP16 change. AI-Assisted
R0Y00 commented 2026-11-27 12:11:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T12:11:29Z.

Review: APPROVED


Reviewed 7325dd17 after retargeting to main, with #3053 applied (tested tree 91cc13b3). ctest --preset <dev|release> --no-tests=error -V -R '^(native_dpp_.*|native_sdwa_f16_.*|native_bitscan_(controls|hardware))$' gave 9/9 passes in each preset. The 16 native programs matched 128 output words each and their guards on RTX, including sparse EXEC, FI, out-of-row BOUND_CTRL and wrapping rotates. The prior quad and mirror fixtures still pass. Both compute_store_aot_dpp_row_shr_(warp|hardware) entries also passed in both presets and rejected their deliberate cross-row and zero controls. Windows 11 26200.9974, SDK 10.0.26100, RTX 4060 Laptop driver 32.0.16.1656 and WARP 10.0.26100.9818. Native compute replay runs without the debug layer. The offscreen and AOT results had zero debug errors/warnings. Hosted Windows, Linux Python and gfx1013 passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6087923152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3010#pullrequestreview-6087923152). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T12:11:29Z. **Review:** APPROVED --- Reviewed `7325dd17` after retargeting to `main`, with #3053 applied (tested tree `91cc13b3`). `ctest --preset <dev|release> --no-tests=error -V -R '^(native_dpp_.*|native_sdwa_f16_.*|native_bitscan_(controls|hardware))$'` gave 9/9 passes in each preset. The 16 native programs matched 128 output words each and their guards on RTX, including sparse EXEC, FI, out-of-row BOUND_CTRL and wrapping rotates. The prior quad and mirror fixtures still pass. Both `compute_store_aot_dpp_row_shr_(warp|hardware)` entries also passed in both presets and rejected their deliberate cross-row and zero controls. Windows 11 26200.9974, SDK 10.0.26100, RTX 4060 Laptop driver 32.0.16.1656 and WARP 10.0.26100.9818. Native compute replay runs without the debug layer. The offscreen and AOT results had zero debug errors/warnings. Hosted Windows, Linux Python and gfx1013 passed.
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!3010
No description provided.