Skip to content

Shaders: keep literal select mask bits when lowering local half-waves - #277

Open
fluffyflattershy-afk wants to merge 1 commit into
fxceless:mainfrom
fluffyflattershy-afk:pr/literal-mask-half-wave
Open

fluffyflattershy-afk wants to merge 1 commit into
fxceless:mainfrom
fluffyflattershy-afk:pr/literal-mask-half-wave

Conversation

@fluffyflattershy-afk

Copy link
Copy Markdown

Change

A v_cndmask_b32 using a literal 64-bit scalar mask was refused in local half-wave lowering. When console lanes are already mapped, both host waves can use the literal and select the bit at their console lane index. This select requires no group exchange. Computed mask pairs still use the existing refusal.

Verification

  • A synthetic 64-thread compute shader selects 0 in lanes 0–31 and 1 in lanes 32–63. Before the change, lowering refused the select. With the patch, DXIL validation passed and all 64 outputs matched on a Windows 11 RTX 5070 Ti Laptop GPU.
  • All six emit::wave64_tests passed. cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings and cargo xtask policy passed.
  • This covers literal mask pairs. The tiled-shadow program discussed in Shaders: lower scc_some directly and per host wave under with_local_waves_any #190 still fails to lower in the local check.

AI-assisted with Codex. The test uses only synthetic inputs.

@ErRusso ErRusso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed at 6c835cd against 2119b0e.

Verification:

  • victory-shader --lib builds for x86_64-pc-windows-gnu.
  • The new local_waves_select_their_console_bits_from_a_constant_mask passes here (the hardware dispatch is skipped because this Wine host has no SM 6.6 device; DXIL validation and lowering still ran).
  • All six emit::wave64_tests pass under Wine.

The change is correct: a local half-wave can select bits from a literal 64-bit mask because both host waves see the same constants and lane_bit relabels each wave's lanes through console_lane(). Computed masks still take the refusal path, and the condition requires both halves to be literal, so a partially computed wave64 mask is still rejected. self.exchange.is_some() is redundant with self.local, but harmless.

Non-blocking: add a negative test that a computed mask (or a mask with only one literal half) is still refused in a local half-wave. That would lock in the boundary the new condition draws.

LGTM.

@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: the new test local_waves_select_their_console_bits_from_a_constant_mask passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (#129 (comment)).

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