shader: cover subvector loop markers #3677

Manually merged
github merged 2 commits from github-bot/gh-3675 into gh-pr/3675/base 2026-12-02 19:18:00 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-12-01 00:08 UTC · original
lambirou:shader/subvector-loops → main · +501 −5 · 6 files · 2 commits · merged 2026-12-02 19:03 UTC

Problem

pixel_aot refused s_subvector_loop_begin and s_subvector_loop_end, so both SOPK forms stayed unobserved and any source-built pixel program using the pair could not be translated. The RDNA 2 ISA defines the pair as a conditional two-half EXEC loop, not as a generic no-op; a reduction is valid only for a restricted per-lane body.

Change

  • Adds plan_subvector_loops(), which validates the SOPK pair against the RDNA 2 ISA section 12.2, opcodes 27 and 28 before lowering it.
  • Both markers must name the same s0-s105 scratch SGPR. Begin targets the instruction after end, end targets the instruction after begin, the displacements must fit signed 16 bits, the pair must be top-level with the entry mask, and the scratch SGPR must be dead outside the pair.
  • The body is restricted to per-lane vector ALU plus NOP/wait/prefetch/priority/sleep/clause hints. EXEC/VCC/SCC writes, compares, cross-lane operations, DPP, carry/borrow writers, memory, exports and crossing branches are refused. Under that contract one full-mask pass has the same per-lane register effect as the wave64 two-half passes, and wave32 runs the entry-mask pass once. The markers emit no state and the body lowers once.
  • Unpaired, nested, mistargeted, empty, post-export and masked-region pairs are refused with explicit messages. s_endpgm_saved and s_endpgm_ordered_ps_done are unaffected.
  • Adds controls, a source-built draw, LLVM encoding checks, CTest entries, a coverage pin and docs/experiments/pixel-subvector-loops.md.

Tests

Commands run in the worktree:

C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py
C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/docs_links_check.py
C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py
ctest --test-dir out/build/dev --no-tests=error -R ^pixel_aot_subvector_loops_ -V

Results:

  • CTest controls, WARP draw and hardware draw: 3/3 passed in 18.0 s, no skips.
  • Hardware: AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows 11 build 26300, debug layer unavailable. WARP: Microsoft Basic Render Driver 10.0.26100.10068.
  • form_coverage_check.py: form coverage checks passed.
  • docs_links_check.py: 193 Markdown files and 746 links checked.
  • rdna2_tools_check.py: 161 tests OK, with 19 LLVM-dependent capability skips reported separately.
  • LLVM 15 binary/encoding controls pin the two gfx10 SOPK words.

Coverage delta

The records contain exactly s_subvector_loop_begin and s_subvector_loop_end, both present in docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv: +2 gfx1013 and +2 gfx1030 in the isolated measurement.

Limits

This is desktop DXIL evidence, not a console run. The wave64 reduction is proven only for the stated per-lane body with no wave-state, memory or cross-lane effects; nested loops and bodies that let the working EXEC half become zero remain refused. No claim is made about arbitrary real-world subvector bodies.

AI-assisted.

**@⁠lambirou** on GitHub · 2026-12-01 00:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3675) `lambirou:shader/subvector-loops` → `main` · +501 −5 · 6 files · 2 commits · merged 2026-12-02 19:03 UTC ## Problem pixel_aot refused s_subvector_loop_begin and s_subvector_loop_end, so both SOPK forms stayed unobserved and any source-built pixel program using the pair could not be translated. The RDNA 2 ISA defines the pair as a conditional two-half EXEC loop, not as a generic no-op; a reduction is valid only for a restricted per-lane body. ## Change - Adds plan_subvector_loops(), which validates the SOPK pair against the RDNA 2 ISA section 12.2, opcodes 27 and 28 before lowering it. - Both markers must name the same s0-s105 scratch SGPR. Begin targets the instruction after end, end targets the instruction after begin, the displacements must fit signed 16 bits, the pair must be top-level with the entry mask, and the scratch SGPR must be dead outside the pair. - The body is restricted to per-lane vector ALU plus NOP/wait/prefetch/priority/sleep/clause hints. EXEC/VCC/SCC writes, compares, cross-lane operations, DPP, carry/borrow writers, memory, exports and crossing branches are refused. Under that contract one full-mask pass has the same per-lane register effect as the wave64 two-half passes, and wave32 runs the entry-mask pass once. The markers emit no state and the body lowers once. - Unpaired, nested, mistargeted, empty, post-export and masked-region pairs are refused with explicit messages. s_endpgm_saved and s_endpgm_ordered_ps_done are unaffected. - Adds controls, a source-built draw, LLVM encoding checks, CTest entries, a coverage pin and docs/experiments/pixel-subvector-loops.md. ## Tests Commands run in the worktree: C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/docs_links_check.py C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py ctest --test-dir out/build/dev --no-tests=error -R ^pixel_aot_subvector_loops_ -V Results: - CTest controls, WARP draw and hardware draw: 3/3 passed in 18.0 s, no skips. - Hardware: AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows 11 build 26300, debug layer unavailable. WARP: Microsoft Basic Render Driver 10.0.26100.10068. - form_coverage_check.py: form coverage checks passed. - docs_links_check.py: 193 Markdown files and 746 links checked. - rdna2_tools_check.py: 161 tests OK, with 19 LLVM-dependent capability skips reported separately. - LLVM 15 binary/encoding controls pin the two gfx10 SOPK words. ## Coverage delta The records contain exactly s_subvector_loop_begin and s_subvector_loop_end, both present in docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv: +2 gfx1013 and +2 gfx1030 in the isolated measurement. ## Limits This is desktop DXIL evidence, not a console run. The wave64 reduction is proven only for the stated per-lane body with no wave-state, memory or cross-lane effects; nested loops and bodies that let the working EXEC half become zero remain refused. No claim is made about arbitrary real-world subvector bodies. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 00:12:31 +00:00
github-bot force-pushed github-bot/gh-3675 from 15733e2a08 to d2ece42163 2026-12-01 00:19:15 +00:00 Compare
github-bot force-pushed github-bot/gh-3675 from d2ece42163 to 47fac32098 2026-12-01 00:25:38 +00:00 Compare
github-bot force-pushed github-bot/gh-3675 from 47fac32098 to 68264630a4 2026-12-01 00:31:39 +00:00 Compare
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 02:39 UTC · original · approved these changes

Reviewed 68264630 by reading the diff; not built or run.

Verdict: approve. The pair checks are tight, and under the body contract one entry-mask pass equals the two wave64 half passes. No MUST, no SHOULD.

  • NIT The wave64 reduction holds only if no body instruction writes an SGPR lane mask, because the second half pass would overwrite the first pass's bits. _co, v_cmp*, div_scale and the lane ops are blocked (tools/pixel_aot.py:4144-4148). The VOP3b v_mad_u64_u32 / v_mad_i64_i32 (SGPR carry-out) are blocked only because pixel_aot does not lower them yet. Adding mad_[iu]64 to SUBVECTOR_BODY_CONTROL would keep the proof true once they are lowered.
  • Checked, no finding:
    • Pairing: the begin/end targets are cross-checked against each other's next instruction, the simm16 field is accepted in both LLVM spellings and sign-extended, nesting and unpaired markers are refused, and both markers must name the same SGPR, which may not be an entry SGPR.
    • The scratch SGPR is checked dead everywhere else, ranges included (names_sgpr), so its post-loop value never matters.
    • Branches into or across the pair, calls and indirect branches are refused for the whole program. plan_subvector_loops runs on the pre-inline list, but inline_calls is then a no-op, so the subvector_at indices match positioned.
    • The markers are refused in a masked region, under a non-entry mask and after the export. The body admits only plain v_ ALU and scalar hints and waits, with no memory, export, EXEC/VCC/SCC, DPP or cross-lane forms.
    • The new CMake fragment only registers pixel_aot_subvector_loops_{controls,warp,hardware} (skip 77 on the draws).

Tests: subvector-controls proves each pairing, liveness, branch, placement and body refusal, plus the LLVM 15 SOPK encodings. The draw shows that the lowered body matches the CPU reference on WARP and hardware. CI ran the controls at this head (they are in pixel_aot_check.py's default subcheck list). The draws are outside the pr filter.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 02:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3675#pullrequestreview-6124199847) · **approved these changes** Reviewed `68264630` by reading the diff; not built or run. **Verdict: approve.** The pair checks are tight, and under the body contract one entry-mask pass equals the two wave64 half passes. No MUST, no SHOULD. - **NIT** The wave64 reduction holds only if no body instruction writes an SGPR lane mask, because the second half pass would overwrite the first pass's bits. `_co`, `v_cmp*`, `div_scale` and the lane ops are blocked (`tools/pixel_aot.py:4144-4148`). The VOP3b `v_mad_u64_u32` / `v_mad_i64_i32` (SGPR carry-out) are blocked only because `pixel_aot` does not lower them yet. Adding `mad_[iu]64` to `SUBVECTOR_BODY_CONTROL` would keep the proof true once they are lowered. - Checked, no finding: - Pairing: the begin/end targets are cross-checked against each other's next instruction, the simm16 field is accepted in both LLVM spellings and sign-extended, nesting and unpaired markers are refused, and both markers must name the same SGPR, which may not be an entry SGPR. - The scratch SGPR is checked dead everywhere else, ranges included (`names_sgpr`), so its post-loop value never matters. - Branches into or across the pair, calls and indirect branches are refused for the whole program. `plan_subvector_loops` runs on the pre-inline list, but `inline_calls` is then a no-op, so the `subvector_at` indices match `positioned`. - The markers are refused in a masked region, under a non-entry mask and after the export. The body admits only plain `v_` ALU and scalar hints and waits, with no memory, export, EXEC/VCC/SCC, DPP or cross-lane forms. - The new CMake fragment only registers `pixel_aot_subvector_loops_{controls,warp,hardware}` (skip 77 on the draws). Tests: `subvector-controls` proves each pairing, liveness, branch, placement and body refusal, plus the LLVM 15 SOPK encodings. The draw shows that the lowered body matches the CPU reference on WARP and hardware. CI ran the controls at this head (they are in `pixel_aot_check.py`'s default subcheck list). The draws are outside the `pr` filter.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 05:45 UTC · original · reviewed

The reviewed head now conflicts in tests/form_coverage_check.py and tests/pixel_aot_check.py. Please keep main's SOPP coverage checks and draw-saveexec-family entry alongside the new subvector-loop coverage and draw mode. The assertion that still bans both subvector markers needs to admit those two specifically while keeping the unimplemented control-flow forms refused. Please rerun form_coverage_check.py and the pixel_aot_subvector_loops_ family on the integrated head.

**@⁠R0Y00** on GitHub · 2026-12-02 05:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3675#pullrequestreview-6145406220) · **reviewed** The reviewed head now conflicts in `tests/form_coverage_check.py` and `tests/pixel_aot_check.py`. Please keep main's SOPP coverage checks and `draw-saveexec-family` entry alongside the new subvector-loop coverage and draw mode. The assertion that still bans both subvector markers needs to admit those two specifically while keeping the unimplemented control-flow forms refused. Please rerun `form_coverage_check.py` and the `pixel_aot_subvector_loops_` family on the integrated head.
github-bot changed target branch from main to gh-pr/3675/base 2026-12-02 19:17:54 +00:00
github manually merged commit 5a6e0d700c into gh-pr/3675/base 2026-12-02 19:17:55 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 19:02 UTC · original · approved these changes

Reviewed 5a6e0d70 on the updated branch. The conflict resolution keeps the existing SOPP and draw-saveexec coverage alongside the subvector fixtures. The controls verify paired markers and refusal of invalid bodies. Independent Windows 11 build 26300 / MSVC Debug ctest --preset dev --no-tests=error -V -j 1 -R '^pixel_aot_subvector_loops_(controls|warp|hardware)$' passed 3/3, with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 for the GPU fixtures.

**@⁠R0Y00** on GitHub · 2026-12-02 19:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3675#pullrequestreview-6157019674) · **approved these changes** Reviewed 5a6e0d70 on the updated branch. The conflict resolution keeps the existing SOPP and draw-saveexec coverage alongside the subvector fixtures. The controls verify paired markers and refusal of invalid bodies. Independent Windows 11 build 26300 / MSVC Debug `ctest --preset dev --no-tests=error -V -j 1 -R '^pixel_aot_subvector_loops_(controls|warp|hardware)$'` passed 3/3, with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 for the GPU fixtures.
This discussion has been locked. Commenting is limited to contributors.
No description provided.