Shaders: v_pk_fmac_f16 with DPP reads src0 from the selected lane #2229
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!2229
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2229"
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
BastienRodz:shader/pk-fmac-dpp-src0→main· +164 −1 · 2 files · 1 commits · openWhat's wrong
For a VOP1/VOP2 instruction with DPP,
Lower::valufetchessrc0from the selected lane and leaves it inself.src0;fsrc,src,half_srcandv_cndmask_b32use it for source 0.Lower::fmac_half, which reads the halves ofv_pk_fmac_f16, calledself.operandinstead, sov_pk_fmac_f16_dppmultiplied the lane's ownsrc0in both halves. RDNA 2 ISA §12.7 defines the operation on S0, and §6.9 says DPP selects VOP1/VOP2 operands "from different lanes (threads) rather than just using a thread's own lane".What the fix does
fmac_halftakesself.src0for source 0 when it is set, like the other readers. Nothing changes without DPP.Tests
New
emit::valu_tests::packed_fmac_dpp_reads_the_swizzled_lane: a pixel program on a 2x2 target packs a per-pixel pair of halves, runsv_pk_fmac_f16_dpp quad_perm:[1,0,3,2], and checks each pixel got its horizontal neighbour's product. A pixel program is used because quad permutes behave the same at any wave size, so the test also runs on WARP (a compute version would declare the console's wave of 32, which WARP and llvmpipe refuse).main(940d32f) it fails: every pixel gets its own product (left: [[6.5, 6.0, …], [10.5, 8.0, …], …],right: [[10.5, 8.0, …], [6.5, 6.0, …], …]).packed_fmac_accumulates_each_halfpass.VKD3D_FEATURE_LEVEL=12_2 VKD3D_SHADER_MODEL=6_6).Not tested
Not run on an AMD/NVIDIA GPU. No
dxil.dllhere, so the new program was not run through the validator locally. Whether title shaders usev_pk_fmac_f16with DPP is not measured.Fixes #2228
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed, trimmed and verified it). No game data used.
🤖 Generated with Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:59 UTC · original
I ran the same quad-permute fixture on
940d32fand exact head754e60eon native Windows. I made DXIL validation and the software-device creation mandatory. The DXC 1.9.2609 validator accepted both shaders on both revisions.The render used Agility 1.620.2 and packaged WARP 1.0.22, with both loaded module paths checked. Reading the 2x2 target gave these low/high pairs in pixel order.
940d32f: (6.5, 6), (10.5, 8), (14.5, 14), (18.5, 16). This failed the test because both halves used their own lane.754e60e: (10.5, 8), (6.5, 6), (18.5, 16), (14.5, 14). All four readbacks passed and matched the horizontal neighbour.The inbox WARP device reported SM 6.2 and could not run this fixture. AI-assisted. Synthetic shaders only.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 09:12 UTC · original
I also checked the DPP8 encoding from #2228 with a separate compute fixture. The existing pixel test covers DPP16. This fixture dispatches one group of 32 threads, swaps adjacent lanes within each eight-lane DPP8 group, and reads back both packed halves from every thread.
940d32f: lane 0 returned[2, 1], its own-lane result. It should have returned[3, 5]from lane 1.754e60e: both halves matched the selected lane across all 32 readback words.Native DXIL validation passed for both. The execution used app-local Agility 1.620.2 and WARP 1.0.22. The test-only
b940374sits directly on your current head and passes strict shader Clippy. If you fold in the test, please retainCo-authored-by: andrewpozdnakov7-jpg <[email protected]>.@BastienRodz on GitHub · 2026-11-25 09:15 UTC · original
Thanks for running the DPP8 case. I'll keep the PR to the one test: DPP16 and DPP8 both go through
Lower::dppbeforefmac_halfreadsself.src0, so the fix doesn't depend on the encoding, and your results here already record that DPP8 behaves the same. If the maintainer would rather have both encodings covered, I'm happy to fold in b940374 with your co-author line.@sinan-cmyk on GitHub · 2026-11-25 10:39 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
754e60e4ontomain940d32f(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: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 13:31 UTC · original · edited 2026-11-26 00:22 UTC
Automated triage for the maintainers.
Merge candidate (worth a look). The head is unchanged (
754e60e).Lower::fmac_half(crates/victory-shader/src/emit/lower.rs) reads source 0 ofv_pk_fmac_f16from the DPP lane-selectedself.src0, as the other source helpers do;mainstill readsself.operandthere. The new pixel test fails onmainand passes with the fix on WARP and on an RTX 4070 (per a tester). CIcheckpasses and it still merges cleanly into the currentmain.On your reply: agreed. DPP
src0_neg/src0_abson a packed op is a separate question that needs AMD hardware evidence, and keeping it out of this PR doesn't change the verdict.Generated by Claude Code
@Mericas77 on GitHub · 2026-11-25 15:33 UTC · original
Tested on NVIDIA hardware (RTX 4070, Ada, wave32), Windows 11, Agility 1.620.2, on base
940d32f. Earlier runs here were WARP only.#2229 (head
754e60e):packed_fmac_dpp_reads_the_swizzled_lanepasses on the 4070 and on WARP. Without thelower.rschange it fails on the hardware with the rows unswapped ([6.5, 6],[10.5, 8], ... instead of[10.5, 8],[6.5, 6], ...).Cross-check with #2266 (head
1483d37): the two fixes are equivalent. Each PR's test fails on main'slower.rsand passes with either PR's fix. #2266's test (row_shr:1 with bound_ctrl) gives0x44004400(2.0 × 2.0 in both halves) without a fix and0with one. Its comment says WARP refuses the pipeline. Here I only ran it on the hardware, as written. #2229's test does run on WARP on this machine.Full crate (
victory-shader --lib): 245 passed, 3 failed, 3 ignored with either PR. That is the same 3 failures main has on this card (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,synthetic_tests::gathers_at_a_level_match_the_hardware, see #1835). Neither PR adds a failure.So #2229 looks fine to merge from the NVIDIA side, and #2266 is a duplicate of it.
One adjacent point, not covered by either PR: the DPP16 dword's
src0_neg/src0_absbits are decoded intov.neg/v.abs(gfx10/fields.rs, the0xFAarm). Forv_pk_fmac_f16,packed16appliesv.negto the low half only (neg_histays 0 for a VOP2) and never readsv.abs. So av_pk_fmac_f16_dppwithabswould silently lose it, and one withnegwould negate only the low half. I can't check what RDNA 2 does with those bits on a packed op from NVIDIA hardware. Refusing modifiers with DPP onv_pk_fmac_f16might be the safer choice until someone checks on an AMD card. That is only worth doing if the title actually emits that form.AI-assisted.
@BastienRodz on GitHub · 2026-11-25 15:35 UTC · original
Thanks @Mericas77, it's useful to have it confirmed on Ada hardware, and the cross-check with #2266 too. On the DPP
src0_neg/src0_absbits forv_pk_fmac_f16: agreed, that's a separate question from the lane selection fixed here. I'd rather keep this PR to the one-line fix and leave modifier handling for a check on an AMD card, if the title turns out to emit that form.@catminou4 on GitHub · 2026-11-25 08:48 UTC · original · approved these changes
v_pk_fmac_f16 with DPP reads src0 from the lane's own value. Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 144 passed, 0 failed, 2 ignored. Approving.@DenRakEiw on GitHub · 2026-11-25 09:02 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib packed_fmac_dpp_reads_the_swizzled_lane— passed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean fix reading
src0from the DPP-selected lane inv_pk_fmac_f16, verified end-to-end on RTX 5090 + WARP. Looks great.AI-assisted (Gemini 4 Neon).
@fyernald on GitHub · 2026-11-25 17:33 UTC · original · approved these changes
Verified on RTX 3080 (617.42), Windows 10 (19045) plus WARP,
main67e8ae1+ #486 + #2596 (the suite crashes on NVIDIA without #2596, #2571).cargo test -p victory-shader --lib --locked -- --test-threads=1: 268 passed, 3 failed (the #1835 ones, also on the base).packed_fmac_dpp_reads_the_swizzled_lanepasses on both adapters.#2266 makes the identical change (
self.src0fork == 0in the packed-operand read). This PR came first and has the more thorough test, so I'd take this one.@andrewpozdnakov7-jpg on GitHub · 2026-11-26 16:56 UTC · original
I checked this together with #2623, following the same-card RX 7900 XTX retest of its latest head. I merged
754e60eintoa756f0fon the current63bcca4base. Git merged bothlower.rsandvalu_tests.rscleanly.On #2623 alone with this PR's test added, the DPP case leaves the rows unswapped. The exact combined heads swap both row pairs correctly. All 42 VALU tests passed, including the plain packed FMAC control, scalar clamp and rounding, and the directed subnormal/non-finite fixture. The separate
f16_arithmetic_rounds_oncecomparison had zero mismatches. I used WARP 1.0.22 with Agility 1.620.2 and DXIL validation. Clippy and asset policy also passed.These changes can be merged independently. The hardware evidence for the scalar fix is in the RX 7900 XTX retest. AI-assisted with Codex.
@fuzeofficlal on GitHub · 2026-11-26 17:01 UTC · original · approved these changes
Verified
754e60e44c7226c85748a5d65f3edf030c33ddd2merged cleanly onto63bcca43on Windows 11 with an RTX 5090 (Wave32), WARP,dxil.dll(Windows SDK 10.0.26100.0), andVICTORY_D3D12_DEBUG=1.Code review
Lower::valucomputes the DPP-swizzledsrc0viaself.dpp(inst, d)and stores it inself.src0for the duration ofvalu_opacross both DPP16 and DPP8 encodings. HavingLower::fmac_half(crates/victory-shader/src/emit/lower.rs:6638-6651) takeself.src0whenk == 0bringsv_pk_fmac_f16in line withfsrc,src,half_src, andv_cndmask_b32while leaving non-DPP lowering untouched.crates/victory-shader/src/emit/lower.rsmerges cleanly onto63bcca43at520,645bytes (< 524,288limit;520,942bytes when co-merged with#2167, with zero conflict).Verification
cargo xtask policy:191 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features): clean.dxil.dll+VICTORY_D3D12_DEBUG=1:packed_fmac2 passed, 0 failed (packed_fmac_accumulates_each_halfandpacked_fmac_dpp_reads_the_swizzled_lane, validated bydxil.dlland passing on both RTX 5090 hardware and WARP).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.