Skip to content

Shaders: accept inline constants in V_PK_FMAC_F16 - #3148

Open
andrewpozdnakov7-jpg wants to merge 2 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/pk-fmac-f16-constants
Open

andrewpozdnakov7-jpg wants to merge 2 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/pk-fmac-f16-constants

Conversation

@andrewpozdnakov7-jpg

@andrewpozdnakov7-jpg andrewpozdnakov7-jpg commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 7510c12 for representative inline encodings, finite and infinite multipliers, and a register control. The local combination with #2884 at 64c62d5 passed 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 <242719754+steven-seagull27@users.noreply.github.com>.

V_PK_FMAC_F16 fails 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 Unsupported on 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 <andrewpozdnakov7-jpg@users.noreply.github.com>.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@steven-seagull27

Copy link
Copy Markdown

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.

Adapter Inline on #3148 Register on #3148 Inline with #2884’s packed-FMA change added
RTX 5080, driver 621.40 74 0 0
Windows WARP 10.0.26100.10068 0 0 0
App-local WARP 1.0.22 74 0 0

All 74 differences were in the high half: the 65 nonnegative integer encodings and nine floating-point encodings contributed +0 there. With an infinite multiplier and a +1 accumulator, those cases returned +1 where 0 × ∞ + 1 should produce a NaN. For example, with inline integer 1 (src0=129), multiplier 0x7c006400, and accumulator 0x3c000000, the RTX 5080 read 0x3c000400 inline and 0x7fff0400 from 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 64c62d5 on 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:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr3148-packed-inline-coverage
git cherry-pick 7510c1286abe5da4041b60be1c64746e69e2beb1
cargo test --locked -p victory-shader --lib packed_fmac_ -- --test-threads=1 --nocapture

These are synthetic shader readbacks. AI-assisted with Codex.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

Thanks, @steven-seagull27. I added your original test commit 7510c12 with its Git authorship intact. On app-local WARP 1.0.22 with DXIL validation, the local combination with #2884 at 64c62d5 passed 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 <242719754+steven-seagull27@users.noreply.github.com>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants