Shaders: zero unavailable mixed-precision FMA halves #683
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/683"
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 Halfect on 2026-11-24T06:46:29Z.
Summary
v_fma_mixlo_f16/v_fma_mixhi_f16with the same zero fallback as the other partial-VGPR-write pathsv_interp_p1ll_f16: it writes a full 32-bitf32intermediate and does not preserve the destination's old high halfValidation
cargo test --locked -p victory-shader --lib -- --test-threads=1— 90 passed, 0 failed, 1 benchmark ignoredcargo clippy --locked -p victory-shader --lib -- -D warningscargo xtask policy— 151 files passedcargo build --locked --release -p victoryorigin/mainwithemit: the first half of an interpolationand passes with this change.origin/main8e79c80: 25,889 matched program labels; DXIL validation gained 8, lost 0. Vertex + pixel validated increased from 12,148 to 12,156; compute and mesh totals were unchanged. The only outcome transition was 8 programs changing fromemit: the first half of an interpolationto validated.Offline translation and DXIL validation only; no game or GPU execution was used.
AI-assisted (Kimi)
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:53:08Z.
Review: APPROVED
cargo test -p victory-shader --lockedon macOS 26 arm64, rustc 1.98.1: 57 passed, 0 failed (+1 vs main — the new f16 high-half interpolation test is ungated and ran green). Approving.Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:00:30Z.
Review: APPROVED
LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 70 unit tests in ictory-shader passed cleanly, including the new unit test n_f16_interpolation_preserves_its_old_high_half. Preserving the high 16 bits of destination VGPR across _interp_p1ll_f16 prevents unneeded shader invalidation.
Imported from Marvisak/VIctory. Originally posted by iurysf on 2026-11-24T08:27:46Z.
Measured offline against main
c2e7254withvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17, comparing outcomes program by program: failures 3,734 -> 3,726 (−8). Eight "the first half of an interpolation" refusals now emit and validate, and there are no regressions.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T09:30:34Z.
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. Merged locally with current mainc7a5f49first (main: VS/PS 12224 / 12148).VS/PS 12232 / 12156 (+8 validated): "the first half of an interpolation" 28 → 20. CS and MS unchanged.
Imported from Marvisak/VIctory. Originally posted by banbanzhige on 2026-11-24T09:44:01Z.
Quick ISA note on the premise here: on RDNA 2 / GFX10,
v_interp_p1ll_f16writes a full 32-bitf32intermediate (D.f32 = P10.f16 * S0.f32 + P0.f16, later consumed asS2.f32byv_interp_p2_f16), so it overwrites all 32 bits ofvdstand does not preserve the pre-interpolation high 16 bits.In those 8 pixel shaders,
v_fma_mixlo_f16is simply reusing a dead temporary VGPR afterv_interp_p2_f16has consumedv_interp_p1ll_f16's result (subsequent instructions only read the low 16 bits). Becausefirst_halveswalks pastv_interp_p1ll_f16to the value held before it, it would actually resurrect stale pre-interpolation bits ifvdsthad held a live value earlier, and it doesn't coverv_fma_mixhi_f16or reuse of other intentionally unlowered VGPRs (such as entry barycentrics).Notice that the other partial-VGPR-write paths in
lower.rs(write_placed,place_bits,write_half, andlow_half) all handle an unlowered preserved half uniformly with:Using that same fallback in
v_fma_mixlo_f16/v_fma_mixhi_f16avoids mismodelingv_interp_p1ll_f16as high-half-preserving, stays consistent withwrite_half/low_half, handles bothmixloandmixhi, and gives the same +8 validated pixel shaders with 0 regressions (tested offline against the local shader pack).AI-assisted review.
[PR #683] Shaders: preserve high halves across f16 interpolationto [PR #683] Shaders: zero unavailable mixed-precision FMA halvesImported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T10:16:09Z.
You're right—thanks for the ISA correction. I had incorrectly modeled
v_interp_p1ll_f16as preserving the old high half;D.f32 = P10.f16 * S0.f32 + P0.f16overwrites the full destination, so walking back to the pre-interpolation value could resurrect stale bits.Updated head
0b48633removesfirst_halves/preserved_highentirely. Bothv_fma_mixlo_f16andv_fma_mixhi_f16now use the sameSome(Ok(o)) => o, _ => i32(0)fallback as the other partial-write paths. The regression covers both result halves with a deliberately stale pre-interpolation high half, and validates the resulting DXIL. It fails on currentorigin/mainwithemit: the first half of an interpolation.I also reran the full offline A/B against
origin/main8e79c80: 8 validation gains, 0 losses across 25,889 matched labels; VS/PS validated 12,148 → 12,156, with compute and mesh unchanged. No game or GPU execution was used.Imported from Marvisak/VIctory. Originally posted by ErRusso on 2026-11-24T11:19:18Z.
Audit: ✅ Looks good — verified & tested
Reviewed this PR as part of an audit of mergeable PRs.
crates/victory-shader/src/emit/lower.rs+mod.rs(+97/-3). Tracksv_interp_p1ll_f16instructions in afirst_halvesmap and walks the chain in the newpreserved_high()so that a low-half f16 interpolation followed by a low-half mixed-precision FMA keeps the destination's old high half instead of treating it as unknown.main.emit::tests::mixed_precision_fmas_accept_an_unavailable_interpolation_half→ passed;cargo test -p victory-shader -- emit::tests::→ 6/6 passed. The emission test exercises the full native→IR→resource→IO→structure→emit pipeline and validates the DXIL with the DXC validator when available.preserved_high()is reused by both the mixed-precision FMA path andlow_half(), which avoids two divergent implementations. Clean.No issues found.
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T11:29:36Z.
Thanks for the audit, but this describes the superseded implementation, not current head
0b48633.first_halvesandpreserved_high()have been removed. The current PR no longer treatsv_interp_p1ll_f16as preserving the old high half: bothv_fma_mixlo_f16andv_fma_mixhi_f16use the sameSome(Ok(o)) => o, _ => i32(0)fallback as the other partial-write paths. The regression covers both result halves with a deliberately stale pre-interpolation high half.Please retest
0b48633; the earlier ISA correction and current implementation details are in the comment above.Imported from Marvisak/VIctory. Originally posted by CaravelaLabs on 2026-11-24T12:06:12Z.
Thanks @Halfect — retested current head
0b48633merged onto mainffe310e, as you asked.Git merges with no text conflicts. The merged code is the zero fallback on both
v_fma_mixlo_f16andv_fma_mixhi_f16(Some(Ok(o)) => o, _ => i32(0)).first_halves/preserved_highare gone.As written,
cargo test -p victory-shader --libstill does not compile: the new test callsresource::trackwith three arguments. Already listed for this PR in #801, and @muhammed-aksoy already hit it on this head, so not a new finding.With only that call updated to pass
None, the new test passes, and the shader library tests are 97 passed / 0 failed / 1 ignored (Linux, rustc 1.98.1). The same test against main's lowering fails withthe first half of an interpolation, so it does catch this change. Both mixlo and mixhi are in the passing run. The DXIL validator did not run here (that check is Windows-only), and the test checks that emit succeeds, not the bit pattern of the zeroed half.AI-assisted; tests run on this machine.
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T12:22:47Z.
Thanks @CaravelaLabs — fixed in
81fb96e. I rebased onto current mainffe310eand updated the new regression call toresource::track(&p, &native.layout, native.stage, None).Validation on Windows:
mixed_precision_fmas_accept_an_unavailable_interpolation_half: passed, including its Windows DXIL validation.cargo check --locked -p victory-shader --tests: passed.diff_tests,valu_tests,waterfall_tests, andstub_pipeline_is_created: 98 passed, 0 failed, 1 ignored.-D warningsandcargo xtask policy: passed (154 files ok).No GPU execution was used for this validation. The regression still checks successful emission rather than the exact zeroed-half bit pattern, as you noted.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:00:21Z.
Review: APPROVED
NVIDIA cross-vendor verification — tested merged cleanly onto
main(ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:cargo test -p victory-shader: 121 passed, 0 failed, 1 ignored (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP)cargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: okClean cross-vendor confirmation on NVIDIA Blackwell + WARP. Approving.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by CaravelaLabs on 2026-11-24T13:05:16Z.
Thanks @Halfect — retested
81fb96e, already on mainffe310e.cargo test -p victory-shader --libcompiles now. 97 passed, 0 failed, 1 ignored (Linux, rustc 1.98.1).mixed_precision_fmas_accept_an_unavailable_interpolation_halfpassed in that run. The DXIL validator still did not run here.AI-assisted; tests run on this machine.
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T13:23:55Z.
Thanks @CaravelaLabs for confirming
81fb96ecompiles and passes the library suite on your side. Nothing further from me on this head — ready for review.Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T14:04:25Z.
Re-tested head
81fb96emerged ontomainffe310e(clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. Pass, with no local change: theresource::trackcall from #801 now builds.mixed_precision_fmas_accept_an_unavailable_interpolation_halfpasses. It doesn't use the GPU, but its DXIL check did run: the Windows SDK10.0.26100.0\x64\dxil.dllis installed here, soValidator::loadfound it.cargo test --workspace --locked, the full workspace including the VALU and waterfall GPU groups (which ran on the RTX 5060): 343 passed, 0 failed, 6 ignored, against 342 / 6 onmain.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T14:22:11Z.
Thanks @DeerSilver for re-testing
81fb96ewith the full workspace suite on the RTX 5060 — 343 passed with the VALU/waterfall groups included is a good cross-check of the CPU-only runs. Nothing further from my side on this head; ready for review.Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T16:20:48Z.
Measured on Linux (RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master), head
81fb96emerged onto our tree:cargo test -p victory-shader --lib114 pass, only the known failure.One thing for your branch: after
emit()gained atarget: Targetargument on main, the new test callsemit(..., &res)with six arguments and does not compile against current main; I passedTarget::ANY.Not tested: in-game on this branch; native Windows.
Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:29:48Z.
Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
81fb96e:cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 103 passed, 0 failed.cargo clippy -p victory-shader -- -D warnings: 0 warnings.1.0.2.1,--console series-s, 19-min world run): no regressions. Ready to merge!Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T16:50:16Z.
Thanks @pablogonz12 for the measurement and the heads-up.
On the compile note: upstream
mainis stillffe310e, and thereemit()keeps its six-argument form (c, native, p, st, io, &res) — I just re-checkedcrates/victory-shader/src/emit/mod.rsatrefs/heads/main. Thetarget: Targetparameter you hit must come from the tree you merged onto, not from upstreammainyet. Against upstream,81fb96ecompiles as pushed: @CaravelaLabs built the library suite on Linux (97 passed) and @DeerSilver the full workspace on Windows (343 passed), both merged ontoffe310ewith no local change.If the target-aware
emit()lands first, I'll rebase and pass the appropriate target through the new test (yourTarget::ANYadaptation is the behavior-preserving choice for it).Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:20:02Z.
@Halfect You're right, thanks for checking. The
target: Targetargument comes from another PR in the tree I merged onto, not from upstream main; againstffe310eyour81fb96ecompiles as pushed. The +8 vertex/pixel count I posted still applies.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:27:20Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Zero-fills the kept half of v_fma_mixlo/hi_f16 when the old value has no host form. Main handles the same programs without inventing a value: the high half stays unknown and only low-half readers are accepted (
13091f6e, low16).If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed