Shaders: lower binary64 division fixup in DXIL #2953
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2953
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2953"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 01:26 UTC · original
andrewpozdnakov7-jpg:codex2/div-fixup-f64→main· +316 −1 · 3 files · 1 commits · openThe DXIL lowerer now handles VOP3 opcode 0x160. It repairs the supplied binary64 quotient using the original denominator and numerator. Both result dwords are selected with 32-bit integer operations, preserving subnormals and NaN payloads in the modeled float mode. A known FP_ROUND16_64 setting controls overflow and underflow. The lowering also handles abs, neg, clamp, and the measured rule that f64 ignores omod.
The implementation uses the convention already modeled by VIctory: IEEE mode off and f64 denormals kept. RDNA2 ISA, quotient repair measurements, modifier measurements, denormal measurements, directed rounding measurements.
Validation
63bcca43refuses opcode 0x160. The patch passes 57 exact readback cases across 15 forms on Windows WARP SM 6.6 with DXIL validation. These cover both dwords, the -1075/-1076 exponent boundary, all four round modes, signed zeros, NaN priority and payloads, clamp and literal/inline inputs.AI-assisted.
@fuzeofficlal on GitHub · 2026-11-26 01:35 UTC · original
Code review and RTX 5090 + WARP + DXIL verification at head
f0f5fb5bde44onmain(63bcca43c6a0;emit/lower.rs=520,966B,3,322B under the 512 KiB cap thanks toemit/lower/div_fixup.rs):emit/lower/div_fixup.rs,lower.rs:6771-6780):[lo, hi]integer bit-ops so it never requires or sets the DXILDOUBLES(SFI0) flag.div_fixup.rs:81-94) matches RDNA2: signed quotient base -> directed-rounding overflow saturation (mode161/2/3->±DBL_MAX, else±Inf) -> underflow (exp_delta < -1075 << 20, directed rounding to±min_denormor±0.0) ->±0.0(den.inf | num.zero) ->±Inf(den.zero | num.inf, bypassesmode16clamp) -> canonical qNaN0xfff8_0000_0000_0000(0/0orInf/Inf) ->den.nan->num.nanforwarding modified NaN payloads.absbeforenegonhi(div_fixup_source),operand64_dwordschecked register-pair bounds,v.omodignored for f64, andv.clampmapping negatives/NaNs to+0.0and(1.0, +Inf]to1.0all check out cleanly.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:192 files ok;cargo clippy -p victory-shader --all-targets -- -D warnings(default +--all-features): 0 warningsbinary64_division_fixup emit::tests emit::lower::tests: 51/51 passed on both RTX 5090 and WARP.LGTM.
@Marvisak on GitHub · 2026-11-26 05:35 UTC · original
Automated triage for the maintainers.
Merge candidate. The PR lowers
v_div_fixup_f64(VOP3 0x160), whichmaindecodes but refuses, in a newemit/lower/div_fixup.rs(Lower::div_fixup_f64) using only 32-bit integer operations on the register pair. I checked the special-case order against the public RDNA2 ISA definition: numerator NaN, then denominator NaN, then 0/0 and inf/inf to the default NaN, then the signed infinity and signed zero cases, then the exponent-difference underflow at -1075, then overflow, else the quotient's magnitude with the XOR sign. The parts the ISA text leaves open (sNaN payloads kept with IEEE mode off, directed-rounding saturation fromFP_ROUND16_64, f64 ignoring omod) are backed by linked hardware measurements from the same AnyPS5 oraclemainalready cites insemantics_tests.rs. Literal (high dword) and inline (f64 1/2pi) operands are handled, andbinary64_division_fixup_preserves_pair_bits_and_limitscovers both dwords, the -1075/-1076 boundary, all four round modes, modifiers and clamp.CI: passing. Recommending a look, not approving.
Generated by Claude Code
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.