Shaders: handle dead mask dwords at data joins and wave-uniform s_bcnt1 SCC #1269
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1269"
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?
Imported from Marvisak/VIctory. Originally posted by Sakura-Byte on 2026-11-24T16:58:23Z.
Fixes #878.
Summary
fill_phis): When a scalar register previously held a lane-mask dword before being overwritten on the live data path, the dead mask dword incoming edge at aphithat has at least one live scalar data (Val::I32) predecessor now lowers toundefon the mask edge rather than failing the whole join as a mask read, while mask-only joins continue to be rejected.s_bcnt1and mask SOP ops (mask_sccs,mask_any,mask_any_in):s_bcnt1_i32_b32(Wave32) /s_bcnt1_i32_b64(Wave64) on tracked lane masks,saveexecforms, and mask-writing SOP ops.getor acrossReg::Sccphis infill_phis) asdx.op.waveActiveBallot(...) != 0so SCC stays wave-uniform on Wave32 and Wave64 without per-lane divergence (avoiding the Wave32scc_laneregression noted on the earlier attempt).s_bcnt1's scalar destination rejected inMaskData::Noneand rejects mismatched-widths_bcnt1_i32_b32in Wave64 programs.Files Changed
crates/victory-shader/src/emit/lower.rs:mask_sccs,is_mask_value,mask_scc_source,mask_any,mask_any_in, updatedget/fill_phis, and synthetic DXIL/WARP tests (mask_dword_at_data_join_emits_undef_and_rejects_mask_only_joins,s_bcnt1_scc_only_translates_while_numeric_popcount_still_fails,s_bcnt1_scc_branch_stays_wave_uniform_on_warp).crates/victory-shader/src/emit/bitcode.rs:#[cfg(test)]inspection helpersModule::func_namesandModule::inst_lines.Verification
Ran cleanly on clean
origin/main(ffe310e):cargo xtask policy:asset policy: 154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)VICTORY_D3D12_WARP=1 VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:123 passed; 0 failed; 1 ignored(only the existing release-only benchmarkemit::bitcode::tests::bench_writeis ignored;dxil.dllvalidation ran; ins_bcnt1_scc_branch_stays_wave_uniform_on_warp, the Wave32 Mesh shader executes end-to-end on WARP checking[0.75, 0.75, 0.75, 1.0], and the Wave32 Compute shader verifiesdx.op.waveActiveBallot,cmp:33 ... k0(!= 0), anddxil.dllvalidation while skipping fixed[WaveSize(32)]PSO creation on WARP which returnsE_INVALIDARG).AI-assisted; synthetic tests only, zero game assets.
Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:03:16Z.
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 — main's host build is broken without it (E0425 host_resourceinvictory-gpu), so the base is that pair. Ran the four-stage offline check (translate, dxil-spirv, spirv-val, RADV pipeline) over 768 programs: the 751-program world dump plus a 52-program BVH capture, 35 duplicate containers skipped.No program gained or lost. The only difference in the failure table: two compute programs that read a lane mask as data now report "a lane mask holding lanes elsewhere read as data" instead of "a lane mask read as data", which is the new distinction working. No new failure, same 10 SPIR-V validation failures as the base.
Not tested: in-game.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:06:56Z.
Review: APPROVED
Dead mask dwords at data joins emit undef instead of a stale ballot, scalar ops writing tracked masks (and s_bcnt1 testing them) get their SCC mapped back to the mask's low dword (saveexec forms map EXEC's new value), so wave-uniform SCC branches on masks translate. Structure tests for the join/undef and s_bcnt1 SCC cases run on macOS. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 98 passed, 0 failed. Note: adds the same #[cfg(test)] op_names/insts helpers as #1275 — the second of the two to land will conflict textually.Imported from Marvisak/VIctory. Originally posted by rafaconvaitis on 2026-11-24T17:13:01Z.
I replayed the two mesh-shader containers reported as the largest and packed drops in the recent update-9 run on #293. Both runtime hash prefixes resolved in the local shader archive. Here is the direct comparison on Windows 11 build 26300 with the RTX 4070 selected explicitly.
ffe310e8c3092fc42cbb0ef5409053e14aa82235e56869c1ea883#1269 gets the first program past the lane-mask refusal. Adding #953 makes both reach the remaining descriptor-data case tracked in #798. Both still stop before DXIL validation or D3D12 PSO creation in the tested builds. These are offline translation results, so the in-game dropped-draw counts remain unmeasured for the stack.
AI-assisted test harness and reporting.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:36:15Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Stale mask dwords at data joins and bit counts of masks in mesh programs are both handled in main (dead_on_edge/live_edges/joins_loaded in fill_phis; host-wave bit count for mesh). This version gives the mask edge undef whenever another edge carries data, which is the unsound shortcut main moved away from.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed