Skip to content

Require descriptor comparisons to gate EXEC at each waterfall access - #3

Closed
MichaelSmithAI wants to merge 2 commits into
r4tedx:shader/per-lane-phifrom
MichaelSmithAI:fix/waterfall-exec-gate
Closed

MichaelSmithAI wants to merge 2 commits into
r4tedx:shader/per-lane-phifrom
MichaelSmithAI:fix/waterfall-exec-gate

Conversation

@MichaelSmithAI

@MichaelSmithAI MichaelSmithAI commented Nov 24, 2026 •

Copy link
Copy Markdown

A reviewer of Marvisak#566 found a shader that samples with the first active lane's descriptor even though the loop compares every lane's descriptor with it. The comparison result never narrows EXEC before the sample. The current matcher accepts the loop and emits a per-lane handle, changing which texture some lanes sample.

This change checks the mask at each resource access. It follows positive mask conjunctions back to the descriptor equality comparisons and requires coverage for every descriptor dword. For wave64 the same comparison must contribute to both halves of EXEC. When the check cannot establish that, resource tracking returns the existing unsupported reason.

The wave32 regression compares two versions of the joined-descriptor fixture. The gated version lowers with one nonuniform handle. The version that saves EXEC without narrowing it is refused. The wave64 control checks the original fixture and a variant that restores only the upper lanes before the access.

The second commit addresses a loop that masks the access correctly, then clears EXEC before its retry branch. The matcher ignores a branch edge only when a statically zero EXEC makes that edge impossible (both words for wave64). A valid loop split across two blocks still lowers.

On 6638098 the two access-mask regressions fail. On e162729 the dead-retry regression fails and the multi-block control passes. With both commits, all 75 shader library tests pass on Linux with Rust 1.98.1. The asset-policy check also passes. The reviewer's Windows result is reported on the parent PR. Our tests use synthetic shaders and do not measure retail rendering or the effect on the parent's translation counts.

This addresses the access-mask condition raised in review. A proof that the loop back edge retries exactly the remaining lanes and general lowering for first-lane broadcast are separate work.

AI assistance was used to implement and independently test this change.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this. I am not merging it; the branch took the other fix offered for the same report, and the reasons are on the upstream thread: Marvisak#566 (comment)

In short, from an independent review and runs on an RTX 5070 and WARP:

  • At 4a64d76 a loop whose retry drops the waiting lanes is still accepted. In WATERFALL_JOINED_WAVE32, 0x897E157E → 0x8A7E7E6A (s_andn2_b32 exec_lo, vcc_lo, exec_lo): on the console lanes 16 to 31 never sample; here they get 2.0. The wave64 form with the retry on one half of EXEC is accepted too.
  • The waterfall LLVM writes for GFX10 and later (a v_cmpx_eq chain, the retry as todo & !EXEC) is refused, because the conditions stop at the last v_cmpx and the EXEC it read is not followed.

Both are tests on shader/per-lane-phi now (a_retry_that_keeps_other_lanes_than_those_waiting_is_no_waterfall, a_wave64_retry_of_one_half_is_no_waterfall, a_waterfall_narrowed_by_v_cmpx_is_one), so they are easy to run against any revision of this.

One thing this PR accepts that the branch now refuses: a loop split over two blocks by an unconditional branch (your waterfall_retry_can_cross_blocks). If you know a compiler that emits that shape, say so on Marvisak#566 and it becomes a real gap rather than a synthetic one.

I am leaving this open for you to close, since it is your PR. The title was not used in these tests. AI-assisted.

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