Skip to content

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

Merged
tedin7 merged 4 commits into
R0Y00:mainfrom
SimSalabimse:cursor/sample-b-lod-entry-exec-e885
Nov 26, 2026
Merged

tedin7 merged 4 commits into
R0Y00:mainfrom
SimSalabimse:cursor/sample-b-lod-entry-exec-e885

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 524873c (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.

cursor Bot pushed a commit to SimSalabimse/Xbox2Windows that referenced this pull request Nov 26, 2026
Review on R0Y00#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 R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
cursor Bot pushed a commit to SimSalabimse/Xbox2Windows that referenced this pull request Nov 26, 2026
Review on R0Y00#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 R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/sample-b-lod-entry-exec-e885 branch from e08e81a to 697419d Compare November 26, 2026 01:47
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Pushed 3c56f58 on top of 697419d (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 697419d 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 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 3c56f58 (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.

cursor Bot pushed a commit to SimSalabimse/Xbox2Windows that referenced this pull request Nov 26, 2026
Review on R0Y00#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 R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/sample-b-lod-entry-exec-e885 branch from 3c56f58 to 02c8188 Compare November 26, 2026 02:09

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 02c8188 (rebase of 3c56f58 onto current main).

  • git range-diff of the three PR commits against the previous head: all three are identical (=), so my earlier review of 3c56f58 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.

cursoragent and others added 3 commits November 26, 2026 02:15
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 R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Review on R0Y00#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 R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
…ack edge

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).
@cursor
cursor Bot force-pushed the cursor/sample-b-lod-entry-exec-e885 branch from 02c8188 to 31913ad Compare November 26, 2026 02:15
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

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

  • Run 1 (02c8188): 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 (2ab3c9e) in a plain checkout, so it is not caused by this PR; it comes from the table change in gfx2hlsl: refuse a scalar ALU source list shorter than the table template uses #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.

R0Y00#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 <SimSalabimse@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants