Repository navigation
Shaders: lower binary64 frexp exponent and significand - #2350
andrewpozdnakov7-jpg wants to merge 2 commits into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:
- Clean lowering of binary64
v_frexp_exp_i32_f64andv_frexp_mant_f64including binary64 immediates and sign modifiers. cargo test -p victory-shader frexp: 3/3 passed on RTX 5090, 3/3 passed on WARP (v_frexp_exp_i32_f64_extracts_the_exponent,v_frexp_mant_f64_extracts_the_significand,v_frexp_f64_uses_binary64_immediates_and_sign_modifiers).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: merged into main 940d32f, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — binary64 frexp exponent and significand lowered.
|
Automated triage for the maintainers. Verdict: merge candidate (unchanged). The new head merges Note for maintainers: #2713 (same author) adds CI: passing ( Generated by Claude Code |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed d30794e6e97ce92acdb2de18cb0958f1f6e63c9c (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP + dxil.dll).
The 32-bit two-dword normalization is bit-exact across normal values, subnormals (including the shift = 31 / 32 / 33 / 52 cross-word boundary), signed zeros, infinities, and NaNs without requiring native f64 or i64 DXIL capabilities (verified across 50,318 bit patterns), and moving frexp64 into emit/lower/frexp.rs keeps emit/lower.rs growth to just +96 B (520,659 B, 3,629 B below the 512 KiB cap).
Optional follow-up notes:
- If guest
MODEtracking forIEEE/ f64 input-denorm-flush is added later, note that RDNA2 quiets sNaN inv_frexp_mant_f64underIEEE=1and flushes subnormals to signed zero under input denorm flush. - Adding a test checking inline
248(1/(2pi)low dword0x6dc9_c882, exponent-2) and asserting zeroSFI0doubles/int64flags on a dynamic-register shader (not just immediate inputs) would tighten coverage further.
Verification
cargo run -p xtask -- policy(191 files ok),cargo clippy(default &--all-features) clean, changed linesrustfmt-clean.emit::valu_tests(38/38 passed) andemit::census_tests(1/1 passed) on both RTX 5090 and WARP withdxil.dllactive (PR head and merged onto63bcca43).
Shaders using
v_frexp_exp_i32_f64orv_frexp_mant_f64fail lowering on currentmain. The emitter now extracts the two binary64 words, computes the signed exponent, and normalizes the significand with 32-bit integer operations. It preserves signed zeros and the original infinity and NaN bits in the significand. Subnormal normalization carries bits across the two words. AMD RDNA 2 ISA, VOP1The three synthetic tests were all rejected as
Unsupportedon940d32f. On the patch, Microsoft DXIL validation and WARP confirm 44 dispatch results, including subnormal shifts of 31, 32 and 33, both zero signs, NaN payloads, register pairs, an inline integer and a negated literal. The tests verify that the DXIL does not require doubles or 64-bit integers. All 31 VALU tests pass. Strict shader Clippy and the staged asset policy pass.Output
clampandomodare refused by name. The tests cover the translated output on WARP. The corresponding RDNA hardware behavior has not been measured here.Coordination claim
Please retain the Git author when reapplying this change. If you fold it into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.AI-assisted. Synthetic tests only.