Shaders: lower v_pk_fmac_f16 #90
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/90"
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 Zettrox/ztrx. Originally posted by Ingenioeren on 2026-11-25T10:07:22Z.
What
v_pk_fmac_f16(VOP2, opcode 0x3C) is lowered now. Until now any program containing it was refused with "a packed 16-bit operation". The instruction goes through the existingpacked16path. Each 16-bit half of the destination (the accumulator) gains the product of the matching halves ofsrc0andsrc1, computed through f32 with FMad likev_pk_fma_f16.A new helper,
fmac_half, reads the operands:self.src0), as for every other VOP2 operation here.neg/absmodifiers and SDWA. Which halves those apply to isn't modelled, so the program is refused rather than lowered with a guess.Why
The lowering comes from upstream VIctory (0b35b7f). Upstream reads source 0 directly and so drops the DPP-selected lane, which was reported there as Marvisak/VIctory#2228 (fixes are open upstream). This port reads the DPP lane from the start, so ztrx doesn't pick up that bug.
How tested
Windows 11, AMD Radeon RX 6750 XT plus WARP, Rust stable MSVC, on
90b529f:cargo test --locked --offline -p victory-shader --lib packed_fmac: 2 passed.packed_fmac_accumulates_each_half:(2.0, 1.0) * (3.0, 4.0) + (1.0, 0.5) = (7.0, 4.5)on the hardware adapter and WARP.packed_fmac_with_dpp8_reads_the_selected_lane: 8 lanes, each lane'ssrc0is(lane, lane)in f16, and DPP8 makes lane i read lane i^1. Lane 0's result is read back throughv_readfirstlane_b32, so which lane's store lands doesn't matter. It runs on hardware only. The cross-lane read declaresWaveSize(32), which WARP's pipeline creation refuses; the existing LDS tests in this file are hardware-only for the same reason.lower(the instruction is refused). With the fix but source 0 read directly (the upstream behaviour), the DPP8 test fails with0x38003C00, the lane's ownsrc0, instead of0x44804400.cargo test --locked --offline -p victory-shader: 210 passed, 2 failed, 2 ignored. The two failures areemit::rect::tests::the_rectangle_stage_is_a_geometry_shaderandemit::rect::tests::rectangles_are_drawn_whole(dxil.dll: "Container part 'Pipeline State Validation' does not match expected"). Unmodifiedmainon this machine fails the same two (208 passed, 2 failed), so they come from the local validator and not from this change.cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings: clean.cargo fmt -p victory-shader --check: no diffs in the lines this PR touches.cargo run -p xtask -- policy --staged: 2 files ok.Not tested: NVIDIA hardware (this machine has an AMD GPU, so this is a code-level change proven by synthetic tests only), DPP16 row controls (they use the same
self.src0path, but no test covers them here), and no game run.AI assistance: prepared with Claude Code, reviewed by Ingenioeren.
🤖 Generated with Claude Code
Imported from Zettrox/ztrx. Originally posted by hamdog0203 on 2026-11-25T11:51:53Z.
Independent verification on NVIDIA RTX 4060 (8 GB, Wave32, driver 621.35) + WARP + Windows SDK
dxil.dll(10.0.26100.0), Windows 11 x64 (26200.9974),rustc 1.98.1, audited at commit2918143b920e6754c75fd68b37689a9fc8f12807:crates/victory-shader/src/emit/lower.rsandvalu_tests.rs(nounsafe). Properly readsself.src0for DPP and conservatively refuses constant operands andneg/abs/SDWA modifiers rather than guessing half-selection.cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)cargo test --locked -p victory-shader --lib packed_fmac -- --nocapture: both tests passed (packed_fmac_accumulates_each_halfon RTX 4060 + WARP +dxil.dll, andpacked_fmac_with_dpp8_reads_the_selected_laneon RTX 4060 +dxil.dllwith no skip)cargo test --workspace --locked: all crates passed with 0 failures (victory_shader: 212 passed, 2 ignored — including bothemit::rect::testspassing against SDKdxil.dll10.0.26100.0;xtaskasset-policy: 4 passed)Looks solid from an NVIDIA Wave32 perspective (synthetic tests + full workspace suite; no game run performed).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.