startup: lower slot 57 pre-exchange execz blocks with several scalar loads (Part of #2413) #2775

Merged
JB2WIN merged 1 commit from upstream-pr/2783 into main 2026-11-26 08:58:50 +00:00
JB2WIN commented 2026-11-26 08:46:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-26T08:46:01Z.


Change

Part of #2413 (claim). This follows #2660.

#2660 lowers exactly one s_buffer_load_dword in a pre-exchange s_cbranch_execz block of a slot 57 mesh program. It uses the wave predicate wave_any = (tid & ~63u) < bound captured at v_cmpx_gt_u32_e32 s<bound>, v<thread>.

This PR accepts a wider block. The block must be straight-line code. It may hold any number of s_buffer_load_dword* / s_load_dword* loads, scalar ALU and lane-only vector code, including a per-lane v_cmp into VCC. The lowering stays the #2660 one:

  • The branch around the block is !wave_any. Every scalar instruction therefore runs for all lanes of a wave that has an active lane, as the guest runs it once per wave.
  • Vector writes stay predicated by each lane's EXEC bit.
  • An empty wave issues no load and keeps the old scalars.

Added acceptance

  • The full EXEC reset may sit above the compare. Nothing between them may write or name EXEC or VCC, and no branch may enter that range from outside.
  • Several such blocks in one program are tracked by their compares.

Refused (slot 57 mesh: s_cbranch_execz skips code with effects outside active lanes):

  • a branch landing between the compare and the execz branch, or inside the block;
  • an EXEC write between the reset and the compare;
  • in the block: EXEC, M0 or src_* operands, s_*_saveexec, MODE writes, stores and atomics;
  • VCC, or SCC written by scalar ALU, that is read after the join;
  • a scalar read after the join that has no wave-uniform value before the block.

docs/experiments/startup-mesh57-wave-block.md describes the shape, the semantics and the census.

Verification

Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 621.24), DXC from Windows SDK 10.0.26100, Python 3.13. The release build was at 96a7b4fb (only Python files change here). The branch is rebased on 4bbe52ee, and the translation checks were re-run there.

  • python -B tests/startup_mesh57_skeleton_check.py: ok.
    • It has the new refusal controls above.
    • It checks that the HLSL keeps both scalar loads and the offset sum inside the [branch] fall-through.
    • On upstream main the new cases fail. For example: pre-exchange wave block translates: got 'unsupported: slot 57 mesh: s_cbranch_execz ...'.
  • python -B tests/startup_mesh57_skeleton_check.py binary <llvm-mc>: ok. All fixture words, including the new WAVE_BLOCK_MESH, match the encodings. Locally llvm-mc is a stand-in that runs clang -cc1as -show-encoding from LLVM 15.0.7. CI runs the real llvm-mc-15.
  • python -B tests/startup_mesh57_skeleton_check.py draw <dxc> <offscreen_check> warp and ... hardware (startup_mesh57_skeleton_draw_warp / _hardware): ok on WARP and on the RTX 3080. The wave block fixture:
    • matches the CPU reference;
    • fails on 259 pixels with the old and new scalar swapped;
    • with the block predicate replaced by the lane's own (exec & 1) == 0, differs from the wave image on 66 pixels and matches its own per-lane image (0 mismatches).
  • The other mesh checks are ok: startup_mesh57_depth_only_check.py, startup_mesh57_loop_check.py, startup_mesh57_loop_refusal_check.py, startup_mesh57_lane_spill_check.py, docs_links_check.py, bidi_controls_check.py, git diff --check.
  • The full Linux Python list from windows.yml, run through tools/run_checks_parallel.py on Windows: 203 ok and 2 skipped.
    • tests/dxc_cache_check.py fails with WinError 193. It fails the same way on unmodified main on this host, because it starts a POSIX script.
  • A fresh read-only review found one blocker before this push: a branch from between the reset and the compare could jump past the compare. It is fixed, and it is the branch from between the reset and the compare past the compare control. That control translates when the rule is reverted.

Evidence and follow-up

The fixture is source-built and hand-assembled. It extends the existing tests/startup_mesh57_skeleton.s fixture with the same geometry and draw as #2660.

Changed #2660 controls

  • wider SMEM load and dead scalar result are now accepted.
  • missing full EXEC reset used an s_nop in place of the adjacent reset. The reset that closes the group-index exchange still reaches the compare there, with nothing naming EXEC or VCC between them. That shape is now an accepted case, and the missing-reset control writes EXEC from s[4:5] instead.
  • second live scalar write stays refused, because its register has no value before the block.
  • The register-offset s_load now stops at the existing s_load with a register offset rule.

Local capture (counts only; no programs, logs or identifiers here)

  • On main 96a7b4fb, 407 slot 57 requests stop at the execz refusal.
  • 91 of them pass the pre-exchange block with this change. They then stop at the same message in the post-count primitive-export block, on an s_add_u32 that is dead after the jump to s_endpgm. I will send that as a separate PR.
  • With both changes, they stop at v_readfirstlane_b32 outside the group-index read is not covered. No complete translation is added yet.
  • The other 316 have branches inside the block, src_scc, or the v_cmpx_lt_u32 v, v compare. These are not in scope.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code). The commands above were run locally.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6622876643 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2783). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-26T08:46:01Z. --- ## Change Part of #2413 ([claim](https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7186705717)). This follows #2660. #2660 lowers exactly one `s_buffer_load_dword` in a pre-exchange `s_cbranch_execz` block of a slot 57 mesh program. It uses the wave predicate `wave_any = (tid & ~63u) < bound` captured at `v_cmpx_gt_u32_e32 s<bound>, v<thread>`. This PR accepts a wider block. The block must be straight-line code. It may hold any number of `s_buffer_load_dword*` / `s_load_dword*` loads, scalar ALU and lane-only vector code, including a per-lane `v_cmp` into VCC. The lowering stays the #2660 one: - The branch around the block is `!wave_any`. Every scalar instruction therefore runs for all lanes of a wave that has an active lane, as the guest runs it once per wave. - Vector writes stay predicated by each lane's EXEC bit. - An empty wave issues no load and keeps the old scalars. **Added acceptance** - The full EXEC reset may sit above the compare. Nothing between them may write or name EXEC or VCC, and no branch may enter that range from outside. - Several such blocks in one program are tracked by their compares. **Refused** (`slot 57 mesh: s_cbranch_execz skips code with effects outside active lanes`): - a branch landing between the compare and the execz branch, or inside the block; - an EXEC write between the reset and the compare; - in the block: EXEC, M0 or `src_*` operands, `s_*_saveexec`, MODE writes, stores and atomics; - VCC, or SCC written by scalar ALU, that is read after the join; - a scalar read after the join that has no wave-uniform value before the block. `docs/experiments/startup-mesh57-wave-block.md` describes the shape, the semantics and the census. ## Verification Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 621.24), DXC from Windows SDK 10.0.26100, Python 3.13. The release build was at `96a7b4fb` (only Python files change here). The branch is rebased on `4bbe52ee`, and the translation checks were re-run there. - `python -B tests/startup_mesh57_skeleton_check.py`: ok. - It has the new refusal controls above. - It checks that the HLSL keeps both scalar loads and the offset sum inside the `[branch]` fall-through. - On upstream main the new cases fail. For example: `pre-exchange wave block translates: got 'unsupported: slot 57 mesh: s_cbranch_execz ...'`. - `python -B tests/startup_mesh57_skeleton_check.py binary <llvm-mc>`: ok. All fixture words, including the new `WAVE_BLOCK_MESH`, match the encodings. Locally `llvm-mc` is a stand-in that runs `clang -cc1as -show-encoding` from LLVM 15.0.7. CI runs the real `llvm-mc-15`. - `python -B tests/startup_mesh57_skeleton_check.py draw <dxc> <offscreen_check> warp` and `... hardware` (`startup_mesh57_skeleton_draw_warp` / `_hardware`): ok on WARP and on the RTX 3080. The wave block fixture: - matches the CPU reference; - fails on 259 pixels with the old and new scalar swapped; - with the block predicate replaced by the lane's own `(exec & 1) == 0`, differs from the wave image on **66** pixels and matches its own per-lane image (0 mismatches). - The other mesh checks are ok: `startup_mesh57_depth_only_check.py`, `startup_mesh57_loop_check.py`, `startup_mesh57_loop_refusal_check.py`, `startup_mesh57_lane_spill_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `git diff --check`. - The full Linux Python list from `windows.yml`, run through `tools/run_checks_parallel.py` on Windows: 203 ok and 2 skipped. - `tests/dxc_cache_check.py` fails with `WinError 193`. It fails the same way on unmodified main on this host, because it starts a POSIX script. - A fresh read-only review found one blocker before this push: a branch from between the reset and the compare could jump past the compare. It is fixed, and it is the `branch from between the reset and the compare past the compare` control. That control translates when the rule is reverted. ## Evidence and follow-up The fixture is source-built and hand-assembled. It extends the existing `tests/startup_mesh57_skeleton.s` fixture with the same geometry and draw as #2660. **Changed #2660 controls** - `wider SMEM load` and `dead scalar result` are now accepted. - `missing full EXEC reset` used an `s_nop` in place of the adjacent reset. The reset that closes the group-index exchange still reaches the compare there, with nothing naming EXEC or VCC between them. That shape is now an accepted case, and the missing-reset control writes EXEC from `s[4:5]` instead. - `second live scalar write` stays refused, because its register has no value before the block. - The register-offset `s_load` now stops at the existing `s_load with a register offset` rule. **Local capture** (counts only; no programs, logs or identifiers here) - On main `96a7b4fb`, 407 slot 57 requests stop at the execz refusal. - 91 of them pass the pre-exchange block with this change. They then stop at the same message in the post-count primitive-export block, on an `s_add_u32` that is dead after the jump to `s_endpgm`. I will send that as a separate PR. - With both changes, they stop at `v_readfirstlane_b32 outside the group-index read is not covered`. No complete translation is added yet. - The other 316 have branches inside the block, `src_scc`, or the `v_cmpx_lt_u32 v, v` compare. These are not in scope. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). The commands above were run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-26 09:04:50 +00:00
tedin7 commented 2026-11-26 09:04:51 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head cb176399 against main (fixture and code review only; no game claim is made or checked here).

What I checked

  • tools/startup/gfx2hlsl.py: the wider pre-exchange execz block keeps the #2660 lowering (!wave_any branch, EXEC-predicated vector writes). The acceptance rules (reset above the compare, no EXEC/VCC use between them, no entry from outside, straight-line block, VCC/SCC dead at the join, only SGPR/SCC/constant scalar operands) match the PR text.
  • tests/startup_mesh57_skeleton_check.py: new accepted case plus refusal controls, and a real D3D12 draw test (startup_mesh57_skeleton_draw_warp / _hardware) that compares GPU readback with the CPU reference and has negative controls (swapped scalars, per-lane predicate).
  • No other open or merged PR covers this slice; it extends #2660 as stated.

Mutations (each must fail the new test)

  • Remove the VCC-live-at-join rule: FAIL VCC live at the join.
  • Remove the branch-entry rule (entries): FAIL branch from between the reset and the compare past the compare.
  • Remove the any(s in edges ...) clause: the suite still passes, because the targets.intersection clause and the join handling already refuse a branch inside the block, including one that jumps to the join (I tried that extra control). That clause is redundant, not a bug.

Commands run

  • python3 -B tests/startup_mesh57_skeleton_check.py, plus the depth_only, loop, loop_refusal and lane_spill mesh57 checks: ok
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: ok
  • Windows Server 2025 WARP dev and release on this head (receipt in the next comment): 8/9, the ninth is a capability skip.
  • tested on RTX 3090 through vkd3d-proton (Linux): 7/9 on -R startup_mesh57_skeleton. The two failures (_exchange_warp, _exchange_hardware) are a missing startup_indirect_draw_indexed.exe on that pod, not this PR; every draw, wave_shift and depth test passed there, including startup_mesh57_skeleton_draw_hardware.

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6071082598 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2783#pullrequestreview-6071082598). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:58:29Z. **Review:** COMMENTED --- Review of head `cb176399` against main (fixture and code review only; no game claim is made or checked here). **What I checked** - `tools/startup/gfx2hlsl.py`: the wider pre-exchange execz block keeps the #2660 lowering (`!wave_any` branch, EXEC-predicated vector writes). The acceptance rules (reset above the compare, no EXEC/VCC use between them, no entry from outside, straight-line block, VCC/SCC dead at the join, only SGPR/SCC/constant scalar operands) match the PR text. - `tests/startup_mesh57_skeleton_check.py`: new accepted case plus refusal controls, and a real D3D12 draw test (`startup_mesh57_skeleton_draw_warp` / `_hardware`) that compares GPU readback with the CPU reference and has negative controls (swapped scalars, per-lane predicate). - No other open or merged PR covers this slice; it extends #2660 as stated. **Mutations (each must fail the new test)** - Remove the VCC-live-at-join rule: `FAIL VCC live at the join`. - Remove the branch-entry rule (`entries`): `FAIL branch from between the reset and the compare past the compare`. - Remove the `any(s in edges ...)` clause: the suite still passes, because the `targets.intersection` clause and the join handling already refuse a branch inside the block, including one that jumps to the join (I tried that extra control). That clause is redundant, not a bug. **Commands run** - `python3 -B tests/startup_mesh57_skeleton_check.py`, plus the depth_only, loop, loop_refusal and lane_spill mesh57 checks: ok - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: ok - Windows Server 2025 WARP dev and release on this head (receipt in the next comment): 8/9, the ninth is a capability skip. - tested on RTX 3090 through vkd3d-proton (Linux): 7/9 on `-R startup_mesh57_skeleton`. The two failures (`_exchange_warp`, `_exchange_hardware`) are a missing `startup_indirect_draw_indexed.exe` on that pod, not this PR; every draw, wave_shift and depth test passed there, including `startup_mesh57_skeleton_draw_hardware`. No blocking findings. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 09:04:55 +00:00 (Migrated from github.com)

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


Win2025 WARP receipt for head cb176399 (branch already up to date with main).

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset dev -R 'startup_mesh57_skeleton' --parallel 2 --no-tests=error --output-on-failure): 8/9 passed (8.67s: startup_mesh57_skeleton 2.03s, startup_mesh57_skeleton_wave_shift_hardware 0.64s, startup_mesh57_skeleton_depth_hardware 0.68s, startup_mesh57_skeleton_exchange_hardware 0.38s, startup_mesh57_skeleton_draw_hardware 3.99s, startup_mesh57_skeleton_wave_shift_warp 0.67s, startup_mesh57_skeleton_depth_warp 0.71s, startup_mesh57_skeleton_draw_warp 3.96s, startup_mesh57_skeleton_exchange_warp 3.08s); skipped (capability, not a pass): startup_mesh57_skeleton_exchange_hardware
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset release -R 'startup_mesh57_skeleton' --parallel 2 --no-tests=error --output-on-failure): 8/9 passed (8.49s: startup_mesh57_skeleton 2.02s, startup_mesh57_skeleton_wave_shift_hardware 0.62s, startup_mesh57_skeleton_depth_hardware 0.66s, startup_mesh57_skeleton_exchange_hardware 0.39s, startup_mesh57_skeleton_draw_hardware 3.75s, startup_mesh57_skeleton_wave_shift_warp 0.77s, startup_mesh57_skeleton_depth_warp 0.88s, startup_mesh57_skeleton_draw_warp 4.11s, startup_mesh57_skeleton_exchange_warp 2.85s); skipped (capability, not a pass): startup_mesh57_skeleton_exchange_hardware
  • Windows Python checks: tests/startup_mesh57_skeleton_check.py ok (1.9s)
  • Wall: 26.6s

Tests named: startup_mesh57_skeleton, _draw_warp/_hardware, depth, wave_shift, _exchange_warp; PYCHECK tests/startup_mesh57_skeleton_check.py rc=0.
tested on RTX 3090 through vkd3d-proton (Linux): 7/9 (the 2 exchange tests need a target missing on that pod; all draw/depth/wave_shift tests pass).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187251717 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2783#issuecomment-7187251717). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:58:30Z. --- Win2025 WARP receipt for head cb176399 (branch already up to date with main). Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `cb176399d589e1425fffb2ab2942a95b3c7e01e5`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset dev -R 'startup_mesh57_skeleton' --parallel 2 --no-tests=error --output-on-failure`): **8/9 passed** (`8.67s`: `startup_mesh57_skeleton` `2.03s`, `startup_mesh57_skeleton_wave_shift_hardware` `0.64s`, `startup_mesh57_skeleton_depth_hardware` `0.68s`, `startup_mesh57_skeleton_exchange_hardware` `0.38s`, `startup_mesh57_skeleton_draw_hardware` `3.99s`, `startup_mesh57_skeleton_wave_shift_warp` `0.67s`, `startup_mesh57_skeleton_depth_warp` `0.71s`, `startup_mesh57_skeleton_draw_warp` `3.96s`, `startup_mesh57_skeleton_exchange_warp` `3.08s`); skipped (capability, not a pass): `startup_mesh57_skeleton_exchange_hardware` - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset release -R 'startup_mesh57_skeleton' --parallel 2 --no-tests=error --output-on-failure`): **8/9 passed** (`8.49s`: `startup_mesh57_skeleton` `2.02s`, `startup_mesh57_skeleton_wave_shift_hardware` `0.62s`, `startup_mesh57_skeleton_depth_hardware` `0.66s`, `startup_mesh57_skeleton_exchange_hardware` `0.39s`, `startup_mesh57_skeleton_draw_hardware` `3.75s`, `startup_mesh57_skeleton_wave_shift_warp` `0.77s`, `startup_mesh57_skeleton_depth_warp` `0.88s`, `startup_mesh57_skeleton_draw_warp` `4.11s`, `startup_mesh57_skeleton_exchange_warp` `2.85s`); skipped (capability, not a pass): `startup_mesh57_skeleton_exchange_hardware` - **Windows Python checks**: `tests/startup_mesh57_skeleton_check.py` ok (`1.9s`) - Wall: `26.6s` Tests named: startup_mesh57_skeleton, _draw_warp/_hardware, _depth_*, _wave_shift_*, _exchange_warp; PYCHECK tests/startup_mesh57_skeleton_check.py rc=0. tested on RTX 3090 through vkd3d-proton (Linux): 7/9 (the 2 exchange tests need a target missing on that pod; all draw/depth/wave_shift tests pass). 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!2775
No description provided.