Shaders: lower v_pk_fmac_f16 (VOP2 0x3c and VOP3 0x13c) #1136
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!1136
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1136/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 16:07 UTC · original
ESAT586:shader/pk-fmac-f16→main· +177 −0 · 2 files · 1 commits · closed without mergingWhat's wrong
v_pk_fmac_f16(VOP20x3c/ VOP30x13c) is already decoded ingfx10/opcodes.rs, andvalu_opdispatches anyv_pk_*instruction intopacked16. Becausepacked16only matches VOP3Pv_pk_*ops,v_pk_fmac_f16fails lowering withUnsupported { what: "a packed 16-bit operation" }.Additionally, unlike VOP3P instructions (which use
op_sel/op_sel_hito select halves per lane),v_pk_fmac_f16uses VOP2/VOP3 encoding where the low half always comes from bits[15:0]and the high half from bits[31:16], accumulates intovdst, and applies VOP3abs/neg/omod/clampto both packed f16 halves.Fix
Lower::pk_fmac_f16incrates/victory-shader/src/emit/lower.rs(dispatched beforepacked16invalu_op):d.lo = s0.lo * s1.lo + d.loandd.hi = s0.hi * s1.hi + d.hiin f32 (matchingvalu16/packed16) vialegacyF16ToF32,fmad, andlegacyF32ToF16.self.src0for DPP, GFX10 inline constant expansion (f16_operandplaces inline constants in the low half and 0 in the high half), and VOP3abs,neg,omod,clamp.Err("SDWA on v_pk_fmac_f16")).emit::valu_tests::v_pk_fmac_f16_matches_rdna2incrates/victory-shader/src/emit/valu_tests.rstesting:v_pk_fmac_f16on two packed f16 pairs with independent accumulators,v_pk_fmac_f16with inline constant1.0(0xF2, verifying low-half1.0and high-half0.0pass-through),v_pk_fmac_f16(0x13c) withabs[0],neg[1], andclamp.Verification (Real GPU + WARP + CI Gates)
Tested on Windows 11, NVIDIA GeForce RTX 3060 Ti (driver
32.0.16.1656), Rust1.98.1:cargo test -p victory-shader --lib v_pk_fmac_f16_matches_rdna2: ok (dxil.dllvalidator + RTX 3060 Ti hardware + Microsoft WARP)cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignoredcargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)cargo xtask policy:asset policy: 154 files okScope & Non-Overlap
v_pk_fmac_f16.AI-generated & verified with Gemini 4 Neon (High Mode) — not written by a human engineer. `v_pk_fmac_f16` (packed 2x f16 multiply-accumulate into the destination VGPR) is decoded by gfx10 (VOP2 0x3c / VOP3 0x13c) but previously routed into `packed16`, which rejected it with `Err("a packed 16-bit operation")`. Add `pk_fmac_f16` in `lower.rs` to compute both f16 halves (`lo` and `hi`) via `legacyF16ToF32` -> `fmad` -> `legacyF32ToF16`, honoring DPP (`self.src0`), GFX10 inline-constant expansion (low half = constant, high half = 0), and VOP3 `abs`/`neg`/`omod`/`clamp` modifiers across both halves. Verified with synthetic GPU + WARP + dxil.dll tests in `valu_tests.rs` on NVIDIA GeForce RTX 3060 Ti (Windows 11, Rust 1.98.1). No game data used. Co-Authored-By: Gemini 4 Neon (High Mode) <[email protected]>@ghost on GitHub · 2026-11-24 16:35 UTC · original
Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head
0dcf6d0on mainffe310e. Your report lists NVIDIA and WARP, so this adds AMD hardware.v_pk_fmac_f16_matches_rdna2passes: VOP2, the VOP2 inline 1.0 case (hi half kept), and the VOP3 abs/neg/clamp case.stub_pipeline_is_created, fails on main too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR).Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too); whether the new test fails without the fix on this host.
AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
0dcf6d0:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:32 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Lowers v_pk_fmac_f16. In main since today (lower.rs:6389-6400, tests packed_fmac_accumulates_each_half and the semantics probe).
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