Shaders: honor DPP16/DPP8 fi and source-lane EXEC activity #1485
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!1485
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1485/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?
@ESAT586 on GitHub · 2026-11-24 18:21 UTC · original
ESAT586:shader/dpp-fi-inactive-lanes→main· +350 −14 · 2 files · 2 commits · closed without mergingSummary
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).@marquezinii on GitHub · 2026-11-24 18:48 UTC · original
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.@wwwwwwww3333333 on GitHub · 2026-11-24 19:15 UTC · original
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).
@Capt-Speed on GitHub · 2026-11-24 19:27 UTC · original
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.@ESAT586 on GitHub · 2026-11-24 19:37 UTC · original
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.)
@sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original
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).
@wwwwwwww3333333 on GitHub · 2026-11-24 21:50 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 00:41 UTC · original
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