Repository navigation
Shaders: lower binary64 scaling with floating-point modes - #2743
andrewpozdnakov7-jpg wants to merge 3 commits into
Conversation
|
Reviewed and verified Code review
Verification (Windows 11, RTX 5090 + WARP +
|
|
Independent WARP/CPU verification for head 99161fd against origin/main 13f91ca. State check at start and again before posting: open, non-draft, mergeable, head unchanged; no prior oni-swr comment. Environment: Windows 11 x64, Rust 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1, Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11). Commands/results:
Review: no correctness blocker found in the inspected paths. The MODE tracker now follows bits 3:2 and 7:6 independently, joins disagreeing paths to unknown, and Not tested: physical GPU, retail title/game behavior, release build (debug profile only). AI disclosure: Claude Code (Claude Sonnet 5.5). |
|
The FpMode16 refactor is the right shape: INITIAL matches the shader-entry convention (nearest-even, preserve subnormals both ways), the s_setreg field overlap check (offset<=start && end>=start+2) handles partial-field writes correctly, and tracking round/denorm independently unblocks ldexp's denorm handling. ldexp_f64 normalizes subnormal inputs by scaling before exponent adjust - the standard approach. Heads up on merge order: #2782's s_getreg reads self.mode16 as Option; whichever lands second needs mode16.round. |
|
Automated triage for the maintainers. This adds a lowering for Generated by Claude Code |
|
First Radeon run of
So the lowered binary64 scaling, denormal and round modes included, matches on RDNA3 hardware as well as on the RTX 5090 and WARP. |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::valu_tests::ldexp: 3 passed, 0 failed (ldexp_f64_scales_normal_and_subnormal_values,ldexp_f64_uses_the_denormal_mode_for_both_operands_and_results, andldexp_f64_uses_the_round_mode_for_underflow_and_overflowpass on both RTX 5090 hardware and WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good — verified locally at 177f0e52:
cargo xtask policy(192 files ok) andcargo clippy --all-targets --all-features -- -D warningspass with 0 warnings.emit::valu_tests::ldexp_f64passes 3/3 on both RTX 5090 (VICTORY_WARP=0) and WARP (VICTORY_WARP=1), verifyingSFI0 & 0x8001 == 0, all 4 rounding modes, and all 4 denormal modes.- Core binary64 exponent scaling, subnormal normalization, overflow/underflow saturation, and rounding arithmetic matched an exact integer reference across 3.19M test cases.
(Non-blocking notes):
- Pre-existing from
round16_after, the whole-wave section loop (lower.rsaroundfor j in i + 1..end { self.section_inst(b, j, i); }) jumpsi = end; continue;without advancingself.mode16 = self.mode16.after(&p.blocks[b].insts[j]). Advancingself.mode16inside that loop keeps intra-blockmode16tracking consistent withfp_modes16if as_round_mode/s_denorm_modeappears inside a section. rustfmt --edition 2024 --checkflags minor line-wrapping diffs incrates/victory-shader/src/emit/lower/ldexp.rsand the added lines inlower.rs/valu_tests.rs.
|
460bea6 tracks the input and output denormal bits independently and processes MODE writes through whole-wave sections. The new synthetic test exercises both directions. Clearing MODE bit 7 alone preserves a subnormal input that scales into the normal range, and flushes a subnormal result. Clearing bit 6 inside a whole-wave section flushes a subnormal input and still preserves a subnormal result. Both negative cases check the sign bit. The first partial write failed to lower on I also tested #2743, #2791 and #2782 together on current main. The integration uses the same separate bits for AI-assisted with Codex. Synthetic shaders only. |
Summary
Lower RDNA 2 V_LDEXP_F64 by adjusting and rounding its binary64 significand and exponent in two 32-bit words. Both register pairs and signed 32-bit scale operands use their normal routes. The translation requires neither host doubles nor int64.
The existing MODE analysis now also tracks the FP16/FP64 denormal field. Scaling handles all four rounding and denormal modes when they are known at translation time. The shader entry uses nearest-even rounding and preserves binary64 subnormals, matching the documented AMDHSA defaults. RDNA 2 ISA · AMDGPU kernel descriptor defaults
Verification
Coordination claim
Please retain the Git author if cherry-picking or rebasing this commit. If folding it into another commit, add Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com.
AI-assisted. Verification used synthetic shaders.