Shaders: track every incoming edge of a lane-mask phi #385
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!385
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-385"
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?
@nathanbzrr on GitHub · 2026-11-24 02:50 UTC · original
nathanbzrr:shaders/lane-mask-phi-joins→main· +1175 −133 · 4 files · 1 commits · openAddresses the
a lane-mask join of an untracked masktranslation failure category listed in #293 (3 shaders / ~66 dropped draws and dispatches per frame, including compute2561af9577c47289and pixelb37565055f2f7d3b).Problem
When a lane-mask
Phimerges a tracked mask with a constant or scalar-built mask (for example an exit-mask or accumulator phi initialized to0before a branch/loop, or reset to a constant on a back edge),structurepreviously failed witha lane-mask join of an untracked maskinstead of tracking every incoming edge of the phi.What changed
crates/victory-shader/src/structure.rs:Structured::phi_masksviaPhiJoinandLanes::{derived_phis, phi_joins, phi_join_ids}.joinsandphi_joinsinLanes::check_joins, propagating derived status until fixpoint before buildingphi_masksinfinish().crates/victory-shader/src/emit/lower.rs:pending_masksbeforedata_phisinLower::fill_phisusingStructured::phi_masks.console_lanesthroughphi_masks(includingv_cndmask_b32andv_*_co_ci_u32selects) when an incoming edge needs lane-bit extraction of a constant/scalar mask.flags::WAVE_OPSinLower::lane_bit.Relation to other PRs
structureandemit::loweracross shader stages and both Wave32 and Wave64.Tests (synthetic GFX10 only, no game files)
crates/victory-shader/src/structure.rs:mask_phi_joining_constant_and_compare_records_edge_boolsloop_mask_accumulator_from_zero_tracks_phi_and_edgesloop_mask_phi_reset_to_constant_on_back_edgecrates/victory-shader/src/emit/lower.rs:lane_mask_phi_joining_zero_and_compare_lowerswave64_loop_mask_accumulator_from_zero_lowerslane_mask_phi_with_partial_constant_enables_console_lanescrates/victory-shader/src/emit/valu_tests.rs:lane_mask_phi_joins_execute_correctly(viabuild_wave32_cs/dispatch_wave32), testing branch join with zero, partial constant mask enablingconsole_lanes, and loop mask accumulation - validated withdxil.dlland executed on both hardware GPU and WARP.a345127:rustfmt --edition 2024 --checkcleancargo clippy -p victory-shader --all-targetsclean (0 warnings)cargo test --workspace(271 passed, 0 failed, 4 ignored)151 files ok)Not verified
No game files. AI-assisted; reviewed and verified with the tests above.
@jeremygold02 on GitHub · 2026-11-24 04:23 UTC · original
Thanks @nathanbzrr for this lane-mask phi fix. I tested head
a34512768a10ab8996e36f583d6b33f9129b17bdwith: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 on GitHub · 2026-11-24 04:30 UTC · original
Tested
a345127with the title on an RX 9060 XT (RDNA4), Windows 11.Offline,
victory translate --listonshaders.rpf,maind2a4baevs this PR alone (#320 alone for comparison):maina lane-mask join of an untracked maskan opaque lane maskEvery join refusal is gone. 24 more compute programs translate; 70 programs now stop at
an opaque lane mask.In the world, pixel shader
b37565055f2f7d3bstill fails at the same offset (0x5340), now withan 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 on GitHub · 2026-11-24 04:55 UTC · original
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17 (DXC v1.9.2602):Entry function performs some operation that is incompatible with the shader stage or other entry properties. No program that validated on main fails now.a3defece8dto90997428f5@slint6614-dev on GitHub · 2026-11-24 09:24 UTC · original
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 main1f858b0before #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).@walterwallaceson on GitHub · 2026-11-24 10:56 UTC · original
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:
main8e79c80+ #175, #55, #89, #439 (1ca87f7), #334, #493, #483, #688, #581, #704. Diagnostics build withVICTORY_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 withvictory_gpu::draw=debug.R16G16B16A16_FLOATtarget. 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.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 instructure.rs(2 hunks),emit/lower.rs(7) andvalu_tests.rs(1), mostly where the two approaches touch the same code (phi_masks/PhiJoinhere,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 on GitHub · 2026-11-24 11:07 UTC · original
@walterwallaceson, the 34 dropped draws give us a specific way to check an integration: first see whether the pipeline for
b37565055f2f7d3bis created and those draws execute, then compare the HDR target. The other 120 draws make the target contents a separate result. I checked #439 atac6ab70; 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 on GitHub · 2026-11-24 11:37 UTC · original
@walterwallaceson @nullmarsh, one detail changes what’s worth testing next. The RX 9060 XT report already follows
b37565055f2f7d3bpast the join refusal on #385 alone. At the same offset (0x5340) it stops onan 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
0x5340and 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 on GitHub · 2026-11-24 12:43 UTC · original
@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
bb099d9on top of #439c153b21, integrated with @permadiego’s #29854f97db. Stock #439 refusedb37565055f2f7d3bat0x5340. On the combined branch, the exact pixel shader passed the SDK DXIL validator. Mesh shaderba8d52f4ea1a1bacalso 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).
@r4tedx on GitHub · 2026-11-24 13:19 UTC · original
Follow-up on the capture branch at
bb099d9: I compared it with stock #439c153b21over the localshaders.rpf. Both ranvictory translate --validate --host-lanes 32-32with the SDKdxil.dllvalidator, offline and without creating pipelines.c153b21bb099d9)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) anda lane-mask join of an untracked mask(−15). Some programs now get further and stop on a later reason instead, most oftena 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 on GitHub · 2026-11-24 13:45 UTC · original
@r4tedx The in-game capture, on your base: #439
c153b21vsbb099d9, both + #500 + a local trace (both include #612), RX 9060 XT, 4 frames, warm caches, one run per build:c153b21:b37565055f2f7d3brefused at0x5340; all 324 of its draws dropped.bb099d9: all 252 issued, none dropped ("issued" is all the trace shows).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 on GitHub · 2026-11-24 13:53 UTC · original
@nullmarsh, thanks. This is the A/B the capture branch was for, and it settles one part. On
bb099d9,b37565055f2f7d3bgets a pipeline and its draws are issued: 0 of 252 dropped, against all 324 dropped onc153b21. 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:
bb099d9): it does what it claims for this shader. The refusal is gone and the draws run. Your dump doesn't confirm or contradict the values those draws compute. So far, the evidence for that is qntic's hardware lane test on #298.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
bb099d9used local title data offline, covering DXIL validation and pipeline creation for this shader only. The title was not run.AI-assisted (Claude Code).
@ghost on GitHub · 2026-11-24 15:23 UTC · original
@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):c153b21144/144/36/0;bb099d9144/34/36/38, and in two later runs 144/34/70/70 and 144/34/68/68 (all ran).0x7FFFFFFFin every texel and frame (looks like a fill).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 on GitHub · 2026-11-24 15:44 UTC · original
@r4tedx Follow-up with #305 (
78dae83) added to the same base, 1 run, same scene:3f1c61d954b46f31stops on "barycentrics read directly" and97175c2c1a214a2fon "a scalar memory read as data". 192 of their draws on that 2560x1440 R32F target run in the 4 frames (0 without #305).0x80in 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 on GitHub · 2026-11-24 15:48 UTC · original
@nullmarsh, thanks. That's the run I was about to prepare a branch for, so I've dropped mine. Two things follow from it:
3f1c61d954b46f31stops atbarycentrics read directly. In upstreammain(lower.rs,Input::Barycentric) that is the reason #453 (barycentrics throughSV_Barycentrics) targets.97175c2c1a214a2fstops ata scalar memory read as data. #180 is the open PR that takes the most programs off that reason in h0useadv's census on #293 (771 → 300).I haven't run either of them on this base. The title was not used for this reply.
AI-assisted (Claude Code).
@KainanP on GitHub · 2026-11-24 18:10 UTC · original
Ran this PR (
a3451276) on Windows 11, RTX 4060 Laptop (driver 32.0.16.1047):cargo test -p victory-shader --lib --lockedpasses 3/3 times on the default adapter (76 passed).With
VICTORY_WARP=1(the WARP mode documented indiff_tests.rs),lane_mask_phi_joins_execute_correctlyfails:(Windows' localized "The parameter is incorrect", i.e. E_INVALIDARG.)
Host::new(false)already returns WARP whenVICTORY_WARP=1(host.rs:68), butdispatch_wave32only skips the fixed-WaveSize refusal when its ownwarpflag is set, so the "hardware" pass panics. Skipping there too isn't enough: then neither pass runs andran > 0fails ("neither hardware nor WARP SM 6.6 device available"), although a device was found.This makes it pass on both (76 passed with
VICTORY_WARP=1and without):(
diff_tests.rs:1208handles the same case by readingVICTORY_WARP.) Test-harness only; the join lowering itself checks out on the RTX.Tested with the help of an AI (Claude Code).
@nathanbzrr on GitHub · 2026-11-24 21:44 UTC · original
Thanks @catminou4 for the review note and @KainanP for the
VICTORY_WARP=1fix!Rebased onto
origin/main(ffe310e, new headec086dc), integrating#566,#612,#140,#801, and#433:crates/victory-shader/src/structure.rs(auto-merged keeping#566'sreachand#385'sphi_masks),crates/victory-shader/src/emit/lower.rs(kept#612'sread_phisclosure alongside#385'spending_masksresolution andlowers_cstest helper), andcrates/victory-shader/src/emit/valu_tests.rs(kept#140'sv_cmp_class_f16_matches_rdna2).resource::trackcalls to passSome(&st)(#801).dispatch_wave32withONE_AT_A_TIME(#433) and applied@KainanP'sVICTORY_WARP=1fix (incrementingranafterHost::newand skipping fixed-WaveSizerejections whenVICTORY_WARP=1).Re-verified on
ec086dc(Windows MSVC):cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: 349 passed, 0 failed, 6 ignored (victory-shader: 127 passed, 0 failed, 1 ignored)VICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi_joins_execute_correctly: 1 passed, 0 failed@nathanbzrr on GitHub · 2026-11-24 22:21 UTC · original
Rebased onto
origin/main(70564ae, new head02a2e91):@catminou4 @KainanP
crates/victory-shader/src/structure.rspreservingorigin/main'srestored,discards,spilled(), andLanes::maskfallback alongsidephi_masks,derived_phis,phi_joins,phi_join_ids, andcheck_joins.crates/victory-shader/src/emit/lower.rskeepingorigin/main'slive_edges/a7fc47a/8af0472/0b35b7fchanges, updatingavoidsedge-mask links to consultst.phi_masksbeforest.masks, and resolvingpending_masksviast.phi_masksinfill_phis.crates/victory-shader/src/emit/valu_tests.rspreserving allorigin/maintests (throughrelative_moves_reach_only_what_their_clamped_index_can), updatingbuild_wave32_cs'sHostShaderfields (root_uavs,memory,memory_writes,view_addresses,heap,heap_writes), and keeping@KainanP'sVICTORY_WARP=1fix +ONE_AT_A_TIMElock indispatch_wave32.Verified on
02a2e91(Windows MSVC):rustfmt --edition 2024 --check crates/victory-shader/src/emit/valu_tests.rs: clean (structure.rsandemit/lower.rsonly retain pre-existingorigin/mainformatting diffs).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --locked:483 passed, 0 failed, 7 ignored(victory-shader:216 passed, 0 failed, 2 ignored;xtask:4 passed).VICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi_joins_execute_correctly:1 passed, 0 failed.@Marvisak on GitHub · 2026-11-25 00:30 UTC · original · edited 2026-11-26 04:20 UTC
Automated triage for the maintainers.
Merge candidate. Since
a3defec,mask_uses_console_lanes(emit/lower/phi.rs) ignores predecessors whosereachisFALSEwhen decidinguniform_joinand queueing phi edges, and looks av_cndmask_b32mask up inst.othertoo, so a partial constant mask in an SGPR turns on console lanes; both read correctly. Carry-in selects and inline-constant masks still stop at a refusal, which is safe. The two new tests only check that WAVE_OPS is set and the DXIL validates; a lane-readback test (such as the direct-select case in this thread) would make them stronger.phi.rsstill deserves a careful human read.CI: passing.
Generated by Claude Code
@nathanbzrr on GitHub · 2026-11-25 00:58 UTC · original
Rebased onto
origin/main(42363ab, new head14c46b2):crates/victory-shader/src/structure.rs, keepingorigin/main'sBools::vars/Bools::giventests and benchmark (e5b7159), BDD memo-cap overflow checks (f177aae), andStructured::other(67c4f53) alongside#385'sphi_masks/PhiJoin/check_joinstracking and tests.crates/victory-shader/src/emit/lower.rs(including1e923adWAVE_OPSand67c4f53v_cndmask_b32) andcrates/victory-shader/src/emit/valu_tests.rs.Verified locally (Windows MSVC):
4118f33(59d7bf4):cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: 705 passed, 0 failed, 10 ignoredcargo xtask policy: 182 files ok42363ab(14c46b2):cargo test -p victory-shader --locked: 253 passed, 0 failed, 3 ignoredVICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi_joins_execute_correctly: 1 passed, 0 failed@nathanbzrr on GitHub · 2026-11-25 03:32 UTC · original
Updated
crates/victory-shader/src/emit/lower.rs(head42fd559, rebased onorigin/main940d32f) with both afill_phisfix and SDKdxil.dllvalidation coverage, plus the #201 root-cause diagnosis for the 22 compute validation errors:1. Cause of the 22 compute validation errors ("incompatible with the shader stage")
As established on #201 (see @r4tedx's analysis, the #201 issue triage note, and @iurysf's corpus stack census):
main,crates/victory-shader/src/emit/lower.rsemitsimage_sample/image_sample_o/image_sample_basdx.op.sample(op 60, implicit derivatives) in compute shaders while declaringdx.valver1.6, whichdxil.dllrejects with "Function uses features incompatible with the shader stage (cs) of the entry function" followed by "Entry function performs some operation that is incompatible with the shader stage or other entry properties".mainlowering path once their control-flow joins no longer fail earlier.2. Code & synthetic DXIL validation updates (
crates/victory-shader/src/emit/lower.rs)fill_phisordering: movedpending_masksresolution beforeself.live_edges()so any scalar/phi values read while lowering mask-phi incoming booleans populateself.read_phisbefore data-phi edge liveness runs.dxil.dllvalidation: addedvalidate_dxil(viaValidator::load) tolane_mask_phi_joining_zero_and_compare_lowers,wave64_loop_mask_accumulator_from_zero_lowers,lane_mask_phi_with_partial_constant_enables_console_lanes(WaveSize(32)+WAVE_OPS), and addedwave64_lane_mask_phi_with_partial_constant_validates(WaveSize(64)+WAVE_OPS). All four emit valid DXIL and pass Windows SDKdxil.dll10.0.26100.0validation without errors.Verified on
42fd559(Windows MSVC,VICTORY_DXILSDK10.0.26100.0):cargo run -p xtask -- policy --staged:asset policy: 1 files okcargo clippy --workspace --all-targets -- -D warnings&--all-features: cleancargo test -p victory-shader --locked: 255 passed, 0 failed, 3 ignoredVICTORY_WARP=1 cargo test -p victory-shader --locked -- lane_mask_phi_joins_execute_correctly: 1 passed, 0 failedcargo test --workspace --locked: 0 failures across all workspace crates@tyr0nsur on GitHub · 2026-11-25 14:57 UTC · original
Tested the predecessor tracking at
42fd55963823on PortVI’s940d32f-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 emptyphi 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 overpending_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_wave32test 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 on GitHub · 2026-11-25 22:24 UTC · original
Rebased onto
origin/main(f3578e3, new head7420237) and addressed the three triage questions + fixpoint duplication issue:1. Whole-mask & cross-lane reads after a per-lane join (
given(m, e))fill_mask_phisand theavoidslinks only evaluategiven(m, e)under edgee:fill_mask_phis, the loweredphi i1selects(x, qb)specifically along predecessor edgeq -> b, whereeholds for every lane traversing that edge, sogiven(m, e)evaluates to the exact same per-lane bit asmon that path (while allowing edges likeif (v0 < s0) { s2 = vcc_lo }wheregiven(m, e) == Bool::TRUEto simplify cleanly).avoids,lane_edge(q, to)already constrainse, so(joined == given(m, e))on edgeq -> tois equivalent to(joined == m)for lanes taking that edge.s_and_b32 s6, s2, exec_lo) and cross-lane viav_readlane_b32(lanes 0 and 31) after per-lane joins:emit::lower::tests::per_lane_mask_phi_read_as_whole_mask_and_readlane_validates(WaveActiveBallotemitted once, validated withdxil.dll).emit::valu_tests::lane_mask_phi_whole_read_and_readlane_execute_correctly(executed on host GPU covering boths2 = vcc_lowheregiven(m, e) == Bool::TRUEand an independent sub-maskv0 < s1underv0 < s0).2.
console_lanesscan (selects) scope & title shader countselectsincrates/victory-shader/src/emit/lower.rsto skip unreachable blocks (x.st.reach[b] != Bool::FALSE).console_lanesonly when a reachablev_cndmask_b32/ carry-in mask transitively depends onAtom::OpaqueorAtom::Constantthroughphi_masks(plain compare masks and uniform0/-1joins do not triggerconsole_lanes).docs/asset-policy.md, so the exact number of retail shaders changed inshaders.rpfcannot be measured here.3. Single resolution per
(data_phi, edge)and draining newpending_masksinfill_phisfill_phis(crates/victory-shader/src/emit/lower.rs) to trackresolved: Vec<Vec<Option<V>>>across fixpoint iterations instead of re-runningfill_data_phisover already-resolved edges:fill_mask_phis()?, recomputeslive = self.live_edges(), and resolves only newly-live unresolved(idx, n)entries once (mask_dwordis never invoked twice for the same incoming edge).pending_masksis non-empty,self.read_phisgrows, or any new data-phi edge resolves, andself.s.m.set_phi(v, incoming)is called once per data phi after convergence—preventing emptyphi i1entries when a data join materializes a loop mask (@tyr0nsur's report).emit::lower::tests::fill_phis_fixpoint_resolves_loop_mask_ballot_without_empty_phi_or_duplicate_ballots, exercising a two-hop chain (s6data join ->s2loop mask ->s7data phi ->s9loop mask) and assertinglowered.wave_ballots == 2anddxil.dllvalidation.Verification (
7420237)cargo run -p xtask -- policy->186 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings&--all-features-> cleancargo 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 on GitHub · 2026-11-25 23:05 UTC · original
Updated
shaders/lane-mask-phi-joins(rebased onorigin/main842b0cb, new heada3defec) to fix thextaskasset-policy failure (crates/victory-shader/src/emit/lower.rswas538,775bytes vs. the524,288-byte limit):fill_mask_phis,fill_phis), console-lanes mask scan (mask_uses_console_lanes), and 9 unit tests into submodulecrates/victory-shader/src/emit/lower/phi.rs(22,696bytes), matchinglower/bvh.rs(emit/lower.rsis now515,592LF bytes /515,626disk 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 okcargo clippy --workspace --all-targets --locked -- -D warnings&--all-features-> cleancargo 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 on GitHub · 2026-11-26 01:31 UTC · original
Code review and RTX 5090 + WARP + DXIL verification at head
a3defece8db9merged cleanly ontomain(63bcca43c6a0):lower.rsheadroom: Extractingcrates/victory-shader/src/emit/lower/phi.rs(22,696B) shrinksemit/lower.rsfrom520,563B down to515,626B (8,662B below the 512 KiB policy limit).structure.rs:475-477, 827-900,emit/lower/phi.rs):check_joinsinspects all incoming edges (including back edges) ofJoin/PhiJoin, re-running when a back edge promotes a phi intoderived_phis, and exports exact per-edge booleans viab.given(m, e)inphi_masks.mask_uses_console_laneswalksAtom::Phiedges transitively soconsole_lanes/WAVE_OPSare triggered accurately,fill_mask_phisemits exact per-edgeboolean(phi_edge, qb), andfill_phisuses a fixed-pointresolved[idx][n]loop preventing empty phis or duplicatewaveActiveBallotcalls on cyclic masks read as data.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:192 files ok;cargo clippy(default +--features diagnostics): 0 warningsemit::lower::tests(33/33),structure::(16/16, 1 ignored),phi(25/25, includingemit::lower::phi::testsand both GPUlane_mask_phi_*tests), andemit::semantics_tests(34/34 on both RTX 5090 and WARP, 1 ignored) all passed.Solid fix and welcome
lower.rssize reduction; LGTM.@Anzymanz on GitHub · 2026-11-26 02:19 UTC · original
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).a lane-mask join of an untracked maskall translate.63bcca4+ #2348 + #2978, then with this PR (a3defeccherry-picked; the only conflicts were themodlines and adjacent test additions, keep both): refused 219 → 202. 17 programs now translate: the 13 above, plus 4 that #2348 and #2978 had brought to a lane-mask join. 1,418 programs' output changes in all, and none goes from translated to refused.Not run: your GPU tests, and the title in a game run. Translation only.
@steven-seagull27 on GitHub · 2026-11-26 03:12 UTC · original
@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, 15and stores one result per lane. Only lanes 0–3 should write 1. Ona3defec, translation stops ata constant lane mask. The select's direct inline mask never enters the scan. A partial mask in a scalar register can likewise be recorded inst.other, while the scan only looks inst.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.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_masksand fixed-point resolution stay inlower/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.rsis 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.
@catminou4 on GitHub · 2026-11-24 13:19 UTC · original · reviewed
Test-merge with current main (
ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touchedlower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.@steven-seagull27 on GitHub · 2026-11-26 09:55 UTC · original
@nathanbzrr I rebased the direct-select mask fix onto your current head,
9099742, and reran the same regression on both revisions. The fix is one commit. Patch and regression testOn
9099742, all three adapters returned 64/64 correct lane values for the inline zero and all-ones controls. Translation then stopped at byte offset 24 witha constant lane maskforv_cndmask_b32 v1, 0, 1, 15, before that case could dispatch. Lanes 0–3 should select 1 and the other 28 should select 0.On your PR branch at
9099742, these commands fast-forward to the tested commit and run the synthetic readback test.AI-assisted with Codex.
@fuzeofficlal on GitHub · 2026-11-26 11:01 UTC · original · requested changes
Splitting
emit/lower/phi.rsbringsemit/lower.rsdown to515,626bytes (under the524,288-byte policy limit) and the added structure/lowering/execution tests pass on RTX 5090 and WARP, but there are two correctness issues and a formatting check failure to resolve before merging:emit/lower.rs:8238-8247,emit/lower/phi.rs:121-154):uniform_joinandforward_uniformonly inspect immediate predecessors' exits, treating anyLaneExit::Jumppredecessor as uniform. Consider a Wave32 shader that initializess2to0, narrowsEXECto lanes0..16(saving the originalEXECins7), and branches ons_cbranch_execzso the nonempty arm copiess7intos2and jumps to the join while the skip arm also reaches the join via an unconditionals_branch, whereEXECis restored andv_cndmask_b32selects ons2. On GFX10, the nonempty arm writes the wave-wide SGPRs2, so all 32 lanes should select true; because both immediate predecessors end inJump,uniform_joinreturnstrueandfill_mask_phisfeeds per-lanephi_edgebooleans (trueto lanes0..15,falseto lanes16..31). Please keep rejecting joins unless uniformity across earlier EXEC splits is proven, and add a readback test covering twoJumppredecessors.avoidsvs.no_mask_lane_on_edgemodel mismatch (emit/lower.rs:8177-8190,emit/lower/phi.rs:155-158):avoidsreadsst.phi_masks[&ph.value][n](falling back tost.masks.get(&ph.args[n])), whereasfill_mask_phissynthesizesfalseviano_mask_lane_on_edgewhenst.masks.get(&arg)isNoneand!uniform. Ifphi_masksstores a non-FALSEboolean derived from an unmasked data operand along that edge, the boolean model queried byavoidsdiverges from thefalseconstant emitted into the phi.rustfmt --edition 2024 --checkfails on newly added code incrates/victory-shader/src/emit/lower/phi.rs(lines 34, 412) and the new tests incrates/victory-shader/src/emit/valu_tests.rs(lines 2557–2599).Verified locally on Windows 11 x64 (RTX 5090 + WARP,
90997428):cargo run --locked -p xtask -- policy(192 files ok) andcargo clippy --workspace --all-targets -- -D warnings(default and--all-features): clean.structure::tests: 16 passed (1 ignored);emit::lower::tests: 33 passed;emit::lower::phi::tests: 11 passed; RTX 5090 &VICTORY_WARP=1valu_tests::lane_mask_phi_*: 6 passed, 0 failed.@steven-seagull27 on GitHub · 2026-11-26 11:27 UTC · original
@nathanbzrr @fuzeofficlal I reproduced both findings on
90997428. In the first shader, both incoming blocks end in an unconditional jump, but their reach conditions select complementary lanes. If any lane enters the nonempty arm, its scalar write copies the original EXEC (all 32 bits) to s2. ReviewThe RTX 5080, Windows inbox WARP, and WARP 1.0.22 each returned the same 72/192 incorrect words. For 16 active lanes, lanes 16–31 read
0where1was expected. The patch refuses the unproven join before dispatch. A twin driven by a uniform scalar compare still translates and matched 192/192 per adapter. The regression also exercises initializing s2 from VCC, so both incoming masks are tracked.The second regression is a synthetic pixel shader. One arm overwrites the interpolation j coordinate. On that incoming edge, the original interpolation proof reads
TRUEwhile the emitted phi usesFALSE. With the inverted mask the original accepted the shader. The patch drops the contradictory fact, and both guard polarities now get the expected computed-barycentrics refusal. This check is at translation time.The structure, lowering, phi and emitter test groups passed, including the existing valid interpolation and execution controls. I also ran shader Clippy with all features and the asset-policy check. This commit is based directly on the PR head and is independent of my earlier direct-select fix. Patch and both regressions
AI-assisted with Codex. Synthetic inputs on native Windows.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.