fix(shader): prove scalar runs before compute EXEC restores #2900

Merged
brainbudt merged 3 commits from upstream-pr/2900 into main 2026-11-27 11:49:13 +00:00
brainbudt commented 2026-11-26 17:29:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by brainbudt on 2026-11-26T17:29:04Z.


Problem

A compute lane-exhaustion exit is refused when its destination starts with a scalar descriptor load and wait before restoring EXEC. Refs #2645 (T3).

Change

Prove that exiting lanes cannot observe work on the staying path, verify that both paths reach a safe scalar run (rejecting divergent EXEC, live SCC reads, scalar clobbers, and wave effects such as s_setprio, s_barrier, and s_sendmsg) and restore an unchanged saved EXEC mask. Add a source-built gfx1013 fixture and refusal controls for wrong remasks, scalar clobbers, unsafe effects, and invalid targets.

Scope

Covers straight exits in compute groups of up to 32 threads (the two-mask counted loop remains refused).

Verification

  • macOS ARM64: python3 -B tests/startup_gfx2hlsl_compute_check.py passed (including after rebasing onto latest origin/main). Wave and singleton traces agreed for both exit outcomes; the original translator refused the accepted fixture with branch out of the block.
  • Linux x86-64: full python-linux (210/210) and LLVM 15.0.7 pixel-binary (136/136) suites passed; python3 -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15 reassembled the fixture byte-for-byte.
  • Verification covered host translation and assembly; native D3D12 dispatch was outside the test scope.

Reviewed & refined by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5514536126 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900). Originally posted by [brainbudt](https://github.com/brainbudt) on 2026-11-26T17:29:04Z. --- ## Problem A compute lane-exhaustion exit is refused when its destination starts with a scalar descriptor load and wait before restoring EXEC. Refs #2645 (T3). ## Change Prove that exiting lanes cannot observe work on the staying path, verify that both paths reach a safe scalar run (rejecting divergent EXEC, live SCC reads, scalar clobbers, and wave effects such as `s_setprio`, `s_barrier`, and `s_sendmsg`) and restore an unchanged saved EXEC mask. Add a source-built gfx1013 fixture and refusal controls for wrong remasks, scalar clobbers, unsafe effects, and invalid targets. ## Scope Covers straight exits in compute groups of up to 32 threads (the two-mask counted loop remains refused). ## Verification - macOS ARM64: `python3 -B tests/startup_gfx2hlsl_compute_check.py` passed (including after rebasing onto latest `origin/main`). Wave and singleton traces agreed for both exit outcomes; the original translator refused the accepted fixture with `branch out of the block`. - Linux x86-64: full `python-linux` (210/210) and LLVM 15.0.7 `pixel-binary` (136/136) suites passed; `python3 -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15` reassembled the fixture byte-for-byte. - Verification covered host translation and assembly; native D3D12 dispatch was outside the test scope. --- Reviewed & refined by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 Code).
thepatrickworld commented 2026-11-26 18:14:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T18:14:13Z.


Independent Linux host-only result on 088d0d11: the new exit is accepted, the base refuses it, and 8 of the 14 conditions of the new guard are not separated by any control

Not a code change; measurements only.

Environment

  • Linux x86-64, Python 3.11.16, no GPU and no DXC: translation only, the same stage your body verifies.
  • Worktree detached at 088d0d11 (base 6ee878d8). Blob sha256 tools/startup/gfx2hlsl.py 382be0e422fd1fba65df93c71d368db8aacacafecbe03f07b9d911b48a748060 at the head, 0eb758407558cd2997e850712adbda1b0d01a49514976a5b2faa89fe60a8fd38 at the base; tests/startup_gfx2hlsl_compute_check.py 6e82de0a3b847e9b422cf663f16d4f4d20ed38ef9564045e075acb6363d23616. The translator sha256 is printed before and after every run and git status --porcelain --untracked-files=no is empty at the end of each pass.

Commands

python3 -B tests/startup_gfx2hlsl_compute_check.py
git checkout -f 6ee878d8 -- tools/startup/gfx2hlsl.py && python3 -B tests/startup_gfx2hlsl_compute_check.py

Observed

Head: exit 0, last line compute entry, numthreads, masked bit counts, manifest, offen store forms and the store, descriptor, execz and sample refusals pass.

Base translator with your fixture: exit 1,

gfx2hlsl.Unsupported: s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block

so the acceptance is new behaviour and this fixture is what names it — the same A/B you describe, on a machine outside your two.

Which conditions the added controls separate

Stage.execz_scalar_exit (lines 2992-3060 at 088d0d11) has 13 return False sites plus the run's own saved_exec(...) and all(...) return. Two measurements: one condition deleted at a time, the motif required to be unique, the tree restored and re-checked by sha256 after each run.

Deleting one of these turns the fixture red: M5 live_in[target] & {mask, 'scc'}, M8 the restore right after the branch, M9 the body between that restore and the exit target, M11 the run's scalar-only content, M12 the saved-mask reuse in the run's EXEC write and its guard-range scan, M13 the shape of that EXEC write. Two of them fail through an adjacent refusal rather than through the near-miss that names them: M11 is refused later by LDS exchange needs a 1D group and a nonzero allocation of at most 32 KiB, M13 refuses the accepted fixture itself.

Deleting one of these changes no verdict, in this fixture and in the 14 other files of tests/ that build an s_cbranch_scc0 inside an s_cbranch_execz-skipped block: M1 x * y * z > 32, M2 into.get(join) != [guard], M3 no other entry into [guard+1, target), M4 the s_andn2_b32 d, s, exec_lo shape, M6 saved_exec before the guard, M7 the body between the guard and the branch, M10 no other entry into the run after its target, M14 the trailing return False. (19 files carry both mnemonics, 4 need arguments or iced_x86 and were left out, leaving 15 that run bare — this fixture included.)

A counter print placed in front of each return False — behaviour unchanged, exit 0 — shows which refusals the suite actually takes: live_in 1, saved_exec before the guard 1, the restore-after-branch 1, the post-restore body 1, the run's EXEC-write shape 1, the run's saved-register range 1, the run's scalar content 7. Six sites are never taken at all.

Putting the two together: seven of the eight green deletions remove a refusal the suite never takes, and three of those (M1, M2, M3) are disjuncts of the single site at 3001-3003. The eighth, saved_exec (3024-3025), is taken once and removing it still leaves the whole suite green, so no control attributes that program's refusal to this line.

Nothing here says the eight are wrong. It says no control in the suite translates a program whose verdict would change if the condition vanished: an exit run entered from a second site, a restored mask that was never saved, an s_andn2_b32 whose destination is not its source.

The fixture is already enforced on pull requests: python-linux (.github/workflows/windows.yml:181, list entry at :340) and pixel-binary (:18, :143) carry no if: guard. So the six deletions that turn it red are caught by CI and the eight above are outside what CI can see.

The scope boundary is the one with a measured consequence

Your body scopes the change to "compute groups of up to 32 threads". Same words, group size varied through the fixture's own translate('O', code=EXIT_RUN_WORDS, group=...):

group=(8,1,1)    head: accepted    M1: accepted
group=(16,2,1)   head: accepted    M1: accepted
group=(32,1,1)   head: accepted    M1: accepted
group=(33,1,1)   head: refused     M1: accepted
group=(8,8,1)    head: refused     M1: accepted
group=(32,2,1)   head: refused     M1: accepted
group=(64,1,1)   head: refused     M1: accepted

Every head refusal is the same branch out of the block, and the whole fixture stays green on M1. The text accepted for (64,1,1) declares [numthreads(64, 1, 1)] and is otherwise the same translation as (32,1,1): one uint exec word for a group of two waves. With the line neutralised the same words translate at every size above, so this condition is the only refusal standing between the shape and a group bigger than one wave — and no test in the suite distinguishes the two sides of it. One control that translates EXIT_RUN_WORDS at group=(64,1,1) and asserts the refusal would pin the boundary your body already claims.

Limits

  • One machine, host translation only: nothing here says the accepted program renders correctly on a device; no DXC, no dispatch, no adapter, no debug layer.
  • A green mutant means no control in the fixtures I ran feeds a program whose verdict changes. For M1 it is worth saying what that does not mean: the condition does refuse the same words at (33,1,1) and (64,1,1), it is simply never given such a group by the suite.
  • The matrix deletes one condition at a time and says nothing about combinations.
  • Line numbers are those of 088d0d11.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7200214357 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#issuecomment-7200214357). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-26T18:14:13Z. --- **Independent Linux host-only result on `088d0d11`: the new exit is accepted, the base refuses it, and 8 of the 14 conditions of the new guard are not separated by any control** Not a code change; measurements only. ### Environment - Linux x86-64, Python 3.11.16, no GPU and no DXC: translation only, the same stage your body verifies. - Worktree detached at `088d0d11` (base `6ee878d8`). Blob sha256 `tools/startup/gfx2hlsl.py` `382be0e422fd1fba65df93c71d368db8aacacafecbe03f07b9d911b48a748060` at the head, `0eb758407558cd2997e850712adbda1b0d01a49514976a5b2faa89fe60a8fd38` at the base; `tests/startup_gfx2hlsl_compute_check.py` `6e82de0a3b847e9b422cf663f16d4f4d20ed38ef9564045e075acb6363d23616`. The translator sha256 is printed before and after every run and `git status --porcelain --untracked-files=no` is empty at the end of each pass. ### Commands ``` python3 -B tests/startup_gfx2hlsl_compute_check.py git checkout -f 6ee878d8 -- tools/startup/gfx2hlsl.py && python3 -B tests/startup_gfx2hlsl_compute_check.py ``` ### Observed Head: exit 0, last line `compute entry, numthreads, masked bit counts, manifest, offen store forms and the store, descriptor, execz and sample refusals pass`. Base translator with your fixture: exit 1, ``` gfx2hlsl.Unsupported: s_cbranch_scc0 inside a block s_cbranch_execz skips per lane: branch out of the block ``` so the acceptance is new behaviour and this fixture is what names it — the same A/B you describe, on a machine outside your two. ### Which conditions the added controls separate `Stage.execz_scalar_exit` (lines 2992-3060 at `088d0d11`) has 13 `return False` sites plus the run's own `saved_exec(...) and all(...)` return. Two measurements: one condition deleted at a time, the motif required to be unique, the tree restored and re-checked by sha256 after each run. Deleting one of these turns the fixture red: M5 `live_in[target] & {mask, 'scc'}`, M8 the restore right after the branch, M9 the body between that restore and the exit target, M11 the run's scalar-only content, M12 the saved-mask reuse in the run's EXEC write and its guard-range scan, M13 the shape of that EXEC write. Two of them fail through an adjacent refusal rather than through the near-miss that names them: M11 is refused later by `LDS exchange needs a 1D group and a nonzero allocation of at most 32 KiB`, M13 refuses the accepted fixture itself. Deleting one of these changes no verdict, in this fixture and in the 14 other files of `tests/` that build an `s_cbranch_scc0` inside an `s_cbranch_execz`-skipped block: M1 `x * y * z > 32`, M2 `into.get(join) != [guard]`, M3 no other entry into `[guard+1, target)`, M4 the `s_andn2_b32 d, s, exec_lo` shape, M6 `saved_exec` before the guard, M7 the body between the guard and the branch, M10 no other entry into the run after its target, M14 the trailing `return False`. (19 files carry both mnemonics, 4 need arguments or `iced_x86` and were left out, leaving 15 that run bare — this fixture included.) A counter print placed in front of each `return False` — behaviour unchanged, exit 0 — shows which refusals the suite actually takes: `live_in` 1, `saved_exec` before the guard 1, the restore-after-branch 1, the post-restore body 1, the run's EXEC-write shape 1, the run's saved-register range 1, the run's scalar content 7. Six sites are never taken at all. Putting the two together: seven of the eight green deletions remove a refusal the suite never takes, and three of those (M1, M2, M3) are disjuncts of the single site at 3001-3003. The eighth, `saved_exec` (3024-3025), is taken once and removing it still leaves the whole suite green, so no control attributes that program's refusal to this line. Nothing here says the eight are wrong. It says no control in the suite translates a program whose verdict would change if the condition vanished: an exit run entered from a second site, a restored mask that was never saved, an `s_andn2_b32` whose destination is not its source. The fixture is already enforced on pull requests: `python-linux` (`.github/workflows/windows.yml:181`, list entry at `:340`) and `pixel-binary` (`:18`, `:143`) carry no `if:` guard. So the six deletions that turn it red are caught by CI and the eight above are outside what CI can see. ### The scope boundary is the one with a measured consequence Your body scopes the change to "compute groups of up to 32 threads". Same words, group size varied through the fixture's own `translate('O', code=EXIT_RUN_WORDS, group=...)`: ``` group=(8,1,1) head: accepted M1: accepted group=(16,2,1) head: accepted M1: accepted group=(32,1,1) head: accepted M1: accepted group=(33,1,1) head: refused M1: accepted group=(8,8,1) head: refused M1: accepted group=(32,2,1) head: refused M1: accepted group=(64,1,1) head: refused M1: accepted ``` Every head refusal is the same `branch out of the block`, and the whole fixture stays green on M1. The text accepted for `(64,1,1)` declares `[numthreads(64, 1, 1)]` and is otherwise the same translation as `(32,1,1)`: one `uint exec` word for a group of two waves. With the line neutralised the same words translate at every size above, so this condition is the only refusal standing between the shape and a group bigger than one wave — and no test in the suite distinguishes the two sides of it. One control that translates `EXIT_RUN_WORDS` at `group=(64,1,1)` and asserts the refusal would pin the boundary your body already claims. ### Limits - One machine, host translation only: nothing here says the accepted program renders correctly on a device; no DXC, no dispatch, no adapter, no debug layer. - A green mutant means no control in the fixtures I ran feeds a program whose verdict changes. For M1 it is worth saying what that does *not* mean: the condition does refuse the same words at `(33,1,1)` and `(64,1,1)`, it is simply never given such a group by the suite. - The matrix deletes one condition at a time and says nothing about combinations. - Line numbers are those of `088d0d11`. _AI-assisted._
KelboLive commented 2026-11-26 20:24:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:24:42Z.

Review: COMMENTED


fix(shader): prove scalar runs before compute EXEC restores

Interesting shader correctness fix. Testing scalar register liveness across compute EXEC restores is important for correctness — scalar pipelines have different scheduling characteristics than vector units.

Observations

  • Moderate scope (222 lines) — this is a shader translator fix, so domain expertise is needed for thorough review
  • The 1 comment suggests maintainer engagement; worth checking for specific feedback
  • Need to verify that scalar register tracking doesn't regress existing shader translation paths

Questions

  • What specific shader scenario triggered this? Is there a test fixture that demonstrates the bug before/after?
  • Does this affect vertex, fragment, or compute shader translation specifically?

Verdict: Needs domain-expert review of the scalar register tracking logic and any potential regression impact on other shader types.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6080121184 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#pullrequestreview-6080121184). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-26T20:24:42Z. **Review:** COMMENTED --- **fix(shader): prove scalar runs before compute EXEC restores** Interesting shader correctness fix. Testing scalar register liveness across compute EXEC restores is important for correctness — scalar pipelines have different scheduling characteristics than vector units. ### Observations - Moderate scope (222 lines) — this is a shader translator fix, so domain expertise is needed for thorough review - The 1 comment suggests maintainer engagement; worth checking for specific feedback - Need to verify that scalar register tracking doesn't regress existing shader translation paths ### Questions - What specific shader scenario triggered this? Is there a test fixture that demonstrates the bug before/after? - Does this affect vertex, fragment, or compute shader translation specifically? **Verdict:** Needs domain-expert review of the scalar register tracking logic and any potential regression impact on other shader types.
KelboLive commented 2026-11-27 05:48:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:48:51Z.

Review: COMMENTED


What works

  1. Clear problem statement targeting #2645 T3 — proving straight lane-exhaustion exits before EXEC restore is a genuine gap in the current executor.
  2. The EXIT_RUN_SOURCE fixture is well-structured: s_and_saveexec_b32/s_cbranch_execz/s_andn2_b32/s_cbranch_scc0 chain followed by a shared scalar run ending in s_mov_b32 exec_lo, s21. Tight and reproducible.
  3. The trace-level verification (trace() / singletons()) is excellent — shows wave vs. singleton parity, including near-miss edge cases (remask from s21, scalar_on_stay=True).
  4. Renaming MESH_WAVE_BLOCK_LOADS to SCALAR_LOADS is a clean unification that reduces duplication across mesh and executor paths.
  5. The refusal controls for EXECZ_EXIT_WAITS (s_nop, s_waitcnt, s_waitcnt_depctr) correctly limit what can appear in the shared scalar run.
  6. The wave/singleton trace agreement with KEY^lane values provides a precise, deterministic oracle — much better than relying on disassembly output alone.

Issues

  1. Group size bound: The proof restricts to x*y*z <= 32. While this is correctly noted, many compute shaders use 256-thread groups. The comment in docs/experiments.md should explicitly state this is a "up to 32 threads" proof, not a general solution. Consider adding a follow-up item for larger groups in the experiment doc.

  2. saved_exec() backward scan: The function scans from guard-1 down to 0 looking for the EXEC save. This O(n) backward scan is fine for small blocks but could miss cases where a scalar effect between the save and guard interferes. The words & effects[k][2] check catches writes to the scalar register, but doesn't verify the save path is unbroken by other execz entry points. This is likely fine in practice.

  3. SCC after the scalar run: The test at the end (check_execz_exit_run) verifies that SCC after the run still distinguishes wave vs. singleton, which triggers refusal. However, the main execz_scalar_exit() method checks live_in[target] & {mask, "scc"} — if SCC is live at the target, it rejects. This is correct but the comment in the function docstring should explicitly mention SCC liveness as a rejection criterion.

  4. EXECZ_EXIT_WAITS scope: The tuple includes s_nop, which means a run consisting entirely of nops and waitcnts is accepted. This is safe but the boundary — when s_cbranch_scc0 is removed and replaced by s_cbranch_execz inside a skipped block — could merge the two test cases (LOOP_BREAK and EXIT_RUN) differently. The current separation into check_execz_loop_break() and check_execz_exit_run() with adjusted assertions in between is correct.

  5. quiet(j) change: The logic shift from reason = 'branch out of the block' followed by conditional override to an elif with execz_scalar_exit() is cleaner but could be confusing during maintenance. The new structure means the original reason string is never assigned when the exit path is valid — consider adding a comment at the top of the block explaining the new control flow.

Recommendations

  • Consider adding a # TODO: or Refs #XXXX: in the code pointing to the next phase (handling groups > 32 or the two-mask counted loop from #2645 T2). This helps future contributors know what's explicitly out of scope vs. deferred bugs.
  • The test swap() function is a clever near-miss generator. Consider making it a standalone helper at module level since it's used across multiple test functions.

Overall

This is a solid, well-tested change. The trace-level verification model (wave vs. singletons with KEY^lane) is a strong foundation for proving the scalar exit pattern. The execz_scalar_exit() method adds clear, structured proof conditions. The refactoring to SCALAR_LOADS is a nice cleanup. The group-size limitation to 32 threads is correctly bounded and clearly documented.

Recommendation: APPROVE (with the documentation note in #1 above addressed as a minor comment).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6084011295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#pullrequestreview-6084011295). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T05:48:51Z. **Review:** COMMENTED --- ## What works 1. Clear problem statement targeting #2645 T3 — proving straight lane-exhaustion exits before EXEC restore is a genuine gap in the current executor. 2. The `EXIT_RUN_SOURCE` fixture is well-structured: `s_and_saveexec_b32`/`s_cbranch_execz`/`s_andn2_b32`/`s_cbranch_scc0` chain followed by a shared scalar run ending in `s_mov_b32 exec_lo, s21`. Tight and reproducible. 3. The trace-level verification (`trace()` / `singletons()`) is excellent — shows wave vs. singleton parity, including near-miss edge cases (remask from s21, scalar_on_stay=True). 4. Renaming `MESH_WAVE_BLOCK_LOADS` to `SCALAR_LOADS` is a clean unification that reduces duplication across mesh and executor paths. 5. The refusal controls for `EXECZ_EXIT_WAITS` (s_nop, s_waitcnt, s_waitcnt_depctr) correctly limit what can appear in the shared scalar run. 6. The wave/singleton trace agreement with KEY^lane values provides a precise, deterministic oracle — much better than relying on disassembly output alone. ## Issues 1. **Group size bound**: The proof restricts to `x*y*z <= 32`. While this is correctly noted, many compute shaders use 256-thread groups. The comment in `docs/experiments.md` should explicitly state this is a "up to 32 threads" proof, not a general solution. Consider adding a follow-up item for larger groups in the experiment doc. 2. **`saved_exec()` backward scan**: The function scans from `guard-1` down to 0 looking for the EXEC save. This O(n) backward scan is fine for small blocks but could miss cases where a scalar effect between the save and guard interferes. The `words & effects[k][2]` check catches writes to the scalar register, but doesn't verify the save path is unbroken by other `execz` entry points. This is likely fine in practice. 3. **SCC after the scalar run**: The test at the end (`check_execz_exit_run`) verifies that SCC after the run still distinguishes wave vs. singleton, which triggers refusal. However, the main `execz_scalar_exit()` method checks `live_in[target] & {mask, "scc"}` — if SCC is live at the target, it rejects. This is correct but the comment in the function docstring should explicitly mention SCC liveness as a rejection criterion. 4. **`EXECZ_EXIT_WAITS` scope**: The tuple includes `s_nop`, which means a run consisting entirely of nops and waitcnts is accepted. This is safe but the boundary — when `s_cbranch_scc0` is removed and replaced by `s_cbranch_execz` inside a skipped block — could merge the two test cases (LOOP_BREAK and EXIT_RUN) differently. The current separation into `check_execz_loop_break()` and `check_execz_exit_run()` with adjusted assertions in between is correct. 5. **`quiet(j)` change**: The logic shift from `reason = 'branch out of the block'` followed by conditional override to an `elif` with `execz_scalar_exit()` is cleaner but could be confusing during maintenance. The new structure means the original reason string is never assigned when the exit path is valid — consider adding a comment at the top of the block explaining the new control flow. ## Recommendations - Consider adding a `# TODO:` or `Refs #XXXX:` in the code pointing to the next phase (handling groups > 32 or the two-mask counted loop from #2645 T2). This helps future contributors know what's explicitly out of scope vs. deferred bugs. - The test `swap()` function is a clever near-miss generator. Consider making it a standalone helper at module level since it's used across multiple test functions. ## Overall This is a solid, well-tested change. The trace-level verification model (wave vs. singletons with KEY^lane) is a strong foundation for proving the scalar exit pattern. The `execz_scalar_exit()` method adds clear, structured proof conditions. The refactoring to `SCALAR_LOADS` is a nice cleanup. The group-size limitation to 32 threads is correctly bounded and clearly documented. **Recommendation: APPROVE** (with the documentation note in #1 above addressed as a minor comment).
brainbudt commented 2026-11-27 09:36:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by brainbudt on 2026-11-27T09:36:46Z.


Note

🤖 Gemini 4 Neon responding on behalf of brainbudt

Thanks @thepatrickworld and @KelboLive! Updated in 022212a:

  • Added explicit refusal controls in check_execz_exit_run for workgroups > 32 threads (group=(33,1,1) and (64,1,1)), an unsaved restore mask (s_mov_b32 s21, 0), and s_andn2_b32 with dest != src.
  • Clarified the single-wave32 (x * y * z <= 32) scope bound (with larger workgroups noted as follow-up work) and the SCC-liveness rejection criterion in docs/experiments.md and Stage.execz_scalar_exit.
  • Verified python3 -B tests/startup_gfx2hlsl_compute_check.py passes cleanly.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7214886241 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#issuecomment-7214886241). Originally posted by [brainbudt](https://github.com/brainbudt) on 2026-11-27T09:36:46Z. --- > [!NOTE] > 🤖 **Gemini 4 Neon responding on behalf of brainbudt** Thanks @thepatrickworld and @KelboLive! Updated in `022212a`: - Added explicit refusal controls in `check_execz_exit_run` for workgroups > 32 threads (`group=(33,1,1)` and `(64,1,1)`), an unsaved restore mask (`s_mov_b32 s21, 0`), and `s_andn2_b32` with `dest != src`. - Clarified the single-wave32 (`x * y * z <= 32`) scope bound (with larger workgroups noted as follow-up work) and the SCC-liveness rejection criterion in `docs/experiments.md` and `Stage.execz_scalar_exit`. - Verified `python3 -B tests/startup_gfx2hlsl_compute_check.py` passes cleanly.
thepatrickworld commented 2026-11-27 10:10:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T10:10:43Z.


Independent Linux host-only result on 022212aa: what the three refusal controls added in the second commit pin

Environment and scope

Linux host, no GPU: no D3D12 dispatch and no _hardware entry ran. Everything below is Python-only translator measurement of tests/startup_gfx2hlsl_compute_check.py at 022212aa (clean worktree). python3 -B tests/startup_gfx2hlsl_compute_check.py passes (… execz and sample refusals pass).

022212aa changes no behaviour: tools/startup/gfx2hlsl.py +3/−2 (docstring only), fixture +6/−1. The accepted program and the proof come from 088d0d11, where I reported the base/head delta (6ee878d8 refuses it, 088d0d11 accepts).

Method

32 hand-written single edits of Stage.execz_scalar_exit; 25 applied through the harness (mutated gfx2hlsl.py loaded over sys.modules['gfx2hlsl'], then check_execz_exit_run() and check_controls() re-run; baseline green before and after, and a sanity edit of s_andn2_b32 to s_andn2_b64 is killed). Four scope edits needed a qualified anchor and re-ran outside the harness; three (operand count, pair-aligned mask, run-operand shape) were not measured. Result: 12 killed, 13 survive. Line numbers are the head's, read from a sys.settrace pass over the module.

What the three added controls pin

  • (33,1,1) / (64,1,1): > 33, > 64 and a deleted bound all turn the check red, so the refusal edge is pinned at 33. The accepted edge is not: the head accepts group=(32,1,1) (9989 chars of HLSL), the fixture never passes a 32-thread group, and x*y*z >= 32 keeps the whole suite green. One translate(..., group=(32,1,1)) line pins it.
  • s_mov_b32 s21, 0 (byte 28): removing the pre-guard save proof for the ANDN2 source alone stays green; removing the restore re-proof (3053-3054) alone is caught. The control pins the restore side, not the pre-guard site.
  • s_andn2_b32 s22, s0, exec_lo (byte 52) is refused at head by the shape test (3006-3008), by the save proof (3025-3026) once the equality term is removed, and by the remask install (3033) once both are removed (measured: refused, refused, accepted). The entry crosses three catchers and pins none of them on its own.

Survivors

  • Masked on the same entry: the equality term, the live-effect term, the restore destination test and the restore width test (s_mov_b32 exec_hi, s21 dies at the destination test 3048 and never reaches the width test 3050).
  • Unreached by any control: the branch-graph guards, the pre-ANDN2 window (3029), and ops[2] != 'exec_lo'. My own entry for the last one, s_andn2_b32 s0, s0, vcc_lo, is refused by the join-liveness rule instead, so it separates nothing.
  • Untested: _dpp and v_permlane/v_movrel in the exit run. Stage.vector_only_instruction accepts v_mov_b32_dpp and v_permlane16_b32, so those terms are the rejection and not that helper; a compute DPP op is refused earlier anyway (4513-4516).
  • One dead condition: branch <= guard + 1 can only be branch == guard + 1, and ins[branch - 1] is then the s_cbranch_execz itself, which the shape test rejects at 3006.

Limits

No HLSL was compiled or executed: these are refusal-gate measurements only. The oracle is the fixture of the same commit, so a killed edit shows the fixture sees a change, not that its expectation is right, and every internal refusal shares one message, so a refusal can pass for the wrong reason (the s22 entry is the demonstration). The edit set is mine.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7215568253 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#issuecomment-7215568253). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-27T10:10:43Z. --- **Independent Linux host-only result on `022212aa`: what the three refusal controls added in the second commit pin** ### Environment and scope Linux host, no GPU: no D3D12 dispatch and no `_hardware` entry ran. Everything below is Python-only translator measurement of `tests/startup_gfx2hlsl_compute_check.py` at `022212aa` (clean worktree). `python3 -B tests/startup_gfx2hlsl_compute_check.py` passes (`… execz and sample refusals pass`). `022212aa` changes no behaviour: `tools/startup/gfx2hlsl.py` +3/−2 (docstring only), fixture +6/−1. The accepted program and the proof come from `088d0d11`, where I reported the base/head delta (`6ee878d8` refuses it, `088d0d11` accepts). ### Method 32 hand-written single edits of `Stage.execz_scalar_exit`; 25 applied through the harness (mutated `gfx2hlsl.py` loaded over `sys.modules['gfx2hlsl']`, then `check_execz_exit_run()` and `check_controls()` re-run; baseline green before and after, and a sanity edit of `s_andn2_b32` to `s_andn2_b64` is killed). Four scope edits needed a qualified anchor and re-ran outside the harness; three (operand count, pair-aligned mask, run-operand shape) were not measured. Result: 12 killed, 13 survive. Line numbers are the head's, read from a `sys.settrace` pass over the module. ### What the three added controls pin - `(33,1,1)` / `(64,1,1)`: `> 33`, `> 64` and a deleted bound all turn the check red, so the refusal edge is pinned at 33. The accepted edge is not: the head accepts `group=(32,1,1)` (9989 chars of HLSL), the fixture never passes a 32-thread group, and `x*y*z >= 32` keeps the whole suite green. One `translate(..., group=(32,1,1))` line pins it. - `s_mov_b32 s21, 0` (byte 28): removing the pre-guard save proof for the ANDN2 source alone stays green; removing the restore re-proof (3053-3054) alone is caught. The control pins the restore side, not the pre-guard site. - `s_andn2_b32 s22, s0, exec_lo` (byte 52) is refused at head by the shape test (3006-3008), by the save proof (3025-3026) once the equality term is removed, and by the remask install (3033) once both are removed (measured: refused, refused, accepted). The entry crosses three catchers and pins none of them on its own. ### Survivors - Masked on the same entry: the equality term, the live-effect term, the restore destination test and the restore width test (`s_mov_b32 exec_hi, s21` dies at the destination test 3048 and never reaches the width test 3050). - Unreached by any control: the branch-graph guards, the pre-ANDN2 window (3029), and `ops[2] != 'exec_lo'`. My own entry for the last one, `s_andn2_b32 s0, s0, vcc_lo`, is refused by the join-liveness rule instead, so it separates nothing. - Untested: `_dpp` and `v_permlane`/`v_movrel` in the exit run. `Stage.vector_only_instruction` accepts `v_mov_b32_dpp` and `v_permlane16_b32`, so those terms are the rejection and not that helper; a compute DPP op is refused earlier anyway (4513-4516). - One dead condition: `branch <= guard + 1` can only be `branch == guard + 1`, and `ins[branch - 1]` is then the `s_cbranch_execz` itself, which the shape test rejects at 3006. ### Limits No HLSL was compiled or executed: these are refusal-gate measurements only. The oracle is the fixture of the same commit, so a killed edit shows the fixture sees a change, not that its expectation is right, and every internal refusal shares one message, so a refusal can pass for the wrong reason (the `s22` entry is the demonstration). The edit set is mine. _AI-assisted._
brainbudt commented 2026-11-27 11:14:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by brainbudt on 2026-11-27T11:14:32Z.


Note

🤖 Gemini 4 Neon responding on behalf of brainbudt

Updated in 491d0fd to address @thepatrickworld's mutation findings:

  • Accepted workgroup edge: Added translate('O', code=EXIT_RUN_WORDS, group=(32, 1, 1)).hlsl_cs() in check_execz_exit_run so x * y * z <= 32 is pinned on both sides (32 accepted, 33/64 refused).
  • Pre-guard save proof: Added a refusal control replacing s_and_saveexec_b32 s0, vcc_lo at byte 36 with s_mov_b32 s0, 0 (800380be), pinning saved_exec(mask, 's_mov_b32', 'exec_lo') independently of the restore-side s21 check.
  • Dead condition: Removed the redundant branch <= guard + 1 check in Stage.execz_scalar_exit (when branch == guard + 1, ins[branch - 1] is s_cbranch_execz and already rejected by the s_andn2_b32 check).

Verified locally: python3 -B tests/startup_gfx2hlsl_compute_check.py passes, and single-edit mutation checks confirm both x * y * z >= 32 and removing the pre-guard saved_exec check are now caught.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7216845630 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#issuecomment-7216845630). Originally posted by [brainbudt](https://github.com/brainbudt) on 2026-11-27T11:14:32Z. --- > [!NOTE] > 🤖 **Gemini 4 Neon responding on behalf of brainbudt** Updated in `491d0fd` to address @thepatrickworld's mutation findings: - **Accepted workgroup edge**: Added `translate('O', code=EXIT_RUN_WORDS, group=(32, 1, 1)).hlsl_cs()` in `check_execz_exit_run` so `x * y * z <= 32` is pinned on both sides (32 accepted, 33/64 refused). - **Pre-guard save proof**: Added a refusal control replacing `s_and_saveexec_b32 s0, vcc_lo` at byte 36 with `s_mov_b32 s0, 0` (`800380be`), pinning `saved_exec(mask, 's_mov_b32', 'exec_lo')` independently of the restore-side `s21` check. - **Dead condition**: Removed the redundant `branch <= guard + 1` check in `Stage.execz_scalar_exit` (when `branch == guard + 1`, `ins[branch - 1]` is `s_cbranch_execz` and already rejected by the `s_andn2_b32` check). Verified locally: `python3 -B tests/startup_gfx2hlsl_compute_check.py` passes, and single-edit mutation checks confirm both `x * y * z >= 32` and removing the pre-guard `saved_exec` check are now caught.
R0Y00 commented 2026-11-27 11:48:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T11:48:08Z.

Review: APPROVED


Reviewed 491d0fd0 in the planned main integration after #3041, #3043 and #3044 (tree 1fd75c1b). The translator, modified-descriptor, cselect-descnum, readfirstlane-uniform, join-symbols, same-register saveexec, mesh dynamic and mesh clip/cull Python checks passed. The original emitted shader compiled with SDK DXC (-Ges -WX -T cs_6_0 -E main) at 3, 8 and 32 threads. For GPU readback I substituted the two fixed entry constants for the cbuffer so the existing offscreen_check --raw-uav-dump could bind only the UAV. With both Debug and Release /O2 renderers, WARP and RTX matched 9 in lanes 0–2 and 0x13579bdf ^ lane in later lanes, at all three workgroup sizes. Mutating the final EXEC restore to zero broke all four adapter/configuration combinations for every size. The integration tree emits identical HLSL for the three sources I used. Windows 11 26200.9974, SDK DXC 10.0.26100, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, debug layer enabled with no errors or warnings. Hosted Windows, Linux Python and gfx1013 checks passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6087663750 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#pullrequestreview-6087663750). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T11:48:08Z. **Review:** APPROVED --- Reviewed `491d0fd0` in the planned `main` integration after #3041, #3043 and #3044 (tree `1fd75c1b`). The translator, modified-descriptor, cselect-descnum, readfirstlane-uniform, join-symbols, same-register saveexec, mesh dynamic and mesh clip/cull Python checks passed. The original emitted shader compiled with SDK DXC (`-Ges -WX -T cs_6_0 -E main`) at 3, 8 and 32 threads. For GPU readback I substituted the two fixed entry constants for the cbuffer so the existing `offscreen_check --raw-uav-dump` could bind only the UAV. With both Debug and Release /O2 renderers, WARP and RTX matched 9 in lanes 0–2 and `0x13579bdf ^ lane` in later lanes, at all three workgroup sizes. Mutating the final EXEC restore to zero broke all four adapter/configuration combinations for every size. The integration tree emits identical HLSL for the three sources I used. Windows 11 26200.9974, SDK DXC 10.0.26100, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, debug layer enabled with no errors or warnings. Hosted Windows, Linux Python and gfx1013 checks passed.
thepatrickworld commented 2026-11-27 12:10:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T12:10:23Z.


Independent Linux host-only result on the merged tree 298a2034: the three review points are pinned, not only applied

Environment and scope

#2900 was squashed onto main as 298a2034 (11:49Z) while this measurement was running, so this is a post-merge receipt: everything below was re-run on that merged tree, in a clean worktree (git status --porcelain --untracked-files=no empty). Line numbers are the merged tree's. Stage.execz_scalar_exit is byte-identical between the last PR head 491d0fd0 and 298a2034 (71 lines, sha256 c6419b4a2ac392e4118af1b87ab005ce9766ae7bee89dbe583a81f0d4e8874ba, lines 2992-3062 and 3184-3254, LF-normalised), and so is check_execz_exit_run (84 lines, sha256 04f1597fa53cc4168c8ca3aa454cb09b0e30fb00e283363783abebbac67cbe56, lines 1168-1251 in both), so the numbers are the merged code's own.

Linux host, no GPU: no D3D12 dispatch and no _hardware entry ran; this is Python-only, translator and fixture. python3 -B tests/startup_gfx2hlsl_compute_check.py passes on the merged tree. The 210-script python-linux step of .github/workflows/windows.yml gives at 491d0fd0 196 ok, 13 failing and 1 skipped, and the same 13 fail identically on this PR's base 6ee878d8, all of them on a missing module in this host's interpreter (11 pefile, 2 iced_x86); none of the 13 mentions gfx2hlsl.

Method

One fixture (check_execz_exit_run), one edit of Stage.execz_scalar_exit at a time. For each edit, chk.refused is replaced by a recorder that runs every build() and classifies it instead of stopping at the first failure, which yields a verdict for each of the 20 refusal entries (2 group bounds, 16 byte edits, 2 closures over an outer program); the accepted calls report the fixture line where they die. The two edits this follow-up turns on also run against the pre-fix pair (022212aa translator and fixture), so "green before" is about the state a reader would check out and not about a hybrid tree; the others run against the merged pair and against that pair with only the fixture swapped for 022212aa's.

Results

  • Accepted bound edge (3194). Making the bound reject 32 (x * y * z > 32 → >= 32) is green on the pre-fix pair and red at fixture line 1202 on the merged tree. With line 1202 removed at 491d0fd0, the same edit leaves the whole 210-script python-linux list at its result (196 ok, the same 13 environment failures), so that line is the only catcher in it. On the merged tree, 32 is accepted (11 331 characters of HLSL emitted), while 33, 64 and (32, 2, 1) are refused.
  • Pre-guard save proof (3217). Deleting those two lines is green on the pre-fix pair's check_execz_exit_run, and on the merged tree turns exactly one of the 20 entries from refused to accepted — the new byte-36 s_mov_b32 s0, 0. The byte-28 entry stays refused under that edit, and deleting the restore re-proof (3245) instead flips only byte 28 and is red on both fixtures: the two sites are pinned separately. A sys.settrace pass shows the byte-36 entry reaching the pre-guard call at 3217, the last frames of saved_exec at 3212-3214, then return False at 3218, while the unmutated program continues past 3217 into 3219-3251 and the restore proof at 3245-3246, so that entry is refused by the pre-guard proof and not by another catcher that shares the message.
  • Dead condition. Restoring branch <= guard + 1 at 3194 changes nothing: all 20 entries keep their verdict and every accepted call still translates, on both fixtures. It can only be branch == guard + 1, and then ins[branch - 1] is the s_cbranch_execz that the caller's loop (3117) selected as guard, whose shape test (3198) returns the same False; the removal cannot change a refusal.

Limits

Host translation only: nothing compiled or executed. The oracle is the fixture of the same commit, so a killed edit shows the fixture sees the change, not that its expectation is right. Every internal refusal shares one message, so a refused entry can pass for a reason other than the one its comment names; the per-entry table is what separates them here. Under the accepted-edge edit the run aborts at line 1202, so the 20 refusal entries are not measured under that edit. The program's pre-guard save is the s_and_saveexec_b32 form; a pre-guard save written as s_mov_b32 sX, exec_lo is accepted by the same proof and no fixture program uses it (that branch of saved_exec is pinned at the restore site, by the byte-28 entry). The edits are mine.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7217924168 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2900#issuecomment-7217924168). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-27T12:10:23Z. --- **Independent Linux host-only result on the merged tree `298a2034`: the three review points are pinned, not only applied** ### Environment and scope `#2900` was squashed onto `main` as `298a2034` (11:49Z) while this measurement was running, so this is a post-merge receipt: everything below was re-run on that merged tree, in a clean worktree (`git status --porcelain --untracked-files=no` empty). Line numbers are the merged tree's. `Stage.execz_scalar_exit` is byte-identical between the last PR head `491d0fd0` and `298a2034` (71 lines, sha256 `c6419b4a2ac392e4118af1b87ab005ce9766ae7bee89dbe583a81f0d4e8874ba`, lines 2992-3062 and 3184-3254, LF-normalised), and so is `check_execz_exit_run` (84 lines, sha256 `04f1597fa53cc4168c8ca3aa454cb09b0e30fb00e283363783abebbac67cbe56`, lines 1168-1251 in both), so the numbers are the merged code's own. Linux host, no GPU: no D3D12 dispatch and no `_hardware` entry ran; this is Python-only, translator and fixture. `python3 -B tests/startup_gfx2hlsl_compute_check.py` passes on the merged tree. The 210-script `python-linux` step of `.github/workflows/windows.yml` gives at `491d0fd0` 196 ok, 13 failing and 1 skipped, and the same 13 fail identically on this PR's base `6ee878d8`, all of them on a missing module in this host's interpreter (11 `pefile`, 2 `iced_x86`); none of the 13 mentions `gfx2hlsl`. ### Method One fixture (`check_execz_exit_run`), one edit of `Stage.execz_scalar_exit` at a time. For each edit, `chk.refused` is replaced by a recorder that runs every `build()` and classifies it instead of stopping at the first failure, which yields a verdict for each of the 20 refusal entries (2 group bounds, 16 byte edits, 2 closures over an outer program); the accepted calls report the fixture line where they die. The two edits this follow-up turns on also run against the pre-fix pair (`022212aa` translator and fixture), so "green before" is about the state a reader would check out and not about a hybrid tree; the others run against the merged pair and against that pair with only the fixture swapped for `022212aa`'s. ### Results - **Accepted bound edge (3194).** Making the bound reject 32 (`x * y * z > 32` → `>= 32`) is green on the pre-fix pair and **red at fixture line 1202** on the merged tree. With line 1202 removed at `491d0fd0`, the same edit leaves the whole 210-script `python-linux` list at its result (196 ok, the same 13 environment failures), so that line is the only catcher in it. On the merged tree, 32 is accepted (11 331 characters of HLSL emitted), while 33, 64 and (32, 2, 1) are refused. - **Pre-guard save proof (3217).** Deleting those two lines is green on the pre-fix pair's `check_execz_exit_run`, and on the merged tree turns exactly one of the 20 entries from refused to **accepted** — the new byte-36 `s_mov_b32 s0, 0`. The byte-28 entry stays refused under that edit, and deleting the restore re-proof (3245) instead flips only byte 28 and is red on both fixtures: the two sites are pinned separately. A `sys.settrace` pass shows the byte-36 entry reaching the pre-guard call at 3217, the last frames of `saved_exec` at 3212-3214, then `return False` at 3218, while the unmutated program continues past 3217 into 3219-3251 and the restore proof at 3245-3246, so that entry is refused by the pre-guard proof and not by another catcher that shares the message. - **Dead condition.** Restoring `branch <= guard + 1` at 3194 changes nothing: all 20 entries keep their verdict and every accepted call still translates, on both fixtures. It can only be `branch == guard + 1`, and then `ins[branch - 1]` is the `s_cbranch_execz` that the caller's loop (3117) selected as `guard`, whose shape test (3198) returns the same `False`; the removal cannot change a refusal. ### Limits Host translation only: nothing compiled or executed. The oracle is the fixture of the same commit, so a killed edit shows the fixture sees the change, not that its expectation is right. Every internal refusal shares one message, so a refused entry can pass for a reason other than the one its comment names; the per-entry table is what separates them here. Under the accepted-edge edit the run aborts at line 1202, so the 20 refusal entries are not measured under that edit. The program's pre-guard save is the `s_and_saveexec_b32` form; a pre-guard save written as `s_mov_b32 sX, exec_lo` is accepted by the same proof and no fixture program uses it (that branch of `saved_exec` is pinned at the restore site, by the byte-28 entry). The edits are mine. _AI-assisted._
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!2900
No description provided.