Shaders: fix whole-wave EXEC inline constant sign-extension and prefix lane validation #646
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!646
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/646/head"
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 06:06 UTC · original
nathanbzrr:shader/wave-exec-const-and-prefix-validation→main· +293 −22 · 1 files · 1 commits · merged 2026-11-25 00:16 UTCSummary
Fixes two silent miscompilation bugs in whole-wave symbolic simulation (
crates/victory-shader/src/emit/wave.rs):constant()collapsed all negative inline integer constants-2..=-16(and negative 32-bit inline floats like-1.0f) tou64::MAX(-1), turning maskeds_mov_b32 exec_lo, -2/s_mov_b64 exec, -2steps intoexec == all, silently clobbering lane 0 and bypassingif exec != allguards. In addition,EXEC/EXEC + 1updates insimulate()were not masked by& all, causing 64-bitexecwrites in wave32 sections to missexec == all.per_lane(),op: Nonelanes withfound == Nonehit(None, None) => continuebefore checking(src, mask, ident, inclusive), allowing mismatched lane 0 / lane 1 values in prefix scans to be silently accepted as validShape::Prefix.Changes (
crates/victory-shader/src/emit/wave.rs)constant(inst)to distinguish 64-bits_mov_b64from 32-bit moves: decodeNULL(125) as0, sign-extend 64-bit inline integers (128..=208) viai64::from(x as i32) as u64, keep 32-bit inline constants zero-extended, and returnNonefor non-integer inline constants ons_mov_b64.EXECandEXEC + 1updates insimulate()by& all.meta: Option<(Value, Value, u32, bool)>independently fromop_foundinper_lane()so everySym::Redlane (including single-laneop: Nonelanes 0 and 1) validates(src, mask, ident, inclusive),op.identity(ident), andlanes[0]inclusive/exclusive invariants.constant_decodes_width_and_inline_kinds,exec_minus_two_masks_lane_zero_and_enforces_dpp_guard,wave32_mov_b64_all_lanes_keeps_exec_masked_for_dpp,per_lane_prefix_soundness).Verification
Isolated verification on branch
shader/wave-exec-const-and-prefix-validation(12eba49):rustfmt --edition 2024 --config skip_children=true --check crates/victory-shader/src/emit/wave.rs(passed)cargo test -p victory-shader -- --test-threads=1(73 passed, 0 failed, 0 ignored)cargo clippy -p victory-shader --all-targets(0 warnings)cargo xtask policy(151 files ok)No game files. AI-assisted; reviewed and verified with the tests above.
@geiyiliyabumo on GitHub · 2026-11-24 10:47 UTC · original
Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver
32.0.32029.2010, Rust1.98.1), cleanly merged ontomain(ffe310e):cargo xtask policy: PASS (154 files ok)cargo clippy -p victory-shader --all-targets --locked -- -D warnings: PASScargo clippy -p victory-shader --all-targets --features diagnostics --locked -- -D warnings: PASScargo test -p victory-shader --locked: 124 passed, 0 failed, 1 ignored (including all newemit::wave::tests::*cases)VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader --locked -- valu_tests: 13/13 PASS on RX 9060 XT and 13/13 PASS on WARP (VICTORY_WARP=1)Diff review of
crates/victory-shader/src/emit/wave.rslooks solid:128..=208) fors_mov_b64fixes the-2..-16 -> u64::MAXbug while keeping float inline constants rejected on 64-bitB64moves and zero-extending 32-bit literals per RDNA2B64rules.execwithallon bothEXECandEXEC+1updates prevents high-half leakage in wave32.metaandop_foundinper_lanecloses the single-laneop: Nonebypass and properly validateslanes[0]andop.identity(ident).AI-assisted; synthetic tests only, no game files.
@molodayamama on GitHub · 2026-11-24 14:06 UTC · original
Independent Windows check of
12eba495039d8018eb6959be95fcc10e387b7e33(Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).cargo test -p victory-shader --locked --lib emit::wave::tests -- --test-threads=1 --nocapture: 6 passed.The whole-wave fixtures covered inline constant kinds, signed
EXEC = -2, DPP guarding with lane zero masked, and the wave32/wave64 prefix checks. This is a CPU-side analysis run.Only source-built synthetic fixtures were used. AI-assisted verification.