startup: accept sample_b and get_lod under entry EXEC after a join #2651
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2659"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_bandimage_get_lodrefused any prior branch target even when EXEC was still the entry mask — the M200-01 shape “outside straight-line with every lane active.”blocksgate inStage.imagefor both forms; keep pixel stage +exec_known.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.
All passed on Linux. This agent could not run DXC / WARP / hardware draws.
Windows verification:
Expect: controls pass;
startup_image_sample_b_warpincludes the join-before bias -1 case; hardware may pass or skip 77.Evidence and follow-up
Checklist
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
blocksgate accepts divergent branches, not only uniform joins.tools/startup/gfx2hlsl.py(theimage_sample_bandimage_get_lodguards inStage.image, about lines 5088-5110) now checks onlykind == 'ps'andexec_known. Nothing clearsexec_knownon 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 differentpcpaths before theSampleBias/CalculateLevelOfDetailcall. Those calls need uniform control flow for their derivatives. The plain sample keepsSampleLevel(..., 0)wheneverblocksis non-empty (line ~5214), for the same reason.Reproduced on this head: I took the plain
sample_bfixture and inserteds_mov_b32 s0,s0; s_cbranch_<cond> +1; s_mov_b32 s1,s1before the sample.s_cbranch_vccz,s_cbranch_vccnz,s_cbranch_execzands_cbranch_scc1are ALL accepted and emitSampleBiasinside thepc ==state machine. Onlyscchas a uniformity notion (scc_uniform); vcc/exec branches have none here.Why the new tests miss it: the "join" fixture uses only an
scc1branch, and the "divergent" control only clearsexec_lo(which already clearedexec_knownbefore 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
sccwithscc_uniform, or a compare whose sources are uniform, as already tracked inuniform_vcc_compares), refuse otherwise, and add a negative control withs_cbranch_vccz/execzbefore the sample in both check files.Smaller points
check_guardsintests/startup_image_sample_b_check.py: the new "accepted after a join" case swallowsAttributeError, so it passes even if the call fails for an unrelated reason. The WARP draw case is the real guard there.Checked (Linux, detached worktree at this head)
python3 -B tests/startup_image_sample_b_check.py: passpython3 -B tests/startup_gfx2hlsl_image_get_lod_check.py: passpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: cleanNot merging. Leaving this for the author to tighten the uniformity condition.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:03:07Z.
Pushed
3c56f5878on top of697419db(no force).What:
uniform_cfonly 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, soSampleBias/CalculateLevelOfDetailran 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.pyandstartup_gfx2hlsl_image_get_lod_check.pyget synthetic words withs_cbranch_vccnz/s_cbranch_execnzright after the read, jumping back to it. They fail on697419dband 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.
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 oldlen(self.blocks) > 0gate 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.image_sample_bandimage_get_lod.Commands run (Linux, on the exact head):
python3 -B tests/startup_image_sample_b_check.pyandtests/startup_gfx2hlsl_image_get_lod_check.py: passpython3 -B tests/docs_links_check.py,python3 -B tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: cleanVerdict: sound, no blocking findings. Windows dev+release receipt follows separately.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:12:50Z.
Review: COMMENTED
Review of head 02c8188c (rebase of
3c56f587onto current main).git range-diffof the three PR commits against the previous head: all three are identical (=), so my earlier review of3c56f587carries over unchanged.tests/startup_image_sample_b_check.py,tests/startup_gfx2hlsl_image_get_lod_check.py,tests/docs_links_check.py,tests/bidi_controls_check.pyall pass;git diff --check origin/main...HEADclean.No blocking findings. Windows dev+release receipt for this head follows.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:18:00Z.
Win2025 run on #2659 (heads 02c8188c, then
31913ad3after another rebase; the PR's own three commits are identical by range-diff) did not produce a pass:tests/startup_run_ps1_check.pyfailed ("translator's child process was still running after run.ps1 exited"). The PR does not touch it.tests/startup_gfx2hlsl_scalar_table_arity_check.pyfailed ("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.