startup: accept sample_b and get_lod under entry EXEC after a join #2659

Manually merged
github merged 4 commits from gh-pr/2659/head into gh-pr/2659/base 2026-11-27 01:11:58 +00:00
Owner

@⁠SimSalabimse on GitHub · 2026-11-26 00:59 UTC · original
SimSalabimse:cursor/sample-b-lod-entry-exec-e885 → main · +165 −31 · 5 files · 4 commits · merged 2026-11-26 02:26 UTC

Change

Refs #2618 (batch M200-01, work codes B and L).

image_sample_b and image_get_lod refused any prior branch target even when EXEC was still the entry mask — the M200-01 shape “outside straight-line with every lane active.”

  • Drop the blocks gate in Stage.image for both forms; keep pixel stage + exec_known.
  • Uniform forward join (or a fall-through branch) before the op is accepted.
  • Divergent EXEC before the op stays refused.
  • startup_image_sample_b_check.py: join control + WARP draw of join-before bias -1 (same mip as plain).
  • startup_gfx2hlsl_image_get_lod_check.py: join/branch accept; divergent EXEC refusal.

AI-assisted.

Verification

Commit under test: this PR head.

python3 -B tests/startup_image_sample_b_check.py
python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py
python3 -B tests/docs_links_check.py

All passed on Linux. This agent could not run DXC / WARP / hardware draws.

Windows verification:

ctest --preset dev --no-tests=error -R '^(startup_image_sample_b|startup_gfx2hlsl_image_get_lod)' -V

Expect: controls pass; startup_image_sample_b_warp includes the join-before bias -1 case; hardware may pass or skip 77.

Evidence and follow-up

  • Source-built fixtures only; no retail bytes.
  • Negative control: divergent EXEC before the op still refused.
  • Does not claim the 12 B + 6 L capture rows are replayed; needs a capture root.
  • Independent of #2657 (DPP).

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.
**@⁠SimSalabimse** on GitHub · 2026-11-26 00:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659) `SimSalabimse:cursor/sample-b-lod-entry-exec-e885` → `main` · +165 −31 · 5 files · 4 commits · merged 2026-11-26 02:26 UTC ## Change Refs #2618 (batch M200-01, work codes B and L). `image_sample_b` and `image_get_lod` refused any prior branch target even when EXEC was still the entry mask — the M200-01 shape “outside straight-line with every lane active.” - Drop the `blocks` gate in `Stage.image` for both forms; keep pixel stage + `exec_known`. - Uniform forward join (or a fall-through branch) before the op is accepted. - Divergent EXEC before the op stays refused. - `startup_image_sample_b_check.py`: join control + WARP draw of join-before bias -1 (same mip as plain). - `startup_gfx2hlsl_image_get_lod_check.py`: join/branch accept; divergent EXEC refusal. AI-assisted. ## Verification Commit under test: this PR head. ```bash python3 -B tests/startup_image_sample_b_check.py python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py python3 -B tests/docs_links_check.py ``` All passed on Linux. This agent could not run DXC / WARP / hardware draws. Windows verification: ```powershell ctest --preset dev --no-tests=error -R '^(startup_image_sample_b|startup_gfx2hlsl_image_get_lod)' -V ``` Expect: controls pass; `startup_image_sample_b_warp` includes the join-before bias -1 case; hardware may pass or skip **77**. ## Evidence and follow-up - Source-built fixtures only; no retail bytes. - Negative control: divergent EXEC before the op still refused. - Does not claim the 12 B + 6 L capture rows are replayed; needs a capture root. - Independent of #2657 (DPP). ## 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.
image_sample_b and image_get_lod refused any prior branch target even when
EXEC was still the entry mask (M200-01 B/L: outside straight-line with every
lane active). Drop the blocks gate; keep the pixel + exec_known proof.
Fixtures: uniform join before the op accepted; divergent EXEC refused;
WARP draw of join-before sample_b bias -1.

Refs #2618

Co-authored-by: SimSalabimse <[email protected]>
Review on #2659: dropping only the blocks gate accepted vcc/exec
branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf
(cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse
vccz/vccnz/execz/execnz before the op in both fixtures.

Refs #2618

Co-authored-by: SimSalabimse <[email protected]>
A divergent backward branch after the read still lets lanes of one quad leave the loop at different passes, so the read runs again with uneven quads although no divergent branch precedes it in program order. Record the read sites and the divergent back edges and refuse a read that one of them spans. Tests: synthetic words with s_cbranch_vccnz/execnz right after the read, back to it (fail before, pass after).
#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms).
The negative control still expected only one non-IndexError survivor.

Co-authored-by: SimSalabimse <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:11:57 +00:00
github manually merged commit c8e0537584 into gh-pr/2659/base 2026-11-27 01:11:58 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 01:01 UTC · original · reviewed

Review of head 524873c5 (after update with main). Fixture-level review only; no executable or capture-row claims.

Finding (blocks merge): dropping the blocks gate accepts divergent branches, not only uniform joins.

tools/startup/gfx2hlsl.py (the image_sample_b and image_get_lod guards in Stage.image, about lines 5088-5110) now checks only kind == 'ps' and exec_known. Nothing clears exec_known on a branch, and the branch lowering (about line 3096) uses the per-lane bits (vcc & 1) == 0, (vcc & 1) != 0, (exec & 1) == 0. In the emitted HLSL, lanes of one quad can therefore take different pc paths before the SampleBias / CalculateLevelOfDetail call. Those calls need uniform control flow for their derivatives. The plain sample keeps SampleLevel(..., 0) whenever blocks is non-empty (line ~5214), for the same reason.

Reproduced on this head: I took the plain sample_b fixture and inserted s_mov_b32 s0,s0; s_cbranch_<cond> +1; s_mov_b32 s1,s1 before the sample. s_cbranch_vccz, s_cbranch_vccnz, s_cbranch_execz and s_cbranch_scc1 are ALL accepted and emit SampleBias inside the pc == state machine. Only scc has a uniformity notion (scc_uniform); vcc/exec branches have none here.

Why the new tests miss it: the "join" fixture uses only an scc1 branch, and the "divergent" control only clears exec_lo (which already cleared exec_known before this PR). No control puts a vcc/exec-conditioned branch before the sample.

Suggested fix: accept the join only when every branch before the op is proven wave-uniform (for example scc with scc_uniform, or a compare whose sources are uniform, as already tracked in uniform_vcc_compares), refuse otherwise, and add a negative control with s_cbranch_vccz / execz before the sample in both check files.

Smaller points

  • check_guards in tests/startup_image_sample_b_check.py: the new "accepted after a join" case swallows AttributeError, so it passes even if the call fails for an unrelated reason. The WARP draw case is the real guard there.
  • The WARP draw for the join case was not run by this review (no Windows run); it must pass on Windows before any merge.

Checked (Linux, detached worktree at this head)

  • python3 -B tests/startup_image_sample_b_check.py: pass
  • python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py: pass
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • Branch-condition probe above: vccz/vccnz/execz/scc1 all accepted.

Not merging. Leaving this for the author to tighten the uniformity condition.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 01:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067149310) · **reviewed** Review of head 524873c5 (after update with main). Fixture-level review only; no executable or capture-row claims. **Finding (blocks merge): dropping the `blocks` gate accepts divergent branches, not only uniform joins.** `tools/startup/gfx2hlsl.py` (the `image_sample_b` and `image_get_lod` guards in `Stage.image`, about lines 5088-5110) now checks only `kind == 'ps'` and `exec_known`. Nothing clears `exec_known` on a branch, and the branch lowering (about line 3096) uses the per-lane bits `(vcc & 1) == 0`, `(vcc & 1) != 0`, `(exec & 1) == 0`. In the emitted HLSL, lanes of one quad can therefore take different `pc` paths before the `SampleBias` / `CalculateLevelOfDetail` call. Those calls need uniform control flow for their derivatives. The plain sample keeps `SampleLevel(..., 0)` whenever `blocks` is non-empty (line ~5214), for the same reason. Reproduced on this head: I took the plain `sample_b` fixture and inserted `s_mov_b32 s0,s0; s_cbranch_<cond> +1; s_mov_b32 s1,s1` before the sample. `s_cbranch_vccz`, `s_cbranch_vccnz`, `s_cbranch_execz` and `s_cbranch_scc1` are ALL accepted and emit `SampleBias` inside the `pc ==` state machine. Only `scc` has a uniformity notion (`scc_uniform`); vcc/exec branches have none here. Why the new tests miss it: the "join" fixture uses only an `scc1` branch, and the "divergent" control only clears `exec_lo` (which already cleared `exec_known` before this PR). No control puts a vcc/exec-conditioned branch before the sample. Suggested fix: accept the join only when every branch before the op is proven wave-uniform (for example `scc` with `scc_uniform`, or a compare whose sources are uniform, as already tracked in `uniform_vcc_compares`), refuse otherwise, and add a negative control with `s_cbranch_vccz` / `execz` before the sample in both check files. **Smaller points** - `check_guards` in `tests/startup_image_sample_b_check.py`: the new "accepted after a join" case swallows `AttributeError`, so it passes even if the call fails for an unrelated reason. The WARP draw case is the real guard there. - The WARP draw for the join case was not run by this review (no Windows run); it must pass on Windows before any merge. **Checked (Linux, detached worktree at this head)** - `python3 -B tests/startup_image_sample_b_check.py`: pass - `python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py`: pass - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - Branch-condition probe above: vccz/vccnz/execz/scc1 all accepted. Not merging. Leaving this for the author to tighten the uniformity condition. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 02:03 UTC · original

Pushed 3c56f5878 on top of 697419db (no force).

What: uniform_cf only looks at branches that come before the read in program order. A divergent backward branch placed after the read (loop with a per-lane exit) still lets lanes of one quad leave the loop on different passes, so SampleBias / CalculateLevelOfDetail ran again with uneven quads and was accepted. The translator now records the read sites and the divergent back edges and refuses a read that one of them spans. Your uniform cases are unchanged.

Why: implicit derivatives need all four lanes of the quad at the call together.

Tests: startup_image_sample_b_check.py and startup_gfx2hlsl_image_get_lod_check.py get synthetic words with s_cbranch_vccnz / s_cbranch_execnz right after the read, jumping back to it. They fail on 697419db and pass with the change.

Commands executed locally:

  • python3 -I tests/startup_image_sample_b_check.py, python3 -I tests/startup_gfx2hlsl_image_get_lod_check.py (fail before, pass after)
  • python3 x2w_pipe.py win2025 2659 --patch <diff> --force-reconfigure --regex 'startup_image_sample_b|startup_gfx2hlsl_image_get_lod|startup_image_sample_lod' on Win2025 (default slots, dev build, release skipped by the fast path): 7/7 passed (sample_b controls/warp/hardware, get_lod controls, sample_lod controls/warp/hardware)

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 02:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659#issuecomment-7180410035) Pushed 3c56f5878 on top of 697419db (no force). What: `uniform_cf` only looks at branches that come before the read in program order. A divergent backward branch placed after the read (loop with a per-lane exit) still lets lanes of one quad leave the loop on different passes, so `SampleBias` / `CalculateLevelOfDetail` ran again with uneven quads and was accepted. The translator now records the read sites and the divergent back edges and refuses a read that one of them spans. Your uniform cases are unchanged. Why: implicit derivatives need all four lanes of the quad at the call together. Tests: `startup_image_sample_b_check.py` and `startup_gfx2hlsl_image_get_lod_check.py` get synthetic words with `s_cbranch_vccnz` / `s_cbranch_execnz` right after the read, jumping back to it. They fail on 697419db and pass with the change. Commands executed locally: - `python3 -I tests/startup_image_sample_b_check.py`, `python3 -I tests/startup_gfx2hlsl_image_get_lod_check.py` (fail before, pass after) - `python3 x2w_pipe.py win2025 2659 --patch <diff> --force-reconfigure --regex 'startup_image_sample_b|startup_gfx2hlsl_image_get_lod|startup_image_sample_lod'` on Win2025 (default slots, dev build, release skipped by the fast path): 7/7 passed (sample_b controls/warp/hardware, get_lod controls, sample_lod controls/warp/hardware) AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 02:08 UTC · original · reviewed

Review of head 3c56f587 (independent, code + fixture tests).

Checked:

  • Stage.image: the old len(self.blocks) > 0 gate is replaced by a wave-uniform control-flow flag (uniform_cf), still requiring pixel stage and a known entry EXEC. Divergent branches before the read clear the flag, so those reads stay refused.
  • The follow-up commit closes the divergent back edge after the read (loop with a per-lane exit): the read sites and divergent back edges are recorded, and a read spanned by one is refused. Logic looks right for both image_sample_b and image_get_lod.
  • No other open or merged PR covers this slice (searched sample_b / get_lod). Independent of #2657.
  • Scope: claims only source-built fixtures, no startup claim, so no executable result is needed here.

Commands run (Linux, on the exact head):

  • python3 -B tests/startup_image_sample_b_check.py and tests/startup_gfx2hlsl_image_get_lod_check.py: pass
  • python3 -B tests/docs_links_check.py, python3 -B tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • Mutation 1: force the uniform-CF gate to always accept -> both tests fail.
  • Mutation 2: disable the back-edge refusal -> both tests fail.

Verdict: sound, no blocking findings. Windows dev+release receipt follows separately.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 02:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067609184) · **reviewed** Review of head 3c56f587 (independent, code + fixture tests). Checked: - `Stage.image`: the old `len(self.blocks) > 0` gate is replaced by a wave-uniform control-flow flag (`uniform_cf`), still requiring pixel stage and a known entry EXEC. Divergent branches before the read clear the flag, so those reads stay refused. - The follow-up commit closes the divergent back edge after the read (loop with a per-lane exit): the read sites and divergent back edges are recorded, and a read spanned by one is refused. Logic looks right for both `image_sample_b` and `image_get_lod`. - No other open or merged PR covers this slice (searched sample_b / get_lod). Independent of #2657. - Scope: claims only source-built fixtures, no startup claim, so no executable result is needed here. Commands run (Linux, on the exact head): - `python3 -B tests/startup_image_sample_b_check.py` and `tests/startup_gfx2hlsl_image_get_lod_check.py`: pass - `python3 -B tests/docs_links_check.py`, `python3 -B tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - Mutation 1: force the uniform-CF gate to always accept -> both tests fail. - Mutation 2: disable the back-edge refusal -> both tests fail. Verdict: sound, no blocking findings. Windows dev+release receipt follows separately. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 02:12 UTC · original · reviewed

Review of head 02c8188c (rebase of 3c56f587 onto current main).

  • git range-diff of the three PR commits against the previous head: all three are identical (=), so my earlier review of 3c56f587 carries over unchanged.
  • Re-ran on this exact head: tests/startup_image_sample_b_check.py, tests/startup_gfx2hlsl_image_get_lod_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py all pass; git diff --check origin/main...HEAD clean.

No blocking findings. Windows dev+release receipt for this head follows.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 02:12 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067640305) · **reviewed** Review of head 02c8188c (rebase of 3c56f587 onto current main). - `git range-diff` of the three PR commits against the previous head: all three are identical (`=`), so my earlier review of 3c56f587 carries over unchanged. - Re-ran on this exact head: `tests/startup_image_sample_b_check.py`, `tests/startup_gfx2hlsl_image_get_lod_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py` all pass; `git diff --check origin/main...HEAD` clean. No blocking findings. Windows dev+release receipt for this head follows. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 02:18 UTC · original

Win2025 run on #2659 (heads 02c8188c, then 31913ad3 after another rebase; the PR's own three commits are identical by range-diff) did not produce a pass:

  • Run 1 (02c8188c): tests/startup_run_ps1_check.py failed ("translator's child process was still running after run.ps1 exited"). The PR does not touch it.
  • Run 2: tests/startup_gfx2hlsl_scalar_table_arity_check.py failed ("control: without the guard the short form raises IndexError: MISMATCH 37 of 40"). The same check also fails on current origin/main (2ab3c9e8) in a plain checkout, so it is not caused by this PR; it comes from the table change in #2515 / a later main commit.

So no Win2025 dev+release receipt for this PR yet. The PR's own tests (startup_image_sample_b, startup_gfx2hlsl_image_get_lod) pass on Linux on the current head. Not merging until main is green for that check.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 02:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2659#issuecomment-7180664684) Win2025 run on #2659 (heads 02c8188c, then 31913ad3 after another rebase; the PR's own three commits are identical by range-diff) did not produce a pass: - Run 1 (02c8188c): `tests/startup_run_ps1_check.py` failed ("translator's child process was still running after run.ps1 exited"). The PR does not touch it. - Run 2: `tests/startup_gfx2hlsl_scalar_table_arity_check.py` failed ("control: without the guard the short form raises IndexError: MISMATCH 37 of 40"). The same check also fails on current origin/main (2ab3c9e8) in a plain checkout, so it is not caused by this PR; it comes from the table change in #2515 / a later main commit. So no Win2025 dev+release receipt for this PR yet. The PR's own tests (`startup_image_sample_b`, `startup_gfx2hlsl_image_get_lod`) pass on Linux on the current head. Not merging until main is green for that check. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.