shader: lower v_subrev_f32_dpp and more v_writelane_b32 shapes #3487

Open
github-bot wants to merge 1 commit from github-bot/gh-3485 into main AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 17:25 UTC · original
Leyukaka:shader-gfx2hlsl-late-gaps → main · +146 −16 · 4 files · 1 commits · open

Refs #3480 (items 1 and 2).

What changes

tools/startup/gfx2hlsl.py:

  • v_subrev_f32_dpp: no new lowering. The existing table entry and the DPP pair/broadcast path already give F(v2) - F(v256) (SRC1 minus the permuted SRC0). What refused these shaders was a s_mov_b64 exec, exec / s_mov_b32 exec_lo, exec_lo between the s_wqm and the read. A move of EXEC to itself without modifiers is no longer counted as an EXEC writer by quad_flow_refusals, and in a pixel stage _lower returns before touching the EXEC/WQM state (the instruction writes neither EXEC nor SCC). The other users of writes_exec are unchanged.
  • v_writelane_b32, lanes k and k+32 of one VGPR: accepted in straight-line code when every v_readlane_b32 of the slot follows a last write to the same lane, and at least one such reload exists. Wave32 (slot k & 31) and wave64 (lane k) then read the same write. A read with no prior write, or after a write to the other lane, is still refused.
  • Spill VGPR reused as a vector: accepted in a straight-line pixel stage when the first ordinary use is v_mov_b32 vN, <SGPR or immediate> without modifiers, no instruction in the program writes EXEC, and no lane read or write follows.
  • Descriptor word spilled in a pixel stage: carried as a symbol, as the compute path already does, when the word is a table descriptor symbol naming one value, the code is straight-line and still in the entry block, and formatted_descriptor_from_block proves its local table load. A copied word (s_mov_b32) is refused.

The existing refusal messages and conditions remain for every shape outside these proofs.

Tests

Two new late-gaps <llvm-mc> modes (startup_gfx2hlsl_dpp_quad_broadcast_check.py, startup_gfx2hlsl_sgpr_spill_check.py), registered in tests/cmake/startup_gfx2hlsl_late_gaps.cmake when llvm-mc is found. They assemble the accept and refuse controls for each shape above.

These two modes did not run on our host: llvm-mc is not installed there, so CTest did not register them. The Linux CI job has LLVM 15 and should run them. Until it does, the new accept/refuse controls are unexecuted, and no mutation was run against them.

Passed on our host (pure-Python modes, 0 FAIL): dpp_quad_broadcast, sgpr_spill, dpp_pair, dpp_quad_flow, dpp_quad_swap, spill_branches, compute_spill, compute_mask_spill, mesh57_lane_spill, mesh57_skeleton, mesh57_depth_only, mesh57_loop, mesh57_loop_refusal, gfx2hlsl_refusals, gfx2hlsl_op_refusals, triage_run, refusal_census. The 11 registered ctest entries for these passed.

Not covered

  • After the vector reuse, helper lanes (inactive in the guest, active in HLSL) hold the new value. Nothing can observe them without an EXEC change, and that shape is refused.
  • No draw comparison for the new shapes.
  • This and the format-load proof PR for #3480 item 3 both edit the formatted-descriptor area of gfx2hlsl.py. They merge without conflict; the combined tree was not tested.
**@⁠Leyukaka** on GitHub · 2026-11-29 17:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3485) `Leyukaka:shader-gfx2hlsl-late-gaps` → `main` · +146 −16 · 4 files · 1 commits · open Refs #3480 (items 1 and 2). ## What changes `tools/startup/gfx2hlsl.py`: - **`v_subrev_f32_dpp`**: no new lowering. The existing table entry and the DPP pair/broadcast path already give `F(v2) - F(v256)` (SRC1 minus the permuted SRC0). What refused these shaders was a `s_mov_b64 exec, exec` / `s_mov_b32 exec_lo, exec_lo` between the `s_wqm` and the read. A move of EXEC to itself without modifiers is no longer counted as an EXEC writer by `quad_flow_refusals`, and in a pixel stage `_lower` returns before touching the EXEC/WQM state (the instruction writes neither EXEC nor SCC). The other users of `writes_exec` are unchanged. - **`v_writelane_b32`, lanes k and k+32 of one VGPR**: accepted in straight-line code when every `v_readlane_b32` of the slot follows a last write to the same lane, and at least one such reload exists. Wave32 (slot `k & 31`) and wave64 (lane `k`) then read the same write. A read with no prior write, or after a write to the other lane, is still refused. - **Spill VGPR reused as a vector**: accepted in a straight-line pixel stage when the first ordinary use is `v_mov_b32 vN, <SGPR or immediate>` without modifiers, no instruction in the program writes EXEC, and no lane read or write follows. - **Descriptor word spilled in a pixel stage**: carried as a symbol, as the compute path already does, when the word is a table descriptor symbol naming one value, the code is straight-line and still in the entry block, and `formatted_descriptor_from_block` proves its local table load. A copied word (`s_mov_b32`) is refused. The existing refusal messages and conditions remain for every shape outside these proofs. ## Tests Two new `late-gaps <llvm-mc>` modes (`startup_gfx2hlsl_dpp_quad_broadcast_check.py`, `startup_gfx2hlsl_sgpr_spill_check.py`), registered in `tests/cmake/startup_gfx2hlsl_late_gaps.cmake` when `llvm-mc` is found. They assemble the accept and refuse controls for each shape above. **These two modes did not run on our host**: `llvm-mc` is not installed there, so CTest did not register them. The Linux CI job has LLVM 15 and should run them. Until it does, the new accept/refuse controls are unexecuted, and no mutation was run against them. Passed on our host (pure-Python modes, 0 FAIL): dpp_quad_broadcast, sgpr_spill, dpp_pair, dpp_quad_flow, dpp_quad_swap, spill_branches, compute_spill, compute_mask_spill, mesh57_lane_spill, mesh57_skeleton, mesh57_depth_only, mesh57_loop, mesh57_loop_refusal, gfx2hlsl_refusals, gfx2hlsl_op_refusals, triage_run, refusal_census. The 11 registered ctest entries for these passed. ## Not covered - After the vector reuse, helper lanes (inactive in the guest, active in HLSL) hold the new value. Nothing can observe them without an EXEC change, and that shape is refused. - No draw comparison for the new shapes. - This and the format-load proof PR for #3480 item 3 both edit the formatted-descriptor area of `gfx2hlsl.py`. They merge without conflict; the combined tree was not tested.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 17:27:37 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 08:25 UTC · original · reviewed

Reviewed 18434d7c by reading the diff; not built or run.

Verdict: comment. I found no defect in the four proofs, but none of the new accept/refuse controls has run yet. No MUST.

  • SHOULD (before approval): the late-gaps modes ran nowhere at this head. In run 46289500579, the gfx1013 job runs sgpr_spill_check.py only as binary and does not run dpp_quad_broadcast_check.py. The Linux job runs sgpr_spill_check.py with no arguments, and the Windows job registers no *_late_gaps test (no llvm-mc found). So the three widened shapes have no executed test and no mutation. One local run with LLVM 15 llvm-mc, pasted here, would settle it.
  • Self-move of EXEC: writes_exec checks destinations, so only the exact s_mov_b64 exec, exec / s_mov_b32 exec_lo, exec_lo without modifiers leaves the writer list (gfx2hlsl.py:4989). The early return in _lower is pixel-only and comes after the fetch-call check.
  • Lane alias proof: spill_operands refuses register lanes (:9556), so no write to an unknown slot can slip in. last_write[lane & 31] == lane at each read means wave32 and wave64 read the same write. Pairs still refuse with branches (quad_flow_straight) or with no observed reload.
  • Vector reuse: refused unless the first ordinary use is v_mov_b32 v<n>, <non-VGPR> with no modifiers, no instruction in the program writes EXEC, and no lane op follows. Vertex, compute and mesh keep the old refusal (self.kind != 'ps').
  • Pixel descriptor spill: limited to the entry block, a table symbol that names one value, and the unchanged formatted_descriptor_from_block. proven comes from spill_word_proven as in compute. #3488 does not change the block proof, so the two PRs do not interact here.

Tests: CI ran only sgpr_spill_check.py in its old modes (no arguments, binary), both ok. Neither reaches the new lines, since every new control lives in late-gaps.

**@⁠lukaslw-lab** on GitHub · 2026-11-30 08:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3485#pullrequestreview-6108862852) · **reviewed** Reviewed `18434d7c` by reading the diff; not built or run. **Verdict: comment.** I found no defect in the four proofs, but none of the new accept/refuse controls has run yet. No MUST. - **SHOULD (before approval):** the `late-gaps` modes ran nowhere at this head. In run 46289500579, the gfx1013 job runs `sgpr_spill_check.py` only as `binary` and does not run `dpp_quad_broadcast_check.py`. The Linux job runs `sgpr_spill_check.py` with no arguments, and the Windows job registers no `*_late_gaps` test (no `llvm-mc` found). So the three widened shapes have no executed test and no mutation. One local run with LLVM 15 `llvm-mc`, pasted here, would settle it. - Self-move of EXEC: `writes_exec` checks destinations, so only the exact `s_mov_b64 exec, exec` / `s_mov_b32 exec_lo, exec_lo` without modifiers leaves the writer list (`gfx2hlsl.py:4989`). The early return in `_lower` is pixel-only and comes after the fetch-call check. - Lane alias proof: `spill_operands` refuses register lanes (`:9556`), so no write to an unknown slot can slip in. `last_write[lane & 31] == lane` at each read means wave32 and wave64 read the same write. Pairs still refuse with branches (`quad_flow_straight`) or with no observed reload. - Vector reuse: refused unless the first ordinary use is `v_mov_b32 v<n>, <non-VGPR>` with no modifiers, no instruction in the program writes EXEC, and no lane op follows. Vertex, compute and mesh keep the old refusal (`self.kind != 'ps'`). - Pixel descriptor spill: limited to the entry block, a table symbol that names one value, and the unchanged `formatted_descriptor_from_block`. `proven` comes from `spill_word_proven` as in compute. #3488 does not change the block proof, so the two PRs do not interact here. Tests: CI ran only `sgpr_spill_check.py` in its old modes (no arguments, `binary`), both ok. Neither reaches the new lines, since every new control lives in `late-gaps`.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 12:21 UTC · original · requested changes

On 18434d7c, LLVM 15.0.7 ran the SGPR spill late-gaps mode successfully. The DPP late-gaps mode fails in check_late_gaps at tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py:329: ps_hw_inputs=PACKED passes an integer where Pipeline expects (enable, address). In an isolated copy, changing that argument to ps_hw_inputs=(PACKED, PACKED) (the same pair used by this file's other pipeline constructor) makes all six DPP controls pass, including both subtraction results and the EXEC refusals. Please commit that fixture fix and make these LLVM modes run in the gfx1013 CI job so a future signature change reaches them.

**@⁠R0Y00** on GitHub · 2026-12-02 12:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3485#pullrequestreview-6150618978) · **requested changes** On `18434d7c`, LLVM 15.0.7 ran the SGPR spill `late-gaps` mode successfully. The DPP `late-gaps` mode fails in `check_late_gaps` at `tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py:329`: `ps_hw_inputs=PACKED` passes an integer where `Pipeline` expects `(enable, address)`. In an isolated copy, changing that argument to `ps_hw_inputs=(PACKED, PACKED)` (the same pair used by this file's other pipeline constructor) makes all six DPP controls pass, including both subtraction results and the EXEC refusals. Please commit that fixture fix and make these LLVM modes run in the gfx1013 CI job so a future signature change reaches them.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3487/head:github-bot/gh-3485'
git switch 'github-bot/gh-3485'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3485'
git switch 'github-bot/gh-3485'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3485'
git switch 'github-bot/gh-3485'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3485'
git switch 'main'
git merge --squash 'github-bot/gh-3485'
git switch 'main'
git merge --ff-only 'github-bot/gh-3485'
git switch 'main'
git merge 'github-bot/gh-3485'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.