shader: lower compute quad DPP OR #1606

Merged
JustinDCosta merged 3 commits from upstream-pr/1613 into main 2026-11-24 16:33:44 +00:00
JustinDCosta commented 2026-11-24 15:02:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JustinDCosta on 2026-11-24T15:02:44Z.


Scope

Adds a narrow gfx1013 compute translation for v_or_b32_dpp with quad_perm and full row/bank masks. It models the guest's logical 1D quad using SV_GroupThreadID.x and group-shared staging, so it does not assume that Shader Model 6.0 wave lane indices map to group thread IDs. The accepted group layout is 1D with a size divisible by four. Other DPP controls remain unsupported; row shifts, partial masks, non-VGPR operands, multidimensional groups, incomplete quads, and lane-guarded execution are refused.

The source-built fixture uses unique input words across logical lanes and quads. The CPU reference derives source lanes from logical thread IDs, and a probe verifies every logical thread participated. An identity-read mutant must fail.

Refs #1543

Validation

Generated HLSL on WARP

  • Debug and Release passed the source-built D3D12 WARP fixture. All 320 words matched; there were zero debug errors or warnings. The identity-read mutant produced the expected mismatch.

Generated HLSL on NVIDIA hardware

  • Debug and Release passed on the NVIDIA GeForce RTX 3060 Laptop GPU. All 320 words matched; there were zero debug errors or warnings. The identity-read mutant produced the expected mismatch.

gfx1013 LLVM round-trip

  • Ubuntu CI passed the LLVM 15 machine-code input check, including the assembly/disassembly round-trip.
  • This Windows environment does not have LLVM 15 assembler/library tools, so I could not run the round-trip locally.

Other checks

  • Debug and Release builds of offscreen_check — passed.
  • dpp_controls() — passed acceptance/refusal checks, including row_shr, incomplete quads, and multidimensional groups.
  • Platform-independent Python CI checks — passed.
  • python -B tests/docs_links_check.py — passed (349 links).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584780571 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613). Originally posted by [JustinDCosta](https://github.com/JustinDCosta) on 2026-11-24T15:02:44Z. --- ## Scope Adds a narrow gfx1013 compute translation for `v_or_b32_dpp` with `quad_perm` and full row/bank masks. It models the guest's logical 1D quad using `SV_GroupThreadID.x` and group-shared staging, so it does not assume that Shader Model 6.0 wave lane indices map to group thread IDs. The accepted group layout is 1D with a size divisible by four. Other DPP controls remain unsupported; row shifts, partial masks, non-VGPR operands, multidimensional groups, incomplete quads, and lane-guarded execution are refused. The source-built fixture uses unique input words across logical lanes and quads. The CPU reference derives source lanes from logical thread IDs, and a probe verifies every logical thread participated. An identity-read mutant must fail. Refs #1543 ## Validation ### Generated HLSL on WARP - Debug and Release passed the source-built D3D12 WARP fixture. All 320 words matched; there were zero debug errors or warnings. The identity-read mutant produced the expected mismatch. ### Generated HLSL on NVIDIA hardware - Debug and Release passed on the NVIDIA GeForce RTX 3060 Laptop GPU. All 320 words matched; there were zero debug errors or warnings. The identity-read mutant produced the expected mismatch. ### gfx1013 LLVM round-trip - Ubuntu CI passed the LLVM 15 machine-code input check, including the assembly/disassembly round-trip. - This Windows environment does not have LLVM 15 assembler/library tools, so I could not run the round-trip locally. ### Other checks - Debug and Release builds of `offscreen_check` — passed. - `dpp_controls()` — passed acceptance/refusal checks, including `row_shr`, incomplete quads, and multidimensional groups. - Platform-independent Python CI checks — passed. - `python -B tests/docs_links_check.py` — passed (349 links).
R0Y00 commented 2026-11-24 16:03:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:12:47Z.

Review: CHANGES_REQUESTED


The added probe computes expected source lanes from the host WaveGetLaneIndex measured in the same dispatch. It verifies the host shuffle but can pass if the host quad differs from the logical guest quad. The branch accepts multidimensional groups and uses cs_6_0, which does not guarantee mapping quad lanes to SV_GroupThreadID. Please use a proven 1D quad layout (SM 6.6 quad semantics with capability gating) or index a logical 1D quad explicitly, and compute the reference from logical thread IDs. Keep the incomplete-quad, row_shift and identity controls. https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Derivatives.html

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041912736 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613#pullrequestreview-6041912736). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T15:12:47Z. **Review:** CHANGES_REQUESTED --- The added probe computes expected source lanes from the host WaveGetLaneIndex measured in the same dispatch. It verifies the host shuffle but can pass if the host quad differs from the logical guest quad. The branch accepts multidimensional groups and uses cs_6_0, which does not guarantee mapping quad lanes to SV_GroupThreadID. Please use a proven 1D quad layout (SM 6.6 quad semantics with capability gating) or index a logical 1D quad explicitly, and compute the reference from logical thread IDs. Keep the incomplete-quad, row_shift and identity controls. https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Derivatives.html
tedin7 commented 2026-11-24 16:03:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:13:09Z.

Review: COMMENTED


Reviewed 79226e74af0fb986eda2c5eadbf6a1309d8f10a6:

  • Diff & semantics: tools/compute_store_aot.py lowers v_or_b32_dpp with quad_perm:[p0,p1,p2,p3] and row_mask:0xf bank_mask:0xf on gfx1013 (unmasked guard_span is None, VGPR operands <= 255, workgroup size divisible by 4) using WaveGetLaneIndex() and WaveReadLaneAt(..., source_lane). tests/compute_check.cpp (run_compute with dpp_case = true) validates the same-dispatch WaveGetLaneIndex(), WaveGetLaneCount(), WaveActiveBallot(true) quad liveness, and the expected input_word(source_lane) | lane output. tests/compute_store_check.py covers dpp_controls(), dpp_binary() (LLVM round-trip), and draw_dpp including a no-shuffle mutant negative control.
  • Linux (LLVM-19 + hygiene):
    • python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so passed (exit 0).
    • python3 tests/docs_links_check.py (16 Markdown files, 349 links) and python3 tests/bidi_controls_check.py (1262 files) passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): cmake --build --preset dev --target offscreen_check + ctest --preset dev -R '^(compute_store_aot_dpp_warp|compute_store_aot_warp|compute_store_aot_ds_route_warp)$' --parallel 4 --no-tests=error --output-on-failure -> 3/3 passed (6.81s).
    • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check + ctest --preset release -R '^(compute_store_aot_dpp_warp|compute_store_aot_warp|compute_store_aot_ds_route_warp)$' --parallel 4 --no-tests=error --output-on-failure -> 3/3 passed (6.73s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041919474 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613#pullrequestreview-6041919474). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:13:09Z. **Review:** COMMENTED --- Reviewed `79226e74af0fb986eda2c5eadbf6a1309d8f10a6`: - **Diff & semantics**: `tools/compute_store_aot.py` lowers `v_or_b32_dpp` with `quad_perm:[p0,p1,p2,p3]` and `row_mask:0xf bank_mask:0xf` on `gfx1013` (unmasked `guard_span is None`, VGPR operands `<= 255`, workgroup size divisible by 4) using `WaveGetLaneIndex()` and `WaveReadLaneAt(..., source_lane)`. `tests/compute_check.cpp` (`run_compute` with `dpp_case = true`) validates the same-dispatch `WaveGetLaneIndex()`, `WaveGetLaneCount()`, `WaveActiveBallot(true)` quad liveness, and the expected `input_word(source_lane) | lane` output. `tests/compute_store_check.py` covers `dpp_controls()`, `dpp_binary()` (LLVM round-trip), and `draw_dpp` including a no-shuffle mutant negative control. - **Linux (LLVM-19 + hygiene)**: - `python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so` passed (exit 0). - `python3 tests/docs_links_check.py` (16 Markdown files, 349 links) and `python3 tests/bidi_controls_check.py` (1262 files) passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): `cmake --build --preset dev --target offscreen_check` + `ctest --preset dev -R '^(compute_store_aot_dpp_warp|compute_store_aot_warp|compute_store_aot_ds_route_warp)$' --parallel 4 --no-tests=error --output-on-failure` -> **3/3 passed** (`6.81s`). - Release `/O2` (`--preset release`): `cmake --build --preset release --target offscreen_check` + `ctest --preset release -R '^(compute_store_aot_dpp_warp|compute_store_aot_warp|compute_store_aot_ds_route_warp)$' --parallel 4 --no-tests=error --output-on-failure` -> **3/3 passed** (`6.73s`). AI-assisted; commands listed were executed locally.
JustinDCosta commented 2026-11-24 16:03:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JustinDCosta on 2026-11-24T15:40:40Z.


Updated in 5c599b9. The generated HLSL now stages each source word in group-shared memory indexed by SV_GroupThreadID.x, and derives the quad source from that logical 1D thread ID. The translator accepts only 1D groups with X divisible by four, so this path no longer depends on the unspecified Shader Model 6.0 mapping from group IDs to wave lanes.

The fixture CPU reference now derives expected sources from logical thread IDs and verifies all 32 IDs participated. The identity-read mutant fails as expected. WARP and the RTX 3060 passed in Debug and Release; Ubuntu CI passed the gfx1013 LLVM 15 round-trip. row_shr, incomplete quads, partial masks, multidimensional groups, and lane-guarded execution remain refused.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7136427444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613#issuecomment-7136427444). Originally posted by [JustinDCosta](https://github.com/JustinDCosta) on 2026-11-24T15:40:40Z. --- Updated in `5c599b9`. The generated HLSL now stages each source word in group-shared memory indexed by `SV_GroupThreadID.x`, and derives the quad source from that logical 1D thread ID. The translator accepts only 1D groups with X divisible by four, so this path no longer depends on the unspecified Shader Model 6.0 mapping from group IDs to wave lanes. The fixture CPU reference now derives expected sources from logical thread IDs and verifies all 32 IDs participated. The identity-read mutant fails as expected. WARP and the RTX 3060 passed in Debug and Release; Ubuntu CI passed the gfx1013 LLVM 15 round-trip. `row_shr`, incomplete quads, partial masks, multidimensional groups, and lane-guarded execution remain refused.
upstream-sync closed this pull request 2026-11-24 17:01:42 +00:00
R0Y00 commented 2026-11-24 17:01:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:33:27Z.

Review: APPROVED


The logical quad staging, windows readback oracle and updated docs now agree. The integrated Windows Release candidate passed 8/8 on RTX and WARP covering DPP, entry layout, MED3 and full-mask image stores, with no skips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043333426 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613#pullrequestreview-6043333426). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:33:27Z. **Review:** APPROVED --- The logical quad staging, windows readback oracle and updated docs now agree. The integrated Windows Release candidate passed 8/8 on RTX and WARP covering DPP, entry layout, MED3 and full-mask image stores, with no skips.
R0Y00 commented 2026-11-24 17:02:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:28:32Z.


Resolved the CTest and documentation conflicts in d383358b. Both entry-layout and DPP tests are retained, and the description now matches the logical group-thread implementation. Windows Release DPP, RSRC2, full-mask image store and MED3 passed on RTX and WARP, 8/8 with no skips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137723347 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1613#issuecomment-7137723347). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:28:32Z. --- Resolved the CTest and documentation conflicts in d383358b. Both entry-layout and DPP tests are retained, and the description now matches the logical group-thread implementation. Windows Release DPP, RSRC2, full-mask image store and MED3 passed on RTX and WARP, 8/8 with no skips.
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!1606
No description provided.