Shaders: accept inline constants in V_PK_FMAC_F16 #3146
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3148"
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 Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T10:23:11Z.
Merge #2884 before #3148. The nearest-even packed FMA lowering in #2884 covers the infinite-multiplier case observed by Steven on the RTX 5080 and app-local WARP 1.0.22. With that dependency, Steven reported 360/360 results on each of three adapters. Adapter results
The PR now includes Steven's original test commit
7510c12for representative inline encodings, finite and infinite multipliers, and a register control. The local combination with #2884 at64c62d5passed all three packed FMAC tests, the packed single-rounding test, and 37 VALU tests on app-local WARP 1.0.22 with DXIL validation. The five-encoding fixture also passed in three fresh local WARP runs on the test commit alone.Please retain Steven's Git authorship for the regression test. If folding it into a different commit, use
Co-authored-by: steven-seagull27 <[email protected]>.V_PK_FMAC_F16fails to lower when SRC0 is an inline constant. Use the existing GFX10 FP16 operand decoder, which places inline FP16 constants in the low half with zero in the high half. LLVM AMDGPU encoding. The inline-float case was also noted in #1136.The synthetic VOP2 fixture returns
Unsupportedon main. With the change, it checks both output halves on WARP for inline 0.5, -4.0, and integer zero. The register-source control and all 36 VALU tests passed on WARP. Strict shader Clippy and the asset policy passed.AI-assisted with Codex. Please retain the Git author when cherry-picking or rebasing. If folded into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T10:28:02Z.
Review: APPROVED
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-shader --lib packed_fmac_accepts_inline_constants -- --test-threads=1: passed on RTX 5090 and WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Clean fix allowing inline constants in
V_PK_FMAC_F16.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T10:41:30Z.
I confirmed the three existing packed-FMAC inline cases on an RTX 5080, Windows WARP, and WARP 1.0.22. That agrees with the RTX 5090 review. I also found one case where the inline and register forms give different answers on this head (
c95fa3b).I tested all 90 inline encodings with a finite and an infinite high-half multiplier, reading both halves of each packed word. The register control loaded the same 32-bit pattern at run time. Each column counts mismatched halves out of 360. NaNs were compared by class, so different NaN signs or payloads pass.
All 74 differences were in the high half: the 65 nonnegative integer encodings and nine floating-point encodings contributed
+0there. With an infinite multiplier and a+1accumulator, those cases returned+1where0 × ∞ + 1should produce a NaN. For example, with inline integer1(src0=129), multiplier0x7c006400, and accumulator0x3c000000, the RTX 5080 read0x3c000400inline and0x7fff0400from the register. The low halves and every finite-multiplier control matched on all three adapters. The parent (63bcca4) refused all 90 inline programs during translation, while the register control passed on all three.I applied only the packed-FMA lowering change from #2884 at
64c62d5on top of this head. Both source forms then matched all 360 half results on each adapter. That gives the two PRs a concrete shared test for round-to-nearest-even.The test-only commit keeps five representative encodings, both multipliers, and the same-bit register control. To apply it on this PR and reproduce:
These are synthetic shader readbacks. AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T11:44:30Z.
Thanks, @steven-seagull27. I added your original test commit
7510c12with its Git authorship intact. On app-local WARP 1.0.22 with DXIL validation, the local combination with #2884 at64c62d5passed the three packed FMAC tests, the packed single-rounding test, and all 37 VALU tests. The smaller five-encoding fixture also passed in three fresh local WARP runs on the test commit alone. The 360-result matrix on each adapter is from your report.Please merge #2884 before #3148. If folding the regression test into another commit, please retain
Co-authored-by: steven-seagull27 <[email protected]>.Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T17:21:42Z.
Checked
7510c12on RDNA2 hardware, for all 90 inline encodings of SRC0 in VOP2v_pk_fmac_f16. I also checked it merged together with #2884 (64c62d5).What the hardware puts in the high half of an inline constant. I read each half as
constant × 1.0 + -0:0x00000001..0x00000040, so the high half is 0.0xffffffff..0xfffffff0, so the high half is0xffff, which is a NaN.0x00003800, -4.0 is0x0000c400, and 1/(2π) is0x00003118.That is what
f16_operandgives.Setup.
build_valu_csharness (a local test, not part of this PR). I ran it onmain63bcca4, on the PR merged onto it, and on #2884 + this PR. Each ran on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter inhardware_adapter).Both halves of each word are compared as f16, which gives 1,440 results.
a constant operand of v_pk_fmac_f16)This PR on its own: all 222 differences come from the f32
FMadpath, and both GPUs give the same ones:+0 × x + -0comes out-0where the hardware gives+0(148 results). Example: code 242 (1.0), multiplier 1.0, accumulator -0. The high half is0x8000here and0x0000on the hardware.0 × inf + 1comes out1.0where the hardware gives a NaN (74 results).The same values loaded from a register match on every branch, so this happens because the constant's high half is a compile-time 0.
With #2884: every result matches the hardware bit for bit on the Radeon. On the 5080 only NaN payloads differ.
So the merge order in your description is right: #2884 first, then this PR.
No game data was used.
AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them on the GPUs above; the numbers come from those runs.
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T00:55:36Z.
RDNA1 run (AMD RX 5700 XT, Navi 10, driver 32.0.21045.29003, Windows 11 26200; from the batch in #3410). It agrees with the description: this needs #2884 first.
7510c12merged alone onto main63bcca4:packed_fmac_inline_integer_and_float_encodings_reach_both_halvesfails on the hardware adapter, with the infinite high-half multiplier:src0 129, multiplier 0x7c006400, shift 16, got 0x3c000400, expected NaN. So the inline form gives0 * inf + 1 = 1.0where the register control gives NaN, the same case reported on the RTX 5080. The other 69 tests in the touched modules pass.64c62d5) merged first, then this PR: the 37valu_testspass on the RX 5700 XT and WARP, including all three packed FMAC tests and the single-rounding test.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T13:39:49Z.
I checked a third change at the same operand reader. #2229's DPP lane selection conflicts with this PR in
fmac_half. Combined branch e5cf4ce keeps #2884 before #3148, then resolves #2229 by taking the DPP-selected value for src0 and using the FP16 operand decoder otherwise. All three PR heads and Steven's test commit are retained.With #2884 and #3148 alone, the unchanged 2×2 DPP fixture reads each pixel's own packed source. In the combined tree, both row pairs read the horizontal neighbour's two halves. The inline finite and infinite multiplier cases, register controls, and all 38 VALU tests pass on app-local WARP 1.0.22 with DXIL validation. The 20 packed nearest-even rounding cases, strict shader Clippy and the asset check also passed.
#2884 remains the dependency for #3148. The branch is a tested resolution of the additional overlap with #2229.
AI-assisted with Codex. Synthetic shader tests only.
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.