Shaders: honor EXEC guards in Lower::interp #3147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3149"
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 Arkenoz on 2026-11-26T10:23:50Z.
Summary
Fixes missing
EXECguard handling when writing interpolation results inLower::interp(crates/victory-shader/src/emit/lower.rs):vdstwrites:ir.rsandstructure.rsalready classifyFields::Vintrpinstructions as vector writes governed byEXECand computeguards[b][i], butLower::interppreviously passedNonetowriteandwrite_half. While the interpolation evaluation itself runs across lanes, the write tovdstmust still preserve inactive lanes under narrowedEXEC(v_cmpx_*,s_and_saveexec_*).Lower::interpnow queriesself.guard(site.0, site.1)?and applies it tov_interp_mov_f32,v_interp_p2_f32, andv_interp_p2_f16.p1vdston shared-destinationp1 + p2pairs: Whenv_interp_p1_*andv_interp_p2_*target the same VGPR,p1is not emitted to DXIL and recordsVal::Missing(_), which would otherwise collapse inactive lanes to0onp2. AddedLower::interp_oldto trace back top1.read(Reg::V(reg))whenbools.meetprovesp1never executed on lanes outsidep2's guard (andreach[b] => reach[b1]).v_interp_p2_f16): Factoredwrite_placed_with_oldandwrite_half_with_oldso active lanes keep existing half-preservation/modifier behavior while inactive lanes preserve the full previous (or pre-p1)vdst.Leaves
omod/clamp/op_sel[3]andSV_Barycentricspaths untouched to avoid conflicts with open PRs.Testing
emit::tests::guarded_interpolation_preserves_inactive_lanesincrates/victory-shader/src/emit/mod.rs, running 5 synthetic pixel shaders viaHost::draw(verified failing before the fix and passing after on both NVIDIA RTX 3060 and WARP, with DXIL validation):v_interp_mov_f32v_interp_p1_f32+v_interp_p2_f32(sharedvdst)v_interp_p1ll_f16+v_interp_p2_f16(low half, separatevdst)v_interp_p1ll_f16+v_interp_p2_f16(sharedvdst)v_interp_p1ll_f16+v_interp_p2_f16(op_sel[3] = 1high half, separatevdst)rustfmt --edition 2024 --check— 0 diffs on all touched/added linescargo clippy --workspace --all-targets -- -D warnings— passedcargo check --workspace --all-targets— passedcargo xtask policy— passed (asset policy: 191 files ok)cargo test -p victory-shader --locked --lib emit::tests::— passed (18 passed; 0 failed)Coordination & AI disclosure
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T10:27:30Z.
Review: APPROVED
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-shader --lib guarded_interpolation_preserves_inactive_lanes -- --test-threads=1: passed.cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1: 33/33 passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly honors EXEC guards in
Lower::interpso inactive lanes preserve their prior VGPR values.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:02:25Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-shader --lib --features host guarded_interpolation: 1 passed (the newguarded_interpolation_preserves_inactive_lanes).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.Synthetic only. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:26:47Z.
Review: CHANGES_REQUESTED
Thanks for adding
EXECguard preservation toLower::interpalong with the draw-test coverage. Two correctness issues came up in the shared-destinationp1+p2handling:v_interp_p2_f16zeroes the untouched half in active lanes (crates/victory-shader/src/emit/lower.rs:6904-6920,crates/victory-shader/src/emit/mod.rs:1985):In
write_half_with_old,guard_oldis only passed to the outer!guardselect at line 6919 (old_for_guard). For active lanes, line 6904 still readsinst.read(Reg::V(reg))to preserve the untouched half — which for a shared-destinationv_interp_p1ll_f16+v_interp_p2_f16pair isp1'sVal::Missingoutput, causing line 6906 to pack0into the untouched half. You can see this in the newv_interp_p2_f16_sharedtest case atmod.rs:1985, which skips checking the high half in active lanes ((0.25, None)) even thoughv_interp_p2_f16_seppreserves2.0. Passing the recovered pre-p1value through for the active-lane half preservation (whenp1did not define a representable half) should fix both halves.p2guard (A && Bvsp1'sA) zeroes!Alanes (crates/victory-shader/src/emit/lower.rs:8209-8246, 2762-2774):In
interp_old, if lanes exist that runp1(g1) withoutp2(g2),interp_oldfalls back toSome(old)(whereoldisp1'sVal::MissingSSA value), andwrite_placed_with_oldreplaces all!g2lanes with0— clobbering!Alanes that skipped bothp1andp2and should retain the pre-p1dstvalue.Once those two cases are handled (and
v_interp_p2_f16_sharedassertsSome(2.0)on the untouched high half in active lanes), this should be good to go.Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-27T14:10:34Z.
Thanks for the review, @fuzeofficial! Fixed both shared-destination
p1 + p2cases:v_interp_p2_f16):interp_oldnow recoverspre_p1ashalf_oldwheneverinst.read(Reg::V(reg))isp1'sVal::Missingoutput, andwrite_half_with_olduses it to preserve the untouched half in active lanes. Updatedv_interp_p2_f16_sharedto assertSome(2.0)on the untouched high half.p2guard (A && Bvsp1'sA):interp_oldnow returns a precomputed DXIL fallback for!g2lanes (select(g1, 0, pre_p1)when bothg1 && !g2and!g1 && !g2are reachable), preserving the pre-p1dstvalue in!Alanes. Addedv_interp_p2_f32_stricter_guardandv_interp_p2_f16_stricter_guarddraw tests coveringA && B,A && !B, and!Alanes.Verified:
cargo test -p victory-shader --lib --features host guarded_interpolation -- --test-threads=1— passedcargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1— 33 passedcargo clippy -p victory-shader --all-targets -- -D warnings— cleancargo xtask policy— 191 files okView 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.