Shaders: lower RDNA2 lighting multiply in DXIL #2936
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2938"
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 andrewpozdnakov7-jpg on 2026-11-26T00:55:50Z.
What changed
The DXIL lowerer now handles VOP3 opcode 0x150 in the default f32 mode used by VIctory. A positive, ordered third operand enables the multiplication. The right operand's negative maximum-finite, negative infinity or NaN encoding returns negative maximum-finite. The result then follows the measured priority of the legacy zero and left NaN rules.
The product's underflow check uses a scaled multiply so the decision at the smallest normal can be made after rounding to 24 significant bits. The lowering applies source abs/neg and output scale/clamp while preserving the relevant NaN payload and zero bits. The behavior comes from public physical RDNA2 reports. Operand rules and source modifiers, flushed inputs, product rounding, output modifiers.
Validation
63bcca43fails with Unsupported for v_mullit_f32. At this head it passes DXIL validation and D3D12 WARP SM 6.6 UAV readback for every case.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:08:14Z.
Code review and RTX 5090 + WARP + DXIL verification at head
20352211afebmerged cleanly ontomain(63bcca43c6a0;emit/lower.rs=520,643B, only+80B thanks to splittingemit/lower/lighting_mul.rs):crates/victory-shader/src/emit/lower/lighting_mul.rs):abs/negbitwise (And !SIGN/Xor SIGN, lines 35-40) avoids quieting sNaNs prematurely.invalid_rhs(rhs_nan || rhs >= NEGATIVE_MAX) returns-f32::MAX(0xff7f_ffff) ahead ofeither_zero(|lhs| < MIN_NORMAL || |rhs| < MIN_NORMAL -> +0.0), so0.0 * -Infand0.0 * qNaNproduce-f32::MAXwhile0.0 * +Inf/0.0 * NaN_lhsproduce+0.0.2^64(0x5f80_0000, lines 80-111) avoids host tininess/FTZ discrepancies around2^-126, andomod(scale_lighting_result) runs before unsigned-clampingclamp([0, 1.0], negatives/NaNs ->+0.0).dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:192 files ok;cargo clippy(default +--all-features): 0 warningsmullit lighting emit::tests emit::lower::tests: 51/51 passed on both RTX 5090 and WARP (includingv_mullit_f32_applies_lighting_rules).Clean submodule split and thorough special-value handling; LGTM.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T02:07:30Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP,dxil.dllvalidator active):cargo test -p victory-shader --lib emit::valu_tests::v_mullit: 1 passed, 0 failed (v_mullit_f32_applies_lighting_rulespasses on both RTX 5090 hardware and WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.The lowering in
emit/lower/lighting_mul.rscleanly handlesabs/negbit-level source modifiers, RDNA2 lighting sentinel/limit checks, post-rounding tininess near2^-126via2^64scaling,omod, andclamp.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:27:02Z.
Automated triage for the maintainers.
Merge candidate. Adds a DXIL lowering for
v_mullit_f32(VOP3 0x150) inemit/lower/lighting_mul.rs, dispatched fromLower::valu. The main special case (S1 is -MAX_FLOAT, -INF or NaN, or S2 is not positive or is NaN, gives -MAX_FLOAT) matches the RDNA2 ISA guide; the gate's interaction with denormal flushing, abs/neg handling that keeps sNaN payloads, omod before clamp and the scaled-product tininess handling read correctly, and the test uses the cited measurements as expected values. Please cite the RDNA2 ISA guide in the doc comment next to the links for the finer rules. Merging this and #2942 leaves a trivialmodline conflict inemit/lower.rs.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:16:33Z.
Review: APPROVED
Reviewed
20352211afeb6d5c9fa1557b6d82406a94651161.LGTM —
Lower::lighting_mulcleanly models RDNA2v_mullit_f32for the default f32 mode: bitwiseabs/negwithout quietingsrc0sNaNs, exact[MIN_NORMAL, INFINITY]limitvalidation,invalid_rhs(rhs_nan || rhs >= 0xff7f_ffff) precedence overeither_zeroandlhs_nan, the2^64post-rounding underflow scaling boundary at2^-126, andomodscaling before DX10clamp.Verified locally on RTX 5090 + WARP:
cargo xtask policy(192 files ok),cargo clippy -p victory-shader --all-targets/--all-features(-D warnings), andrustfmt --edition 2024 --checkonlighting_mul.rspass cleanly (zero newrustfmtdiffs inlower.rs/valu_tests.rs;lower.rsis 520,643 bytes).emit::valu_tests::passed (36 passed, 0 failed), andv_mullit_f32_applies_lighting_rulespasses under bothVICTORY_WARP=0andVICTORY_WARP=1.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.