Shaders: honor op_sel[3], clamp, and omod on v_interp_p2_f16 #1338
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1338"
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 AscilCH on 2026-11-24T17:33:05Z.
Bug
In
crates/victory-shader/src/emit/lower.rs,Lower::interp()loweredv_interp_p2_f16(VOP3 0x35a) viaself.low_half(), unconditionally writing the convertedf16to bits[15:0]and ignoring VOP3op_sel[3](high destination half),clamp, andomod.On RDNA2 (GFX10.3),
v_interp_p2_f16usesop_sel[3]to select whether the result is written tovdst[15:0]orvdst[31:16]while preserving the untouched half, and supportsomod(*2,*4,/2) andclamp([0.0, 1.0]) on the interpolated result before converting tof16.Reproduction (Before Fix)
With a synthetic RDNA2 VS+PS draw lowered to DXIL and executed on hardware (NVIDIA RTX 3050 6GB Laptop GPU, Windows 11) and WARP:
Fix
v.omodandv.clampinLower::interp()beforelegacyF32ToF16, and returnself.write_half(inst, r, None)soop_sel[3]places the 16-bit result into the chosen half while preserving the other half.emit::valu_tests::v_interp_p2_f16_respects_opsel_and_clampcovering low-half (op_sel[3]=0), high-half (op_sel[3]=1preserving low half),clamp, andomod(mul:2/div:2).Verification
Tested on Windows 11, NVIDIA RTX 3050 6GB Laptop GPU, WARP, and Windows SDK
dxil.dll:rustfmt --edition 2024 --checkonvalu_tests.rs: cleancargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p victory-shader --locked -- v_interp_p2_f16_respects_opsel_and_clamp --nocapture --test-threads=1: passed (hardware + WARP +dxil.dll)VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:121 passed, 0 failed, 1 ignoredImported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:54Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests.Honors op_sel[3], clamp and omod on v_interp_p2_f16; v_interp_p2_f16_respects_opsel_and_clamp covers the combinations.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:23:02Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:48:58Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
e2dc6baontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T02:00:06Z.
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
e2dc6baapplied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass. The newv_interp_p2_f16_respects_opsel_and_clamptest is GPU-specific (requires dxil.dll/WARP) and is skipped on Linux.cargo clippy -p victory-shader --all-targets -- -D warnings: 2 errors (vs 4 on main). The PR net-reduces clippy errors by fixing unused imports.Not tested: Windows MSVC build, the title itself. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T02:19:39Z.
I tested the draw fixture from
e2dc6baonmain@940d32fwith the lowering from #1696. A test-only rebase worked with one change to the synthetic pixel shader input signature.With the original fixture, pixel shader emission stopped before the draw at offset 128 with
a packed input half no element holds. The fixture setsfp16: true, pack2: true, but its ISG1 declaresTEXCOORDas float32. Main’s packed-half lookup uses the element’s parsed component type. In the test’sps_isg1, changing the second element’s component type from3to6(float16, little-endian u32 at byte 56) was sufficient. The shader instructions and expected pixels stayed the same.All 16 pixels matched on both the RTX 3050 Laptop and WARP (Windows/MSVC). Two independent controls on hardware show what the test catches: disabling only
clampchanged pixel 0’s alpha from 1 to 0.5, and disabling onlyomodchanged blue from 0.5 to 0.25. Restoring main passed on both backends again.To reproduce, append
v_interp_p2_f16_respects_opsel_and_clampfrom this PR to main’svalu_tests.rsand run the following before and after changing the fixture field:AI-assisted. Synthetic draw only.
upstream-sync referenced this pull request2026-11-25 14:07:23 +00:00
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.