startup: lower the first active lane of a pixel stage in gfx2hlsl (Refs #2618) #2846

Merged
RenzoWit35 merged 1 commit from upstream-pr/2854 into main 2026-11-26 14:30:48 +00:00
RenzoWit35 commented 2026-11-26 14:24:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-26T14:24:14Z.


Change

This implements the FIX claim in https://github.com/R0Y00/Xbox2Windows/issues/2618#issuecomment-7193852709 (the F rows, for example M500-01/070). Refs #2618.

On main, tools/startup/gfx2hlsl.py folds s_ff1_i32_b32 sD, exec_lo only at compute dispatch entry (#2389). It refuses the instruction in a pixel stage with "s_ff1_i32_b32 of exec_lo outside compute". A pixel v_readlane_b32 accepts only a constant spill lane.

The pair s_ff1_i32_b32 sD, exec_lo / v_readlane_b32 sX, vY, sD reads vY from the lowest lane in EXEC. In a pixel stage it now becomes WaveReadLaneFirst(vY) over the active lanes of the desktop wave. This uses the packing contract of the #2835 wave reductions: a correct program cannot depend on which pixel the console puts first.

  • Stage.first_active_lane (called from op_s_ff1_i32_b32) turns sD into a symbol with no run-time value. The desktop numbers its lanes in its own way. Each read of sD up to its next write must be the lane select of a v_readlane_b32; any other read is refused by name (a shift, a copy to another SGPR, a move to a VGPR).
  • Stage.read_first_lane (called from op_v_readlane_b32) emits sX = WaveReadLaneFirst(vY);.
  • The pair is accepted only in a straight-line pixel stage whose EXEC is the entry mask at the s_ff1 and at each readlane, with no s_wqm before them. On the console the helper lanes are then out of EXEC, and on the desktop wave operations leave them out.
  • Also refused:
    • a v_writelane_b32 spill VGPR as the readlane source;
    • a program that names exec_hi or the 64-bit exec. The decoder prints wave32 syntax, and in wave64 exec_lo is half the wave.
    • an EXEC that is changed and restored before the readlane. This is conservative: the one-lane model no longer knows the mask.
  • Vertex and mesh stages keep the existing refusal.

Not covered: pixel stages with branches, wave64, and other first-lane forms such as v_mbcnt compared with sD, or s_ff1 of a copy of EXEC. Whether the F rows stop at this exact pair still needs a replay against the captured requests by someone with capture access.

Verification

Commit 037eaf1b, rebased on 5a41adba. Windows 11 build 26300, VS Build Tools 2026 (MSVC 14.51), DXC 1.8.2502, Python 3.14. WARP 10.0.26100.9818. The D3D12 debug layer is not installed on this machine (debug_layer=unavailable).

python -B tests/startup_gfx2hlsl_pixel_first_lane_check.py
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(pixel_first_lane|wave_reduce|vcc_hi|readfirstlane)' -E '_hardware$' --output-on-failure
  • Controls: pass.
    • A 32-lane model of the source pair, written from the ISA text, gives the input of the lowest active lane for 500 random EXEC masks.
    • Three programs translate: the pair, two reads of one first lane, and a lane number overwritten and then read as a number.
    • Ten refusals are each checked by their reason. The vertex and mesh refusals are unchanged.
    • Against main's translator, the same fixture is refused with "s_ff1_i32_b32 of exec_lo outside compute".
  • WARP draw: pass. The triangle of the wave reduction test gives 482 covered pixels in 135 waves (lane count 4), with 30 partly covered quads. Every covered pixel matches the input (and, in the two-read program, the packed position) of the covered pixel with the lowest lane index in its wave. The wave is named by WaveActiveMin of the pixel id, not by the intrinsic under test. Four planted errors fail against the reference:
    • the lane's own value: 347 pixels;
    • the largest value of the wave: 456 and 474 pixels;
    • the first lane of the quad, a helper lane where the quad is partly covered: 25 pixels;
    • the lane after the first: 482 pixels.
  • CTest: all 9 selected tests pass.
  • Linux Python checks: the python-linux list (tools/run_checks_parallel.py --from-dir tests/checks/python-linux plus the inline list), run locally on Windows, has no failures. Two checks skip on Windows (startup_run_sh_check, startup_build_rev_check).
  • Binary mode: not run locally (no LLVM 15 here). The pixel-binary job runs it. Every fixture's words decode back to its source text with the repository disassembler.

WARP runs 4-lane waves, so on WARP the reference separates only covered lanes from helper lanes within a quad. Only startup_gfx2hlsl_pixel_first_lane_hardware on an adapter with wider waves picks a first lane across quads. I have no discrete GPU result to report.

Evidence and follow-up

  • Registration: tests/cmake/startup_gfx2hlsl_pixel_first_lane.cmake, tests/checks/python-linux/startup_gfx2hlsl_pixel_first_lane.txt, tests/checks/pixel-binary/startup_gfx2hlsl_pixel_first_lane.txt.
  • Note: docs/experiments/startup-gfx2hlsl-pixel-first-lane.md, plus a bullet in docs/startup-runtime.md after the wave reductions bullet.
  • This does not measure console behavior or a title.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6628711296 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2854). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-26T14:24:14Z. --- ## Change This implements the FIX claim in https://github.com/R0Y00/Xbox2Windows/issues/2618#issuecomment-7193852709 (the F rows, for example M500-01/070). Refs #2618. On main, `tools/startup/gfx2hlsl.py` folds `s_ff1_i32_b32 sD, exec_lo` only at compute dispatch entry (#2389). It refuses the instruction in a pixel stage with "s_ff1_i32_b32 of exec_lo outside compute". A pixel `v_readlane_b32` accepts only a constant spill lane. The pair `s_ff1_i32_b32 sD, exec_lo` / `v_readlane_b32 sX, vY, sD` reads `vY` from the lowest lane in EXEC. In a pixel stage it now becomes `WaveReadLaneFirst(vY)` over the active lanes of the desktop wave. This uses the packing contract of the #2835 wave reductions: a correct program cannot depend on which pixel the console puts first. - `Stage.first_active_lane` (called from `op_s_ff1_i32_b32`) turns `sD` into a symbol with no run-time value. The desktop numbers its lanes in its own way. Each read of `sD` up to its next write must be the lane select of a `v_readlane_b32`; any other read is refused by name (a shift, a copy to another SGPR, a move to a VGPR). - `Stage.read_first_lane` (called from `op_v_readlane_b32`) emits `sX = WaveReadLaneFirst(vY);`. - The pair is accepted only in a straight-line pixel stage whose EXEC is the entry mask at the `s_ff1` and at each readlane, with no `s_wqm` before them. On the console the helper lanes are then out of EXEC, and on the desktop wave operations leave them out. - Also refused: - a `v_writelane_b32` spill VGPR as the readlane source; - a program that names `exec_hi` or the 64-bit `exec`. The decoder prints wave32 syntax, and in wave64 `exec_lo` is half the wave. - an EXEC that is changed and restored before the readlane. This is conservative: the one-lane model no longer knows the mask. - Vertex and mesh stages keep the existing refusal. Not covered: pixel stages with branches, wave64, and other first-lane forms such as `v_mbcnt` compared with `sD`, or `s_ff1` of a copy of EXEC. Whether the F rows stop at this exact pair still needs a replay against the captured requests by someone with capture access. ## Verification Commit 037eaf1b, rebased on 5a41adba. Windows 11 build 26300, VS Build Tools 2026 (MSVC 14.51), DXC 1.8.2502, Python 3.14. WARP 10.0.26100.9818. The D3D12 debug layer is not installed on this machine (`debug_layer=unavailable`). ```powershell python -B tests/startup_gfx2hlsl_pixel_first_lane_check.py ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(pixel_first_lane|wave_reduce|vcc_hi|readfirstlane)' -E '_hardware$' --output-on-failure ``` - **Controls:** pass. - A 32-lane model of the source pair, written from the ISA text, gives the input of the lowest active lane for 500 random EXEC masks. - Three programs translate: the pair, two reads of one first lane, and a lane number overwritten and then read as a number. - Ten refusals are each checked by their reason. The vertex and mesh refusals are unchanged. - Against main's translator, the same fixture is refused with "s_ff1_i32_b32 of exec_lo outside compute". - **WARP draw:** pass. The triangle of the wave reduction test gives 482 covered pixels in 135 waves (lane count 4), with 30 partly covered quads. Every covered pixel matches the input (and, in the two-read program, the packed position) of the covered pixel with the lowest lane index in its wave. The wave is named by `WaveActiveMin` of the pixel id, not by the intrinsic under test. Four planted errors fail against the reference: - the lane's own value: 347 pixels; - the largest value of the wave: 456 and 474 pixels; - the first lane of the quad, a helper lane where the quad is partly covered: 25 pixels; - the lane after the first: 482 pixels. - **CTest:** all 9 selected tests pass. - **Linux Python checks:** the `python-linux` list (`tools/run_checks_parallel.py --from-dir tests/checks/python-linux` plus the inline list), run locally on Windows, has no failures. Two checks skip on Windows (`startup_run_sh_check`, `startup_build_rev_check`). - **Binary mode:** not run locally (no LLVM 15 here). The `pixel-binary` job runs it. Every fixture's words decode back to its source text with the repository disassembler. WARP runs 4-lane waves, so on WARP the reference separates only covered lanes from helper lanes within a quad. Only `startup_gfx2hlsl_pixel_first_lane_hardware` on an adapter with wider waves picks a first lane across quads. I have no discrete GPU result to report. ## Evidence and follow-up - Registration: `tests/cmake/startup_gfx2hlsl_pixel_first_lane.cmake`, `tests/checks/python-linux/startup_gfx2hlsl_pixel_first_lane.txt`, `tests/checks/pixel-binary/startup_gfx2hlsl_pixel_first_lane.txt`. - Note: `docs/experiments/startup-gfx2hlsl-pixel-first-lane.md`, plus a bullet in `docs/startup-runtime.md` after the wave reductions bullet. - This does not measure console behavior or a title. AI-assisted.
upstream-sync closed this pull request 2026-11-26 15:00:52 +00:00
tedin7 commented 2026-11-26 15:00:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:29:13Z.

Review: COMMENTED


Review of head 037eaf1b (comment only).

What I checked:

  • first_active_lane / read_first_lane in tools/startup/gfx2hlsl.py: the pair s_ff1_i32_b32 sD, exec_lo + v_readlane_b32 sX, vY, sD becomes WaveReadLaneFirst(vY). Guards look right: straight-line pixel stage only, EXEC must be the entry mask, no s_wqm, lane-number reads other than the readlane select are refused, spill VGPRs are refused, vs/ms stay refused.
  • The WARP test draws a triangle with partly covered quads and compares each desktop wave with the input of its lowest covered lane, plus a second program with two reads of one first lane. Masked lanes are exercised.
  • Mutations: removing the branch refusal makes startup_gfx2hlsl_pixel_first_lane_check.py fail (refused: a program with branches). Removing the exec_hi guard does not fail it, because the decoder already refuses exec_hi earlier (operand 'exec_hi'), so that guard is currently redundant (not a blocker).
  • Sibling code: startup_gfx2hlsl_wave_reduce_check.py still passes; docs and CMake wiring follow the existing pattern.
  • A lane-mask fuzz over the existing pixel wave families (135 variants) shows no mismatch against the CPU wave model: 20 match, 115 refused, 0 mismatches.

Commands executed locally:

  • python3 -B tests/startup_gfx2hlsl_pixel_first_lane_check.py: PASS
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean
  • Windows run: see the receipt comment (dev and release 3/3).

Not verified: real-GPU run not available (RunPod stopped). The PR cites #2618 and the startup path; I cannot check on the game itself, so the merge stays with MasterDomino or @R0Y00.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6075836620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2854#pullrequestreview-6075836620). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T14:29:13Z. **Review:** COMMENTED --- Review of head 037eaf1b (comment only). What I checked: - `first_active_lane` / `read_first_lane` in `tools/startup/gfx2hlsl.py`: the pair `s_ff1_i32_b32 sD, exec_lo` + `v_readlane_b32 sX, vY, sD` becomes `WaveReadLaneFirst(vY)`. Guards look right: straight-line pixel stage only, EXEC must be the entry mask, no `s_wqm`, lane-number reads other than the readlane select are refused, spill VGPRs are refused, vs/ms stay refused. - The WARP test draws a triangle with partly covered quads and compares each desktop wave with the input of its lowest covered lane, plus a second program with two reads of one first lane. Masked lanes are exercised. - Mutations: removing the branch refusal makes `startup_gfx2hlsl_pixel_first_lane_check.py` fail (`refused: a program with branches`). Removing the `exec_hi` guard does not fail it, because the decoder already refuses `exec_hi` earlier (`operand 'exec_hi'`), so that guard is currently redundant (not a blocker). - Sibling code: `startup_gfx2hlsl_wave_reduce_check.py` still passes; docs and CMake wiring follow the existing pattern. - A lane-mask fuzz over the existing pixel wave families (135 variants) shows no mismatch against the CPU wave model: 20 match, 115 refused, 0 mismatches. Commands executed locally: - `python3 -B tests/startup_gfx2hlsl_pixel_first_lane_check.py`: PASS - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean - Windows run: see the receipt comment (dev and release 3/3). Not verified: real-GPU run not available (RunPod stopped). The PR cites #2618 and the startup path; I cannot check on the game itself, so the merge stays with MasterDomino or @R0Y00. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 15:00:59 +00:00 (Migrated from github.com)

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


Win2025 WARP receipt for head 037eaf1b.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 037eaf1b37288d23edf5c7d7dcadedbdd98bcc0c:

  • Debug (--preset dev): ctest -R startup_gfx2hlsl_pixel_first_lane: 3/3 passed (_controls, _warp, _hardware).
  • Release /O2 (--preset release): same filter, 3/3 passed.
  • Windows Python checks: tests/startup_gfx2hlsl_pixel_first_lane_check.py ok, tests/startup_gfx2hlsl_wave_reduce_check.py ok.
  • Real-GPU run not available (no discrete GPU host in this pass); the _hardware test ran on the VM's adapter.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7194889198 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2854#issuecomment-7194889198). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T14:29:12Z. --- Win2025 WARP receipt for head 037eaf1b. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `037eaf1b37288d23edf5c7d7dcadedbdd98bcc0c`: - Debug (`--preset dev`): `ctest -R startup_gfx2hlsl_pixel_first_lane`: 3/3 passed (`_controls`, `_warp`, `_hardware`). - Release `/O2` (`--preset release`): same filter, 3/3 passed. - Windows Python checks: `tests/startup_gfx2hlsl_pixel_first_lane_check.py` ok, `tests/startup_gfx2hlsl_wave_reduce_check.py` ok. - Real-GPU run not available (no discrete GPU host in this pass); the `_hardware` test ran on the VM's adapter. AI-assisted; commands listed were executed locally.
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!2846
No description provided.