Skip to content

Shaders: track every incoming edge of a lane-mask phi - #385

Open
nathanbzrr wants to merge 1 commit into
Marvisak:mainfrom
nathanbzrr:shaders/lane-mask-phi-joins
Open

nathanbzrr wants to merge 1 commit into
Marvisak:mainfrom
nathanbzrr:shaders/lane-mask-phi-joins

Conversation

@nathanbzrr

Copy link
Copy Markdown
Contributor

Addresses the a lane-mask join of an untracked mask translation failure category listed in #293 (3 shaders / ~66 dropped draws and dispatches per frame, including compute 2561af9577c47289 and pixel b37565055f2f7d3b).

Problem

When a lane-mask Phi merges a tracked mask with a constant or scalar-built mask (for example an exit-mask or accumulator phi initialized to 0 before a branch/loop, or reset to a constant on a back edge), structure previously failed with a lane-mask join of an untracked mask instead of tracking every incoming edge of the phi.

What changed

  • crates/victory-shader/src/structure.rs:
    • Export per-edge incoming masks for lane-mask phis in Structured::phi_masks via PhiJoin and Lanes::{derived_phis, phi_joins, phi_join_ids}.
    • Check every incoming edge across both joins and phi_joins in Lanes::check_joins, propagating derived status until fixpoint before building phi_masks in finish().
  • crates/victory-shader/src/emit/lower.rs:
    • Resolve pending_masks before data_phis in Lower::fill_phis using Structured::phi_masks.
    • Transitively expand console_lanes through phi_masks (including v_cndmask_b32 and v_*_co_ci_u32 selects) when an incoming edge needs lane-bit extraction of a constant/scalar mask.
    • Set flags::WAVE_OPS in Lower::lane_bit.

Relation to other PRs

Tests (synthetic GFX10 only, no game files)

  • crates/victory-shader/src/structure.rs:
    • mask_phi_joining_constant_and_compare_records_edge_bools
    • loop_mask_accumulator_from_zero_tracks_phi_and_edges
    • loop_mask_phi_reset_to_constant_on_back_edge
  • crates/victory-shader/src/emit/lower.rs:
    • lane_mask_phi_joining_zero_and_compare_lowers
    • wave64_loop_mask_accumulator_from_zero_lowers
    • lane_mask_phi_with_partial_constant_enables_console_lanes
  • crates/victory-shader/src/emit/valu_tests.rs:
    • lane_mask_phi_joins_execute_correctly (via build_wave32_cs / dispatch_wave32), testing branch join with zero, partial constant mask enabling console_lanes, and loop mask accumulation - validated with dxil.dll and executed on both hardware GPU and WARP.
  • Local checks on commit a345127:
    • rustfmt --edition 2024 --check clean
    • cargo clippy -p victory-shader --all-targets clean (0 warnings)
    • cargo test --workspace (271 passed, 0 failed, 4 ignored)
    • Asset policy hook (151 files ok)

Not verified

  • No game files were used, so in-game shader translation and runtime impact were not measured directly.

No game files. AI-assisted; reviewed and verified with the tests above.

@jeremygold02

Copy link
Copy Markdown
Contributor

Thanks @nathanbzrr for this lane-mask phi fix. I tested head a34512768a10ab8996e36f583d6b33f9129b17bd with:

cargo test --locked -p victory-shader --lib lane_mask_phi_joins_execute_correctly -- --test-threads=1

Result: 1 passed, 0 failed (75 filtered out). The synthetic shader test exercises a lane-mask phi join with multiple incoming edges and checks the resulting values. It validates the translator’s modeled case, not execution in a title.

@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown

Tested a345127 with the title on an RX 9060 XT (RDNA4), Windows 11.

Offline, victory translate --list on shaders.rpf, main d2a4bae vs this PR alone (#320 alone for comparison):

refusal main + #385 + #320
a lane-mask join of an untracked mask 39 0 17
an opaque lane mask 29 99 29
compute emitted (of 2,581) 1,693 1,717 1,715

Every join refusal is gone. 24 more compute programs translate; 70 programs now stop at an opaque lane mask.

In the world, pixel shader b37565055f2f7d3b still fails at the same offset (0x5340), now with an opaque lane mask is not supported. In a traced baseline world frame its pipeline dropped 284 mesh dispatches writing a 2560x1440 RGBA16F target that stays all zero, so that case would be worth covering next.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

@iurysf

iurysf commented Nov 24, 2026

Copy link
Copy Markdown

Tested offline against main d2a4bae with victory translate --list --validate over the title's shaders.rpf + executable (26,096 programs), dxil.dll 1.9.2602.17 (DXC v1.9.2602):

  • Translation failures: 3,733 on main → 3,709 with this PR (−24). "a lane-mask join of an untracked mask" disappears.
  • 22 compute programs that failed to emit on main with "a lane-mask join of an untracked mask" now emit but fail DXIL validation with Entry function performs some operation that is incompatible with the shader stage or other entry properties. No program that validated on main fails now.
  • Merges cleanly with Shaders: forward SGPRs reloaded from VGPR lanes as the spilled value #309: 3,572 failures together (−161), and that validation error goes from 24 to 55 modules.

@slint6614-dev

Copy link
Copy Markdown

Measured on the full retail shader pack (26,503 containers) with victory translate --validate --pipelines (pipelines created on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. This PR conflicts with current main (lower.rs), so it was measured on its own base, against main 1f858b0 before #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).

  • CS 1717 / 1672: +24 emitted but only +2 validated; the validator's "Entry function performs some operation that is incompatible with the shader stage" goes 23 → 45.
  • "a lane-mask join of an untracked mask" 39 → 0 and "scalar memory read as data" 573 → 521, but "an opaque lane mask" 29 → 99.
  • VS/PS and MS unchanged.

@walterwallaceson

Copy link
Copy Markdown

In-game data on where the pixel program named in this PR's description sits in a frame, from a run on Windows 10 with an RTX 3070. The short version: it draws into the HDR scene target the final image is built from, and that target is empty.

Setup: main 8e79c80 + #175, #55, #89, #439 (1ca87f7), #334, #493, #483, #688, #581, #704. Diagnostics build with VICTORY_SHADER_LOOP_LIMIT=4096. Player control is reached at about 1 fps, and the world is black (#392 has the run).

What I captured: I saved every render target of one frame in the world with VICTORY_CAPTURE + VICTORY_DUMP_TARGETS, and traced its draws with victory_gpu::draw=debug.

  • The geometry is drawn: two full-resolution colour targets show the whole scene, and a mask target has the right silhouettes.
  • The last full-screen pass that feeds the 4K output reads, among other inputs, a full-resolution R16G16B16A16_FLOAT target. All four full-resolution targets of that format are a single flat value at the end of the frame, so the output is black with only the UI on top.
  • 154 draws write that HDR target. 34 of them, from one mesh + pixel pipeline, are dropped because this PR's pixel program fails with a lane-mask join of an untracked mask. The other 120 run and still leave the target flat, so this program is probably one of several things missing there, not the only one.

About merging with #439's stack: the pixel program still fails with that reason on the stack above. #439's stack has its own handling for masks that start as a constant (Structured::others, "a loop's exit mask starts as a constant 0"), but it doesn't cover this program. I tried merging this PR on top and it conflicts in structure.rs (2 hunks), emit/lower.rs (7) and valu_tests.rs (1), mostly where the two approaches touch the same code (phi_masks/PhiJoin here, others/pairs/console masks there). I didn't hand-merge two designs, since a wrong merge would make an in-game result meaningless.

@nathanbzrr @r4tedx if a version of this fix lands on top of #439's stack (or #439 takes this case), I can run the same capture and say whether that HDR target fills.

I'm testing with Claude's help, and Claude drafted this comment.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@walterwallaceson, the 34 dropped draws give us a specific way to check an integration: first see whether the pipeline for b37565055f2f7d3b is created and those draws execute, then compare the HDR target. The other 120 draws make the target contents a separate result. I checked #439 at ac6ab70; its update brings in #566’s descriptor waterfall handling. It does not integrate #385’s per-edge mask tracking. I don’t have a combined head verified for that capture.

AI-assisted (Codex).

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@walterwallaceson @nullmarsh, one detail changes what’s worth testing next. The RX 9060 XT report already follows b37565055f2f7d3b past the join refusal on #385 alone. At the same offset (0x5340) it stops on an opaque lane mask. A second frame capture would be most informative after that pixel shader emits, validates, and creates a pipeline on the combined stack.

If either of you has the local shader inspection handy, could you report the opcode at 0x5340 and how its mask is produced on each incoming path (for example, a constant, a compare, or a saved EXEC value)? Mnemonics and a description of the register flow are enough to start a synthetic regression case. No shader binary or game files needed.

AI-assisted (Codex).

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@walterwallaceson @nullmarsh, I traced the failing pixel shader locally. At the join reported at 0x5340, two edges carry the same tracked mask. The third reloads that very mask from the same VGPR lane where it was saved. That makes #298’s spill handling sufficient for this shader.

I pushed a capture branch at bb099d9 on top of #439 c153b21, integrated with @permadiego’s #298 54f97db. Stock #439 refused b37565055f2f7d3b at 0x5340. On the combined branch, the exact pixel shader passed the SDK DXIL validator. Mesh shader ba8d52f4ea1a1bac also validated, and the RTX 5070 (616.92) created a mesh pipeline using the two actual shaders together. The workspace suite passed (378 passed, 6 ignored). The branch also serializes the console-wave GPU tests with the other device tests after an access violation in the local NVIDIA driver during parallel testing.

That gets us to the capture you offered: on the same scene and the rest of your original stack, do the formerly dropped draws now execute, and does the RGBA16F target change? I have checked pipeline creation here. I haven’t measured writes to the title’s HDR target. No game data attached.

AI-assisted (Codex).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the capture branch at bb099d9: I compared it with stock #439 c153b21 over the local shaders.rpf. Both ran victory translate --validate --host-lanes 32-32 with the SDK dxil.dll validator, offline and without creating pipelines.

build vertex + pixel validated compute validated mesh validated total
#439 c153b21 12,155 1,385 8,152 21,692
+ #298 (bb099d9) 12,182 1,385 8,152 21,719

All 27 gains are pixel programs. Matching programs by source container hash, none that validated on #439 fails on the branch. Refusals fell by 27 in total. The largest drops were an opaque lane mask (−29), an SCC the emitter did not compute (−27), a lane mask read as data (−16) and a lane-mask join of an untracked mask (−15). Some programs now get further and stop on a later reason instead, most often a program the console structure cannot hold (+144). Compute and mesh counts did not change.

Local title data was used for this comparison; only counts, refusal reasons and hashes are reported here. This doesn't answer the HDR-target question. That still needs the in-game capture.

AI-assisted (Claude Code).

@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown

@r4tedx The in-game capture, on your base: #439 c153b21 vs bb099d9, both + #500 + a local trace (both include #612), RX 9060 XT, 4 frames, warm caches, one run per build:

  • c153b21: b37565055f2f7d3b refused at 0x5340; all 324 of its draws dropped.
  • bb099d9: all 252 issued, none dropped ("issued" is all the trace shows).
  • Their 2560x1440 RGBA16F target, end-of-frame dump: near-black in both. 7 of 8 dumps have 17–59 sampled pixels ≥ 0.0005 (the eighth peaks at 0.0004); none reach 0.01.

Your base lacks #346: 983 indirect rectangle-list draws dropped on bb099d9, 727 on that target. With #346 in both builds those drops are gone, though its path is outside my trace. The target is the same: 24–60 pixels ≥ 0.0005, none ≥ 0.01, bar one frame whose 21.5 max the quarter-sampled dump missed.

So your fix makes these draws run, but the dump shows no change from them or from #346. Not checked: their inputs, later writes, or correctness (qntic's #298 report).

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@nullmarsh, thanks. This is the A/B the capture branch was for, and it settles one part. On bb099d9, b37565055f2f7d3b gets a pipeline and its draws are issued: 0 of 252 dropped, against all 324 dropped on c153b21. It also shows that those dropped draws weren't what kept the RGBA16F target empty. With them running, the target stays near-black, with or without #346.

What that means for the PRs:

If your trace can show, for one of the 252 draws, which views are bound and whether those resources hold nonzero data at that point, that would separate the two cases. Also, are 324 and 252 the same four frames counted the same way? Or does the scene issue fewer of these draws on bb099d9?

No new tests for this reply. My earlier check of bb099d9 used local title data offline, covering DXIL validation and pipeline creation for this shader only. The title was not run.

AI-assisted (Claude Code).

@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown

@r4tedx Your two questions, from dump runs on bb099d9 + #500 + a local trace that names view resources and counts raw values per target (RX 9060 XT, 4 frames, warm cache):

  • 324 vs 252: same counting; the trigger lands on different frames. Per frame: c153b21 144/144/36/0; bb099d9 144/34/36/38, and in two later runs 144/34/70/70 and 144/34/68/68 (all ran).
  • Bound views: 16 texture views with a resource; 9 are targets I can read (end of frame, not at draw time):
    • Data: depth 2560x1440 (1-6% nonzero), three 384x384 RGBA16F.
    • Uniform: 2560x1440 R32F all 0; 2304x576 R16F all 0; 128x128 RGBA16F all 0; 80x45 one value (3 of 4 frames); 960x540 R32F 0x7FFFFFFF in every texel and frame (looks like a fill).
  • b375's own RGBA16F target: 0 NaN/Inf; 99.92-99.94% exactly 0.
  • The 2560x1440 R32F input is render target 0 of 232 draws (depth: the same buffer b375 reads). 218 are dropped, 206 by 9 pixel programs refused for "a 64-bit image atomic" (e.g. 8ba01719b71d1d35). It is all 0 at end of frame although 14 draws on it ran.

Not known: which views b375 samples; texture-UAV writes (the trace names buffer UAVs only). Next: the same run with #305.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown

@r4tedx Follow-up with #305 (78dae83) added to the same base, 1 run, same scene:

  • 7 of the 9 programs now translate; 3f1c61d954b46f31 stops on "barycentrics read directly" and 97175c2c1a214a2f on "a scalar memory read as data". 192 of their draws on that 2560x1440 R32F target run in the 4 frames (0 without Shaders: lower 64-bit image atomics #305).
  • End-of-frame contents don't differ from two control runs: rt0 R32F all 0; rt1 R8 nonzero in 42-127 texels; rt2 R8 0x80 in every texel (looks like a clear value); the shared depth buffer within control run-to-run spread (1-6% nonzero); b375's own target 99.92-99.94% exactly 0.

An end-of-frame dump can't tell "never wrote" from "cleared later", and their 64-bit image writes aren't visible to my trace. This base has no #587.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@nullmarsh, thanks. That's the run I was about to prepare a branch for, so I've dropped mine. Two things follow from it:

I haven't run either of them on this base. The title was not used for this reply.

AI-assisted (Claude Code).

@tyr0nsur

Copy link
Copy Markdown

Tested the predecessor tracking at 42fd55963823 on PortVI’s 940d32f-based patch stack, against 46 compute programs that previously stopped at the untracked-mask join. The tracking emitted all 46. The Windows SDK validator accepted 13 and rejected 33 with an empty phi i1.

In fill_phis, a scalar join materializes a mask word on one incoming edge. Its ballot requests a boolean loop phi after the first pass over pending_masks. Draining newly discovered masks and reconsidering scalar edges whenever another scalar input becomes live brought the same set to 46/46 validated. Our desktop RTX 4060 (driver 32.0.16.2114) created 45/46 compute pipelines. The remaining program declares WaveSize(64) on our fixed 32-lane adapter.

The authored data_join_materializes_a_loop_mask_wave32 test reproduces the empty phi on the upstream-only integration and checks the returned scalar and lane bit after the fix. It runs without a title. The three-pass loop and pair-identity tests are in the same PortVI patch. Thanks for the original edge tracking.

@nathanbzrr

Copy link
Copy Markdown
Contributor Author

Rebased onto origin/main (f3578e3, new head 7420237) and addressed the three triage questions + fixpoint duplication issue:

1. Whole-mask & cross-lane reads after a per-lane join (given(m, e))

  • Both fill_mask_phis and the avoids links only evaluate given(m, e) under edge e:
    • In fill_mask_phis, the lowered phi i1 selects (x, qb) specifically along predecessor edge q -> b, where e holds for every lane traversing that edge, so given(m, e) evaluates to the exact same per-lane bit as m on that path (while allowing edges like if (v0 < s0) { s2 = vcc_lo } where given(m, e) == Bool::TRUE to simplify cleanly).
    • In avoids, lane_edge(q, to) already constrains e, so (joined == given(m, e)) on edge q -> to is equivalent to (joined == m) for lanes taking that edge.
  • Added synthetic tests reading the joined mask both as a whole 32-bit integer (s_and_b32 s6, s2, exec_lo) and cross-lane via v_readlane_b32 (lanes 0 and 31) after per-lane joins:
    • emit::lower::tests::per_lane_mask_phi_read_as_whole_mask_and_readlane_validates (WaveActiveBallot emitted once, validated with dxil.dll).
    • emit::valu_tests::lane_mask_phi_whole_read_and_readlane_execute_correctly (executed on host GPU covering both s2 = vcc_lo where given(m, e) == Bool::TRUE and an independent sub-mask v0 < s1 under v0 < s0).

2. console_lanes scan (selects) scope & title shader count

  • Updated selects in crates/victory-shader/src/emit/lower.rs to skip unreachable blocks (x.st.reach[b] != Bool::FALSE).
  • The scan still enables console_lanes only when a reachable v_cndmask_b32 / carry-in mask transitively depends on Atom::Opaque or Atom::Constant through phi_masks (plain compare masks and uniform 0 / -1 joins do not trigger console_lanes).
  • This environment has no local title files per docs/asset-policy.md, so the exact number of retail shaders changed in shaders.rpf cannot be measured here.

3. Single resolution per (data_phi, edge) and draining new pending_masks in fill_phis

  • Refactored fill_phis (crates/victory-shader/src/emit/lower.rs) to track resolved: Vec<Vec<Option<V>>> across fixpoint iterations instead of re-running fill_data_phis over already-resolved edges:
    • Each iteration drains fill_mask_phis()?, recomputes live = self.live_edges(), and resolves only newly-live unresolved (idx, n) entries once (mask_dword is never invoked twice for the same incoming edge).
    • The loop repeats whenever pending_masks is non-empty, self.read_phis grows, or any new data-phi edge resolves, and self.s.m.set_phi(v, incoming) is called once per data phi after convergence—preventing empty phi i1 entries when a data join materializes a loop mask (@tyr0nsur's report).
  • Added emit::lower::tests::fill_phis_fixpoint_resolves_loop_mask_ballot_without_empty_phi_or_duplicate_ballots, exercising a two-hop chain (s6 data join -> s2 loop mask -> s7 data phi -> s9 loop mask) and asserting lowered.wave_ballots == 2 and dxil.dll validation.

Verification (7420237)

  • cargo run -p xtask -- policy -> 186 files ok
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings & --all-features -> clean
  • cargo test -p victory-shader --locked -> 316 passed; 0 failed; 3 ignored (unit), 3 passed; 0 failed; 1 ignored (resource_tracking), 0 passed; 0 failed (doctests)
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi -> 6 passed; 0 failed

@nathanbzrr
nathanbzrr force-pushed the shaders/lane-mask-phi-joins branch from 7420237 to a3defec Compare November 25, 2026 23:04
@nathanbzrr

Copy link
Copy Markdown
Contributor Author

Updated shaders/lane-mask-phi-joins (rebased on origin/main 842b0cb, new head a3defec) to fix the xtask asset-policy failure (crates/victory-shader/src/emit/lower.rs was 538,775 bytes vs. the 524,288-byte limit):

  • Extracted PR Shaders: track every incoming edge of a lane-mask phi #385's lane-mask phi lowering (fill_mask_phis, fill_phis), console-lanes mask scan (mask_uses_console_lanes), and 9 unit tests into submodule crates/victory-shader/src/emit/lower/phi.rs (22,696 bytes), matching lower/bvh.rs (emit/lower.rs is now 515,592 LF bytes / 515,626 disk bytes).

Verification (a3defec)

  • cargo test -p xtask --locked -> 6 passed; 0 failed (policy::tests::repository_passes_policy ... ok)
  • cargo run -p xtask -- policy -> 186 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings & --all-features -> clean
  • cargo test -p victory-shader --locked -> 316 passed; 0 failed; 3 ignored (unit), 3 passed; 0 failed; 1 ignored (resource_tracking)
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi -> 6 passed; 0 failed

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Code review and RTX 5090 + WARP + DXIL verification at head a3defece8db9 merged cleanly onto main (63bcca43c6a0):

  • Bonus lower.rs headroom: Extracting crates/victory-shader/src/emit/lower/phi.rs (22,696 B) shrinks emit/lower.rs from 520,563 B down to 515,626 B (8,662 B below the 512 KiB policy limit).
  • Code review (structure.rs:475-477, 827-900, emit/lower/phi.rs):
    • check_joins inspects all incoming edges (including back edges) of Join/PhiJoin, re-running when a back edge promotes a phi into derived_phis, and exports exact per-edge booleans via b.given(m, e) in phi_masks.
    • mask_uses_console_lanes walks Atom::Phi edges transitively so console_lanes/WAVE_OPS are triggered accurately, fill_mask_phis emits exact per-edge boolean(phi_edge, qb), and fill_phis uses a fixed-point resolved[idx][n] loop preventing empty phis or duplicate waveActiveBallot calls on cyclic masks read as data.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, dxil.dll 10.0.26100.0, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 192 files ok; cargo clippy (default + --features diagnostics): 0 warnings
    • emit::lower::tests (33/33), structure:: (16/16, 1 ignored), phi (25/25, including emit::lower::phi::tests and both GPU lane_mask_phi_* tests), and emit::semantics_tests (34/34 on both RTX 5090 and WARP, 1 ignored) all passed.

Solid fix and welcome lower.rs size reduction; LGTM.

@Anzymanz

Copy link
Copy Markdown

From a tester working with Claude (AI-assisted, Claude Code): an offline check of this PR over a whole title's shader pack (25,889 distinct containers through emit::translate_with; hashes and counts only).

Not run: your GPU tests, and the title in a game run. Translation only.

@steven-seagull27

Copy link
Copy Markdown

@nathanbzrr I found a case outside the phi-edge tests where the same console-wave scan matters. A Wave32 compute shader uses v_cndmask_b32 v1, 0, 1, 15 and stores one result per lane. Only lanes 0–3 should write 1. On a3defec, translation stops at a constant lane mask. The select's direct inline mask never enters the scan. A partial mask in a scalar register can likewise be recorded in st.other, while the scan only looks in st.masks.

I put a standalone patch directly on your head. It checks both sources in reachable compute blocks. Inline zero and all-ones still work at any host wave size.

The new select regression covered nine 32-lane readbacks, including a scalar input with only bit 31 set and 0xa5a55a5a. The RTX 5080 and WARP 1.0.22 each returned 288/288 correct lane values. Built-in WARP returned 64/64 for the two width-independent controls and skipped the fixed Wave32 cases. The original phi execution tests and the fixed-point validator regression still pass. Strict shader Clippy passed.

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr385-direct-select-mask
git cherry-pick 1c73d188cb19e1ff8d0598124972ba897ed94e80
cargo test --locked -p victory-shader --lib direct_select_uses_this_lanes_mask_bit -- --nocapture

For the merge overlap with #2967, there is also a combined branch that preserves both PR histories and #171's signed carry fix. Your per-edge phi_masks and fixed-point resolution stay in lower/phi.rs. #2967 contributes its mask spill/restore and carry operand handling. Signed multiply-add SDST and carry-in are distinct here. The latter exposed the same missing direct-mask scan. Its eight additional Wave64 readbacks on portable WARP matched all 512 lanes, including masks that set only bits 32 or 63. lower.rs is 517,936 bytes in the combined tree (6,352 bytes below policy).

For wider coverage I also ran the combined production change with the carry regression. The library suite stopped at the heap-texture test tracked in #2571. Excluding that one test gave 321 passed, 3 ignored and the same two stride failures and gather failure seen on this host. The final targeted run included both new regressions and the saved-EXEC refusal control.

AI-assisted. All tests used synthetic shader inputs.

Rebased onto main, reconciled with uniform/per-lane mask-data joins, and
turned `fill_phis` into a fixpoint loop (`fill_mask_phis` +
`fill_data_phis`) so a loop mask phi materialized later by a uniform data
join is always populated instead of emitting an empty `phi i1` (thanks to
@tyr0nsur for identifying this bug). Also align `mask_uses_console_lanes`
with `lower.rs` by filtering unreachable predecessors via `st.reach` and
checking `st.other` on `v_cndmask_b32` selectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.