Shaders/wave: seed EXEC in uni map and validate full wave64 mask pairs #759
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!759
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-759"
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?
@AscilCH on GitHub · 2026-11-25 06:44 UTC · original
AscilCH:fix/shader-wave-exec-uni-and-wave64-mask-pair→main· +178 −34 · 1 files · 1 commits · openProblem
Two soundness bugs in whole-wave section simulation (
crates/victory-shader/src/emit/wave.rs):EXECentries inuni:simulate()never inserted section-startEXEC/EXEC+1SSA values or mid-sections_mov_b*writes toEXEC/EXEC+1intouni. An in-section read ofexec_lo/exec_hi(e.g.s_mov_b32 s8, exec_loorv_mov_b32 v2, exec_lo) fell back toSym::Uni(exec_val)->Shape::Value(exec_val), which lowering turned into the divergent hostwaveActiveBallot(true)(or failed to lower) instead of the section's constant mask (0xFFFF_FFFFor the mid-section constant).sections()accepted 32-bits_or_saveexec_b32/s_nand_saveexec_b32and 32-bitexec_lo-only restores in wave64 even though lanes 32..63 are untouched.simulate()accepted 32-bits_and_b32in wave64 and checked only the low dwordValueins_and_b64andv_cndmask_b32, so overwriting the high dword of a saved or derived wave64 mask still produced a validSym::Red.Fix
uniwith section-startEXEC/EXEC+1constant values (u32::MAX) and updateunion mid-section constants_mov_b*writes toEXEC/EXEC+1.(Value, Option<Value>)mask pairs inmasked, require 64-bit start, restore, ands_and_b64in wave64, and match both low and high dwords ins_and_b64andv_cndmask_b32.Verification
cargo test -p victory-shader --locked -- emit::wave emit::wave64_tests:15 passed; 0 failed(including new testsin_section_exec_reads_export_section_constantsandwave64_mask_checks_high_dword_and_rejects_32bit_ops).cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, no game data.)
Two soundness bugs in crates/victory-shader/src/emit/wave.rs: 1. `simulate()` never inserted section-start `EXEC`/`EXEC+1` SSA values or mid-section `s_mov_b*` writes to `EXEC`/`EXEC+1` into `uni`. Any in-section instruction reading `exec_lo`/`exec_hi` (e.g. `s_mov_b32 s8, exec_lo` or `v_mov_b32 v2, exec_lo`) fell back to `Sym::Uni(exec_val)` -> `Shape::Value(exec_val)`, which lowering then read as the divergent host `waveActiveBallot(true)` (or rejected) instead of the section's constant mask (`0xFFFF_FFFF` or the mid-section constant). Seed `uni` with the section-start `EXEC`/`EXEC+1` values and update it on mid-section constant writes. 2. In wave64, whole-wave mask tracking checked only the low dword (`Value`): - `sections()` accepted 32-bit `s_or_saveexec_b32`/`s_nand_saveexec_b32` and 32-bit restores that leave `exec_hi` unmodified. - `simulate()` accepted 32-bit `s_and_b32` as a wave64 mask derivation and never verified `code + 1` in `s_and_b64` or `v_cndmask_b32`, so clobbering the high dword of a saved/derived mask still produced a valid `Sym::Red`. Track `(Value, Option<Value>)` mask pairs in `masked`, require 64-bit start, restore, and `s_and_b64` in wave64, and match both dwords in `s_and_b64` and `v_cndmask_b32`.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.