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

Merged
SimSalabimse merged 4 commits from upstream-pr/2659 into main 2026-11-26 02:26:16 +00:00
SimSalabimse commented 2026-11-26 00:59:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T00:59:15Z.


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617051877 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T00:59:15Z. --- ## 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.
tedin7 commented 2026-11-26 01:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:01:59Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067149310 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067149310). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T01:01:59Z. **Review:** COMMENTED --- 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 commented 2026-11-26 02:05:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:03:07Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7180410035 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659#issuecomment-7180410035). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:03:07Z. --- 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.
upstream-sync closed this pull request 2026-11-26 03:03:03 +00:00
tedin7 commented 2026-11-26 03:03:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:08:05Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067609184 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067609184). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:08:05Z. **Review:** COMMENTED --- 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 commented 2026-11-26 03:03:04 +00:00 (Migrated from github.com)

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

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067640305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659#pullrequestreview-6067640305). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:12:50Z. **Review:** COMMENTED --- 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 commented 2026-11-26 03:03:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:18:00Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7180664684 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2659#issuecomment-7180664684). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:18:00Z. --- 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.
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!2651
No description provided.