Skip to content

Shaders: v_fma_mixlo/mixhi over an f16 first interpolation half keeps zero (8 pixel programs) - #77

Closed
m335671 wants to merge 1 commit into
fxceless:mainfrom
m335671:fix/mixlo-interp-first-half
Closed

m335671 wants to merge 1 commit into
fxceless:mainfrom
m335671:fix/mixlo-interp-first-half

Conversation

@m335671

@m335671 m335671 commented Nov 24, 2026

Copy link
Copy Markdown

Summary

8 of the title's deferred material pixel programs failed with emit: the first half of an interpolation. The interpolation pairing itself was fine. What failed was a 16-bit write further on:

v_interp_p1ll_f16 v8, v0, attr.x        ; first half: no value of its own (the second half recomputes it)
v_interp_p2_f16   v27, v1, attr.x, v8   ; second half, into another VGPR
v_fma_mixlo_f16   v8, v19, v10, 0       ; low half of v8 written, high half kept
v_cvt_f32_f16     v6, v8                ; only the low half is read

v_fma_mixlo_f16 keeps the high half of its destination, so the lowering read the old v8 with i32_of(..)?. That old value is the first half's Val::Missing, so it propagated to the colour export and refused the whole program. Nothing reads that high half.

write_half and low_half already treat an old value that has none as zero. This change makes the v_fma_mix* arm do the same.

Changes

  • crates/victory-shader/src/emit/lower.rs: in the v_fma_mix_f32 | v_fma_mixlo_f16 | v_fma_mixhi_f16 arm, an old destination without a value keeps 0 instead of failing the program, as write_half does.
  • crates/victory-shader/src/emit/mod.rs: test mixlo_over_an_f16_first_interpolation_half. It is a pixel program with v_interp_p1ll_f16 / v_interp_p2_f16, then v_fma_mixlo_f16 into the first half's VGPR. It fails without the change (Unsupported { offset: 28, what: "the first half of an interpolation" }) and passes with it. pixel gets a pixel_with(.., fp16) variant for the 16-bit TEXCOORD0 the test needs.

Verification

  • NVIDIA GeForce RTX 4070 12 GB (driver 32.0.16.2124), AMD Ryzen 9 7900, 32 GB, Windows 11 Pro 26300, Rust 1.97.1. Branch on 4e17478.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: 0 warnings.
  • cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored (the new test included).
  • cargo xtask policy: 169 files ok.
  • Offline corpus A/B, victory translate --list --validate over the title's shader pack, base 90228a7 (4e17478 changes no code) against this change. Aggregate counts and hashes only, no game data:
    • emit: the first half of an interpolation: 8 → 0
    • Vertex and pixel programs emitted: 14,156 → 14,164 of 14,247; validated: 14,045 → 14,053
    • Compute and mesh: unchanged (2,668 / 8,762 emitted)
    • Per-program diff: exactly these 8 change, all from that failure to validated: 38bf0814e721a1b3, 78f3f2fc53a69531, 8445dcb2b63aa197, 007bb29b393d08c5, 15547db9d31b056b, 288c43f50bc7abee, 5ddcaa08d4a51215, 464ea474374b8ecd.
  • In game (Series X, prologue checkpoint, VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024, on 90228a7 + this change):

Not tested

  • AMD and other NVIDIA cards.
  • Scenes past the prologue's first minutes.
  • Whether a title ever reads the kept high half after such a write. Zero is what write_half already assumes.

AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the checks and the title on my machine, and wrote this description.

🤖 Generated with Claude Code

… zero

A v_fma_mixlo_f16 into the VGPR of an f16 interpolation's first half
(v_interp_p1ll_f16, whose second half writes another VGPR) read the old
value with i32_of(..)?. That value is the first half's Val::Missing, so
the failure reached the colour export and refused the whole program,
reported as "the first half of an interpolation". Nothing reads the kept
high half. write_half and low_half already keep zero for an old value
without one; the v_fma_mix* arm now does the same.

8 of the title's deferred material pixel programs translate and validate
now (14,156 -> 14,164 vertex and pixel programs emitted); no other
program changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@T0ns1

T0ns1 commented Nov 24, 2026

Copy link
Copy Markdown

In-game data point for this change, from an independent fix of the same failure (same diagnosis: v_fma_mixlo_f16 keeping the high half of a VGPR that holds an f16 first half).

Setup: Windows 11 Pro 26300, RTX 5070 Ti 16 GB (driver 32.0.16.2140, 32-lane waves), Ryzen 7 9800X3D, 32 GB. Release build of main 4e17478 plus the equivalent change, Series X profile.

  • Offline, over the whole shader pack with VICTORY_HOST_WAVE=32: vertex and pixel programs emitted 14156 → 14164 of 14247; the 8 "first half of an interpolation" failures are gone, and every other failure count is unchanged. PS_DeferredTextured (#38bf0814e721a1b3) now translates, validates and makes a host pipeline.
  • Before, a run of the first gameplay scene logged shader does not translate; its pipelines' draws are dropped stage="pixel" hash=38bf0814e721a1b3 (and 3 PS_PuddleDetect variants).
  • In game, with the change: the first gameplay room has its walls and ceiling. Before, they were missing: the ceiling lights hung against the sky, and the window frames stood free with the yard behind them. The doorway shot before gameplay starts is also clean where it had blocky, stair-stepped patches and ghost lettering on the character's shirt (stale G-buffer where those draws were dropped). Draws per frame in the room went from 6421 to 6831.

cargo test --release -p victory-shader: 210 passed, 0 failed, 2 ignored.

AI use: Claude Code (Claude Opus 5.5) traced the failure, made the change, ran the tests and the game.

@dkdknight

Copy link
Copy Markdown

Tested on an RTX 5080 (merged with #71, #81 and #38 on 4e17478): 38bf0814e721a1b3 and 78f3f2fc53a69531 translate, and the run had no device removal.

  • Both were shader does not translate (the first half of an interpolation) on 4e17478 and shader translated with this PR, in the same scene (Series X profile, same save, ~2 min standing in the world).
  • Untranslated programs in the run: 11 on 4e17478, 5 with the four PRs (all compute). The frame numbers for the merged build are on GPU: parallelize CARD_COMPARE (64 threads per 64 KiB piece) #71.
  • Not checked: whether the surfaces these programs draw look right, frame by frame.

Setup: NVIDIA GeForce RTX 5080 16 GB, driver 621.14, i9-13900KF, Windows 11 26200, release build.

AI use: Claude Code, Claude Opus 5.5 built the merged branch, ran it on the machine above (the person at the machine played) and read the logs.

@adriaespii

Copy link
Copy Markdown

Independent test run on commit a6388aa (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 497 passed, 0 failed, 7 ignored (victory-shader: 211 passed, 0 failed, 2 ignored; victory-gpu: 110 passed, 0 failed, 1 ignored)
  • Not tested: retail shader pack / live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

@rocobalt1

Copy link
Copy Markdown

Offline coverage of this PR on the retail shader pack, measured alone on its base 4e17478.

Method: worktree at 4e17478, cargo build --release -p victory, then victory.exe translate <shaders.rpf> --validate --list --jobs 20 with the same Windows SDK validator, compared program by program by program hash against the same command on 4e17478 alone.

programs validated
4e17478 26 531 25 370
+ this PR 26 531 25 378

+8 gained, 0 lost.

The eight:

PS_DeferredTextured_9e3a1555     PS_DeferredTextured_c5fd36bb
PS_MirrorReflectionDeferredTextured_862306ef / f0a15084 / d3b47178
PS_MirrorReflectionDeferredDecalTextured_38f9dc3e / e3251b40

And these are precisely the programs the title is missing on my machine. On --console series-s the run refuses three pixel pipelines with converter shader.dxil v1: GFX10 code at 0x1464: the first half of an interpolation is not supported, and their hashes map to PS_DeferredTextured_c5fd36bb (twice) and PS_DeferredTextured_9e3a1555 - two of the eight above. Their draws are dropped today; with this PR they should be kept.

For what it is worth, #52 on the same base gains the same 8 but loses 160 ped/fire pixel programs, so this narrower change looks like the one to take.

No game data; counts and program names only.

@arminkhaleghirod

Copy link
Copy Markdown

Merged onto main 90228a7 and ran victory translate --validate over the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason:

  • the first half of an interpolation: 8 → 0
  • DXIL emitted: 14,168 → 14,176
  • No new failure reason. The 8 newly emitted programs join the existing Pipeline State Validation does not match group.

@rocobalt1

Copy link
Copy Markdown

In-title confirmation of what the coverage comment promised: this PR removes the refusal on my machine as well, not only offline.

Same machine, same build as the coverage comment (4e17478 + #32 + #86 + this PR), --console series-s, VICTORY_FFX_DIR set (AMD FSR 3.1.6 through #86), VICTORY_SHADER_LOOP_LIMIT=256, VICTORY_NO_WATCHDOG=1, VICTORY_D3D12_DRED=1, fresh VICTORY_DATA_DIR, RTX 4060 Ti 8 GB / driver 32.0.16.1656. TdrDelay=60 here, so times are upper bounds.

without this PR with this PR
0x1464: the first half of an interpolation refusals 3 0
shader refusals in the whole run 15 12
frame, settled 380 - 432 ms 380 - 456 ms
draws per frame 1 733 - 5 760 4 684 - 5 158
device removal no no

The three PS_DeferredTextured draws that were dropped now run. I cannot tell you yet whether the wall that uses them looks right, because the frame is still heavily overexposed on this profile; what I can say is that nothing else regressed in the run (no new refusal, no device loss, frame time unchanged).

No game data; counts only.

@m335671

m335671 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Current main already fixes the 8 programs this PR is about, so this change is no longer needed there.

Checked

  • main at 8dd30ab, diagnostics build, VICTORY_HOST_MAX_WAVE=32 victory translate --list --validate <shaders.rpf> over the title's whole shader pack (RTX 4070, Windows 11).
  • All 8 hashes are validated: 38bf0814e721a1b3, 78f3f2fc53a69531, 8445dcb2b63aa197, 007bb29b393d08c5, 15547db9d31b056b, 288c43f50bc7abee, 5ddcaa08d4a51215, 464ea474374b8ecd.
  • No program fails with the first half of an interpolation any more.
  • The fix came in with 3bff182 ("a first half of a paired interpolation read as data"), which handles it on the first half's side, like Shaders: sizes of unused descriptors, paired f16 interpolation halves, 16-bit wave sums with lanes gone (+46 programs) #203.
  • In the title on 8dd30ab alone: the first gameplay room and the window are drawn, and the main character's face is complete.

I'm closing this as superseded. Thanks to everyone who tested it.

AI use: Claude Code (Claude Opus 5.5) ran the check on my machine and wrote this comment.

@m335671 m335671 closed this Nov 25, 2026
deynesdev referenced this pull request in deynesdev/Protonida Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deynesdev referenced this pull request in deynesdev/Protonida Nov 26, 2026
…ought (collapsible if, enumerate index used only in diagnostics, a cast to the same type)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

6 participants