Skip to content

Shaders: resolve loop-carried inputs of console EXEC mask phis - #6

Closed
ifBars wants to merge 1 commit into
r4tedx:shader/console-flow-ldsfrom
ifBars:fix/console-mask-phi-inputs
Closed

ifBars wants to merge 1 commit into
r4tedx:shader/console-flow-ldsfrom
ifBars:fix/console-mask-phi-inputs

Conversation

@ifBars

@ifBars ifBars commented Nov 24, 2026

Copy link
Copy Markdown

This targets shader/console-flow-lds in support of Marvisak#439 and the four instance-culling programs discussed in Marvisak#71.

A loop header can join an EXEC value from a latch whose mask is itself a phi. The first walk visits the header before it tracks that incoming value. The console-flow pass now records the inputs of nontrivial mask phis and resolves them after that walk, when the loop header is available. The authored lane-read loop regression adds a latch that selects between two live masks.

With just the regression on e6936e3, emission fails at byte 40 with “a lane-mask join of an untracked mask.” With this change, the compiler emits 32-lane DXIL. In a separate Agility 620 WARP test harness, the single 64-thread dispatch returned all 64 expected words (40 through 103).

The clean commit adds no SDK build configuration. The clean local run passed 66 shader tests with 33 filtered. A separate WARP harness passed 73 with 26 filtered. Seven existing tests in the wider clean run require shader model 6.6, unavailable with that system runtime.

For an offline compiler check, we also tested this change in a private build with Marvisak#193's stride lowering. All four reported programs failed at their loop joins before the change. Afterward the Windows SDK validator accepted all four with compute PSV wave limits 32..32. Their runtime descriptor bindings and scene output are still unverified. Only authored test shaders were dispatched on WARP.

AI-assisted implementation and testing.

A loop-carried EXEC phi can depend on a latch phi that is not otherwise used. Discover deferred inputs before emitting mask phis, including inputs discovered while walking the deferred worklist. Extend the authored lane-read loop fixture by adding a second predecessor of the latch.
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Taken into shader/console-flow-lds as 9e98b2b (your commit and authorship, cherry-picked onto d2189ff because the base had moved; no conflict), with 901eef9 after it. It shows as closed here, and is in Marvisak#439 now. Thank you: this is the gap behind a lane-mask join of an untracked mask.

Review. In the console structure a join resolves only the masks arriving on forward edges; a back-edge input that is itself a join, and that nothing else reads as a mask, was never tracked, so the lowering had no boolean for it. Recording the inputs and resolving them after the walk is the smallest change that fixes it. The resolution only follows forward edges, so it cannot recurse through the loop. The per-lane structure is untouched (console only).

Tested on an RTX 5070 (32..32) and a Radeon iGPU (32..64), Windows 11:

  • Your test emitted but skipped its dispatch here, as on any machine: WARP has 4-lane waves. 901eef9 makes it run like the other lane-read loop test, on every hardware adapter, validated and compared lane by lane. Exact on both (the RTX runs it as two 32-lane waves).
  • With the structure change taken out, the test stops with a lane-mask join of an untracked mask at byte 40, as you describe.
  • cargo test --workspace: 296 passed, 0 failed, 4 ignored. The title was not used in these tests.

Measured locally (local title data, offline translate --host-lanes 32-32 --validate --list, CPU only; counts only), d2189ff against 901eef9: 9 more compute programs translate (1,676 to 1,685), 6 of them validate and 3 are in the compute sample class that Marvisak#180 fixes; 0 that translated before stop. No change for a 32..64 host. I have not checked your four programs by hash; with the stride lowering of Marvisak#193 absent from this stack they still stop on that reason here.

AI-assisted (Claude Code).

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.

2 participants