Shaders: honor DPP16/DPP8 fi and source-lane EXEC activity #1484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1485"
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 ESAT586 on 2026-11-24T18:21:30Z.
Summary
Fixes VIC-BT-008 from #1242:
Lower::dpp()incrates/victory-shader/src/emit/lower.rspreviously ignored thefi(fetch-inactive) modifier on both DPP16 (0xFA) and DPP8 (0xE9/0xEA) and never checked whether the source lane was active inEXEC.Root Cause
On RDNA2 hardware, when
fi == 0(Dpp::Row { fi: false, .. }or DPP80xE9), reading from an inactive source lane (EXEC[src] == 0) is treated identically to an out-of-bounds lane:bound_ctrl:1supplies0assrc0.bound_ctrl:0(and DPP80xE9) disables the destination write sovdstretains its previous value.fi:1(Dpp::Row { fi: true, .. }or DPP8FI0xEA) fetches an inactive source lane's VGPR value.Previously
dpp()discardedfi(..) and only checked row bounds forrow_shl/row_shr, so active lanes under partialEXECmasks read stale VGPR values from inactive neighbor lanes.Fix
crates/victory-shader/src/emit/lower.rs:guard: Option<V>intoLower::dpp().!fi, compute the active-lane bitmask withdx.op.waveActiveBallot(guard.unwrap_or(true))(covering both divergent DXIL branches and non-branching in-blockEXECguards), test bitsrc(handling Wave64's upper dword and host quad indices formesh_quad), and combineinside && src_activeintovalidbefore applyingbound_ctrl(select(valid, r, 0)) or destination write masking (enable = Some(valid)).crates/victory-shader/src/emit/valu_tests.rs:dpp16_and_dpp8_honor_fi_and_source_lane_exec: lowers 6 Wave32 compute shaders (EXEC = 0x7777_7777), validates each withdxil.dll, and runs all 6 on WaveSize(32)-capable D3D12 devices:row_shr:1 bound_ctrl:1 fi:0(guardedEXEC)row_shr:1 bound_ctrl:1 fi:0(brancheds_cbranch_execz)row_shr:1 bound_ctrl:0 fi:0(guardedEXEC, preserves oldvdst)row_shr:1 bound_ctrl:1 fi:1(guardedEXEC, fetches inactive lane)0xE9fi:0(guardedEXEC, preserves oldvdstwhen source inactive)0xEAfi:1(guardedEXEC, fetches inactive lane)Verification
Ran locally on Windows with NVIDIA GeForce RTX 3060 Ti and
dxil.dll:cargo test -p victory-shader --locked— 121 passed, 0 failed (including all 6 Wave32 DPP cases on RTX 3060 Ti; WARP skipped cleanly due toWaveLaneCountMax = 4)cargo clippy --workspace --all-targets --locked -- -D warnings— passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings— passcargo xtask policy— 154 files okRelated to #1242 (
VIC-BT-008).Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:28:08Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib dpp16_and_dpp8_honor_fi_and_source_lane_exec— passed on RTX 5090 hardware (and skips cleanly on WARP where WaveSize(32) is unsupported)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean handling of DPP16/DPP8
fiand source-lane EXEC activity with end-to-end RTX 5090 verification. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T18:42:11Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e),cargo test -p victory-shader --locked→ 96 passed, 0 failed. Execution/valu tests are#[cfg(all(test, windows))]and were not run here; lowering/structure coverage only.DPP
fi+ source-lane EXEC activity (VIC-BT-008): withfi:0the source lane's activity is computed viawaveActiveBallotunder the current guard and ANDed intoinside/enable, so an inactive source lane reads as out-of-bounds (bound_ctrl:1 → 0, otherwise the destination keeps its old value). Wave64 selects ballot word 1 for lanes ≥ 32, and the mesh-quad path maps quad lanes to host lanes before the ballot bit test. FlagsWAVE_OPSset. The 268-line valu test exercises DPP16/DPP8 with narrowed EXEC both in-block and vias_cbranch_execz. Windows-only execution — verify on hardware/WARP before merge.Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:48:11Z.
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
fa0ee13.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 121 passed, 0 failed, 1 ignored.dpp16_and_dpp8_honor_fi_and_source_lane_execran on the hardware adapter, whose only wave size is 32. WARP skips it (WARP device does not support WaveSize(32)), so on this machine the hardware run is the only check. Thefi/bound_ctrlrules in the description (withfi:0, an inactive source lane behaves like an out-of-row one) match how I read the RDNA 2 DPP description.Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-24T19:15:09Z.
Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head
fa0ee13on mainffe310e(clean merge).cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignored (main alone: 120 passed).dpp16_and_dpp8_honor_fi_and_source_lane_execpasses. Output was captured, so this log doesn't show which adapters took the WaveSize(32) path; RDNA2 reports 32..64, so the hardware one should. This adds an AMD result to the NVIDIA runs already posted.Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
Imported from Marvisak/VIctory. Originally posted by Capt-Speed on 2026-11-24T19:27:11Z.
Thanks for working on
VIC-BT-008! I was independently verifying this on an RTX 5090 D at the same time and noticed three subtle issues in the current patch worth double-checking:DPP8(0xE9,fi:0) semantics (zero = falsevszero = true):The patch sets
zero = falseforDpp::Lanes, which disables writingvdstwhen the source lane is inactive. On RDNA2 (gfx1031) hardware (AMD RDNA2 ISA + verified acrossgfx1031hardware DPP sweeps),DPP8has no write-disable/bound_ctrl=0 mode: active destination lanes always write, and0xE9(fi:0) substitutes0assrc0for inactive source lanes (behaving likebound_ctrl:1, while0xEA/DPP8FIfetches the inactive source).waveReadLaneAt:self.read_lane(x, src)is currently emitted beforesrc_activeandvalidare computed, so out-of-row shifts (e.g.row_shr:1on lane 0, wheresrc = 0xFFFF_FFFF) and inactive source lanes are still passed directly todx.op.waveReadLaneAt(UB in DXIL). Selectingsafe_src = select(valid, src, lane)before callingread_laneavoids the UB even whenfi == 1on out-of-row lanes.cross_lane(quad)permits pixel shaders to emit quad DPP (quad_perm). Callingdx.op.waveActiveBallot(true)in a pixel shader marks WQM helper lanes as0per DXIL spec, which will zero out triangle-edge quad derivatives. Routing pixel quad ops throughquad_pick(quadReadLaneAt) and skippingwaveActiveBallotwhenguardisNone(or testingguardviaquad_pickwhenSome) avoids breaking helper lanes.I also opened a unified PR (covering both
VIC-BT-008andVIC-BT-018with these fixes and 29 synthetic Wave32 GPU tests) — happy to coordinate or defer if you'd prefer to update #1485 directly.Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-24T19:37:08Z.
Awesome catches, @Capt-Speed — thank you for the detailed review and hardware verification!
Applied all three improvements on this branch:
0xE9(fi:0) semantics: SwitchedDpp::Lanestozero = trueso inactive source lanes substitute0(0 + vsrc1, active destination lanes always write), while0xEA(fi:1) fetches the inactive lane; updated thedpp8 fi:0Wave32 test assertion accordingly.waveReadLaneAtlane index: Movedsrc_active/validcomputation before the lane read and selectsafe_src = select(valid, src, lane)so out-of-row indices (0xFFFF_FFFFon lane 0) and inactive source lanes are never passed todx.op.waveReadLaneAt.quad_permthroughquad_pick(quadReadLaneAt) and skippedwaveActiveBallot(true)whenguardisNone(testingguardviaquad_pickwhenSome) so triangle-edge WQM helper lanes stay intact for derivatives.Re-verified locally on Windows 11 with NVIDIA GeForce RTX 3060 Ti and
dxil.dll:cargo test -p victory-shader --locked: 121 passed, 0 failed (including all 6 Wave32 DPP16/DPP8 scenarios on RTX 3060 Ti)cargo clippy --workspace --all-targets --locked -- -D warnings&--all-features: passcargo xtask policy: 154 files ok(Authored and verified by Gemini 4 Neon — High Mode; synthetic tests only, zero game data.)
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:13:21Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
b77b148ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-24T21:50:39Z.
The new head passes on AMD too. RX 6750 XT (RDNA2, gfx1031, AMD driver 32.0.21045.29003), Windows 11, Rust 1.98.1 MSVC, head
b77b148on mainffe310e(clean merge).cargo test -p victory-shader --lib -- --test-threads=1 --nocapture: 121 passed, 0 failed, 1 ignored.dpp16_and_dpp8_honor_fi_and_source_lane_execran on the hardware adapter; WARP reporteddoes not support WaveSize(32) (4..=4); skipped. clippy-D warningsis clean.Unit tests only, no game files. AI-assisted (Claude; I ran it on my machine).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:41:10Z.
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1582. DPP16/DPP8 honour fi and inactive source lanes. #1582 carries the same dpp() change (near-identical code) plus ds_swizzle and a GPU test file of its own.
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