startup: lower s_wqm exec, exec on a narrowed EXEC as a quad vote #2739

Closed
tedin7 wants to merge 20 commits from upstream-pr/2747 into main
tedin7 commented 2026-11-26 05:41:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:41:58Z.


Part of #1723

What this unblocks: image_sample_b / image_get_lod after s_wqm_b64 exec, exec on a lane-narrowed EXEC (a kill or cmpx followed by a whole-quad restore), which was refused as a lane-EXEC break.
Source: AMD "RDNA 2" Instruction Set Architecture reference guide, SOP1 instruction S_WQM_B64 (whole-quad mode of a mask) and the EXEC / quad rules of the MIMG sample instructions; Microsoft DirectX-Specs, D3D11 functional specification, sample_b and lod.

Stacked on #2736 (this branch contains its commits until that merges; the new work is the last two commits). Builds on #2659.

What changed

  • s_wqm exec, exec on a narrowed EXEC is lowered as exec = x2w_quad_any(exec) ? 1u : 0u;: the guest turns on every lane of a quad with an active lane, which is exactly the vote the branches already use. It is taken only where the quad runs the statement together (uniform_cf holds, no earlier lane-EXEC break, pixel program without a backward branch).
  • Before: recorded as a lane-EXEC break, so the op after it was refused. Other s_wqm forms (other operands) still break and stay refused.
  • A skipped EXEC-branch block that contains an s_wqm is still not voted (the #2736 vector-only gate), so the op is refused there.

Tests

  • New draw fixture wqm (cmpx, then s_wqm_b64 exec, exec, then the subtraction, then the op) in startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py: u1 = 1/8 when the whole quad is back on, 5/8 if s_wqm were a no-op. Mutant "s_wqm as a no-op" must fail the draw. Words reassemble with llvm-mc.
  • The wqm_break refused fixture of #2736 became this accepted fixture.

Verification (Linux only):

python3 -B tests/startup_image_sample_b_flow_check.py                 rc=0
python3 -B tests/startup_image_get_lod_flow_check.py                  rc=0
python3 -B tests/startup_image_sample_b_flow_check.py binary llvm-mc-19   fixtures reassemble
python3 -B tests/startup_image_get_lod_flow_check.py binary llvm-mc-19    fixtures reassemble
for every tests/startup_gfx2hlsl_*_check.py (no arguments)            all rc=0 except the two draw-only checks that need adapter arguments (untouched)

Win2025 WARP dev+release: pending Stage-2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6620348086 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2747). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:41:58Z. --- Part of #1723 What this unblocks: `image_sample_b` / `image_get_lod` after `s_wqm_b64 exec, exec` on a lane-narrowed EXEC (a kill or cmpx followed by a whole-quad restore), which was refused as a lane-EXEC break. Source: AMD "RDNA 2" Instruction Set Architecture reference guide, SOP1 instruction S_WQM_B64 (whole-quad mode of a mask) and the EXEC / quad rules of the MIMG sample instructions; Microsoft DirectX-Specs, D3D11 functional specification, `sample_b` and `lod`. Stacked on #2736 (this branch contains its commits until that merges; the new work is the last two commits). Builds on #2659. What changed - `s_wqm exec, exec` on a narrowed EXEC is lowered as `exec = x2w_quad_any(exec) ? 1u : 0u;`: the guest turns on every lane of a quad with an active lane, which is exactly the vote the branches already use. It is taken only where the quad runs the statement together (`uniform_cf` holds, no earlier lane-EXEC break, pixel program without a backward branch). - Before: recorded as a lane-EXEC break, so the op after it was refused. Other `s_wqm` forms (other operands) still break and stay refused. - A skipped EXEC-branch block that contains an `s_wqm` is still not voted (the #2736 vector-only gate), so the op is refused there. Tests - New draw fixture `wqm` (cmpx, then `s_wqm_b64 exec, exec`, then the subtraction, then the op) in `startup_image_sample_b_flow_check.py` and `startup_image_get_lod_flow_check.py`: u1 = 1/8 when the whole quad is back on, 5/8 if s_wqm were a no-op. Mutant "s_wqm as a no-op" must fail the draw. Words reassemble with llvm-mc. - The `wqm_break` refused fixture of #2736 became this accepted fixture. Verification (Linux only): ``` python3 -B tests/startup_image_sample_b_flow_check.py rc=0 python3 -B tests/startup_image_get_lod_flow_check.py rc=0 python3 -B tests/startup_image_sample_b_flow_check.py binary llvm-mc-19 fixtures reassemble python3 -B tests/startup_image_get_lod_flow_check.py binary llvm-mc-19 fixtures reassemble for every tests/startup_gfx2hlsl_*_check.py (no arguments) all rc=0 except the two draw-only checks that need adapter arguments (untouched) ``` Win2025 WARP dev+release: pending Stage-2. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 11:02:43 +00:00
tedin7 commented 2026-11-26 11:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:12:33Z.


Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189054118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2747#issuecomment-7189054118). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:12:33Z. --- Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.

Pull request closed

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!2739
No description provided.