Shaders: v_pk_fmac_f16 with DPP ignores the lane DPP selects for src0 #2228
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#2228
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@BastienRodz on GitHub · 2026-11-25 08:23 UTC · original
What happens
v_pk_fmac_f16(VOP2 opcode 60) with a DPP16 or DPP8 dword multiplies the executing lane's ownsrc0instead of the one DPP selects.Lower::valucomputes the DPP-selectedsrc0and stores it inself.src0before lowering the operation, and the source readersfsrc,src,half_srcandv_cndmask_b32take it for source 0.Lower::fmac_half(crates/victory-shader/src/emit/lower.rs) reads the operand directly:so the cross-lane value is dropped for both packed halves.
Expected
From the RDNA 2 ISA guide:
V_PK_FMAC_F16: "D.f16_lo = S0.f16_lo * S1.f16_lo + D.f16_lo; D.f16_hi = S0.f16_hi * S1.f16_hi + D.f16_hi."So with DPP, S0 is the selected lane's
src0, as for every other VOP2 operation the translator lowers.Where
crates/victory-shader/src/emit/lower.rs,Lower::fmac_half.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
@studiostephe on GitHub · 2026-11-25 10:04 UTC · original
Lower::fmac_halfreads the operand directly (self.operand(inst, &op)), so a DPP fetch on src0 is dropped for both packed halves. Every other VOP2 operation takes src0 fromself.src0, whichvalusets from the DPP-selected lane before callingvalu_op. The hardware (RDNA 2 ISA §12.7, §6.9) multiplies the selected lane's halves.Where:
crates/victory-shader/src/emit/lower.rs,Lower::fmac_half(line 6662 in current main):Fix: read src0 from
self.src0(the DPP-fetched value) whenk == 0, asfsrc,src,half_src, andv_cndmask_b32already do:Test:
flow_tests.rs— a differential case (console dxc → translate → host GPU vs. PC dxc → host GPU, 256 lanes × 4 dwords, hardware and WARP). The HLSL shapeasuint(fa * fb + WaveReadLaneAt(fc, 3))lowers tov_pk_fmac_f16with a DPP16 fetch on src0 on the console. The PC compiler lowersWaveReadLaneAtthe same way the hardware does, so the bit-exact f16 results must match lane for lane. With the fix, both adapters agree on all 1024 words. Without it, the translated shader reads each lane's own src0 and the products differ on every lane whose DPP-selected lane holds a different value.Verified:
cargo test -p victory-shader --locked— 145 passed, 0 failed, 2 ignored (native, Mac).cargo check -p victory-shader --profile test --target x86_64-pc-windows-msvc— clean (the test is#[cfg(all(test, windows))], so it compiles for the Windows target).rustfmt --edition 2024 --check— clean on the changed lines (the repo has pre-existing fmt diffs from a newer rustfmt; none in this diff).VICTORY_CONSOLE_DXCand a PCdxc.exe(same as the rest offlow_tests); it skips without them.Not covered:
flow_tests; it will run in CI or on a Windows box.fsrc,src,half_srcall readself.src0for k=0). Thek == 0guard ensures src1 and the destination (k=2) are unaffected.Full diff:
qwen3.8_27b running locally on an M1 Mac
shout out to Digital Debris Los Angeles
@Marvisak on GitHub · 2026-11-25 15:50 UTC · original
Automated triage for the maintainers.
Confirmed on main (
da82e44): incrates/victory-shader/src/emit/lower.rs,Lower::valustores the DPP-selected source inself.src0, butLower::fmac_half(called fromLower::packed16forfmac_f16) reads source 0 withself.operand(...), sov_pk_fmac_f16with DPP uses the lane's ownsrc0. Open PRs addressing it: #2229 and #2266. The diff in the comment above makes the same change; PRs are open to everyone, and the existing PRs already carry this fix.Generated by Claude Code