Shaders: lower binary64 scaling with floating-point modes #2741

Open
andrewpozdnakov7-jpg wants to merge 3 commits from upstream-pr/2743 into main
andrewpozdnakov7-jpg commented 2026-11-25 19:27:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T19:27:17Z.


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

  • On 13f91ca, each of the three synthetic shaders fails translation with Unsupported v_ldexp_f64.
  • With the change, the same tests verify both result words on app-local D3D12 WARP. Cases cover normals, subnormals, signed zeros, overflow, underflow, NaN/Inf, cross-word carry, and explicit S_ROUND_MODE, S_DENORM_MODE and S_SETREG writes.
  • All 33 project VALU tests pass. The existing FP16 mode test also passes on the base and patched builds. Strict shader Clippy and staged asset policy pass.

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 [email protected].

AI-assisted. Verification used synthetic shaders.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5497751908 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T19:27:17Z. --- ## 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](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) · [AMDGPU kernel descriptor defaults](https://llvm.org/docs/AMDGPUUsage.html#amdhsa-kernel-directives-table) ## Verification - On 13f91ca, each of the three synthetic shaders fails translation with Unsupported v_ldexp_f64. - With the change, the same tests verify both result words on app-local D3D12 WARP. Cases cover normals, subnormals, signed zeros, overflow, underflow, NaN/Inf, cross-word carry, and explicit S_ROUND_MODE, S_DENORM_MODE and S_SETREG writes. - All 33 project VALU tests pass. The existing FP16 mode test also passes on the base and patched builds. Strict shader Clippy and staged asset policy pass. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7172137644) Please retain the Git author if cherry-picking or rebasing this commit. If folding it into another commit, add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>. AI-assisted. Verification used synthetic shaders.
fuzeofficlal commented 2026-11-25 21:03:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:10:44Z.


Reviewed and verified 99161fd6 on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll) against main (13f91ca).

Code review

  • Pure 32-bit integer lowering of v_ldexp_f64 (no DOUBLE / INT64 shader capability required).
  • scale_source_words applies abs then neg on the high word, rejects src1 modifiers and clamp/omod/sdwa/dpp, places Literal in the high word, sign-extends inline negative integers, promotes inline floats (with 248 = 0x3fc4_5f30_6dc9_c882), preserves ±0.0/±Inf, and quietens sNaN while retaining payload.
  • Clamping power to [-4096, 4096] avoids signed overflow with i32::MIN/i32::MAX. FpMode16 tracks both MODE[3:2] rounding and MODE[7:6] FP16/FP64 denorm modes cleanly and explicitly refuses unknown/conflicting modes at CFG joins; subnormal input flush vs. FirstbitHi normalization, cross-word FirstbitLo sticky rounding in round_scaled_subnormal, carry-out from max subnormal to min normal before output flush, and overflow rounding (±Inf vs. ±f64::MAX) all check out.

Verification (Windows 11, RTX 5090 + WARP + dxil.dll)

  • cargo test --locked -p victory-shader --lib --features host emit::tests: 17/17 passed; emit::lower::tests: 27/27 passed; emit::valu_tests (excluding slow exhaustive tests): 29/29 passed (all 3 ldexp_f64_* tests pass on both RTX 5090 and WARP).
  • VICTORY_WARP=1 cargo test --locked -p victory-shader --lib --features host ldexp: 3/3 passed.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 185 files ok.
  • Clean git merge-tree against 13f91ca, #2713, and #2728.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7173296012 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7173296012). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T20:10:44Z. --- Reviewed and verified `99161fd6` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`) against `main` (`13f91ca`). ### Code review - Pure 32-bit integer lowering of `v_ldexp_f64` (no `DOUBLE` / `INT64` shader capability required). - `scale_source_words` applies `abs` then `neg` on the high word, rejects `src1` modifiers and `clamp`/`omod`/`sdwa`/`dpp`, places `Literal` in the high word, sign-extends inline negative integers, promotes inline floats (with `248` = `0x3fc4_5f30_6dc9_c882`), preserves `±0.0`/`±Inf`, and quietens `sNaN` while retaining payload. - Clamping `power` to `[-4096, 4096]` avoids signed overflow with `i32::MIN`/`i32::MAX`. `FpMode16` tracks both `MODE[3:2]` rounding and `MODE[7:6]` FP16/FP64 denorm modes cleanly and explicitly refuses unknown/conflicting modes at CFG joins; subnormal input flush vs. `FirstbitHi` normalization, cross-word `FirstbitLo` sticky rounding in `round_scaled_subnormal`, carry-out from max subnormal to min normal before output flush, and overflow rounding (`±Inf` vs. `±f64::MAX`) all check out. ### Verification (Windows 11, RTX 5090 + WARP + `dxil.dll`) - `cargo test --locked -p victory-shader --lib --features host emit::tests`: **17/17 passed**; `emit::lower::tests`: **27/27 passed**; `emit::valu_tests` (excluding slow exhaustive tests): **29/29 passed** (all 3 `ldexp_f64_*` tests pass on both RTX 5090 and WARP). - `VICTORY_WARP=1 cargo test --locked -p victory-shader --lib --features host ldexp`: **3/3 passed**. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **185 files ok**. - Clean `git merge-tree` against `13f91ca`, `#2713`, and `#2728`.
oni-swr commented 2026-11-25 21:03:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:15:42Z.


Independent WARP/CPU verification for head 99161fd6fe against origin/main 13f91caee2. 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). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set (WARP only, no physical GPU); no game files. CARGO_TARGET_DIR=D:\victory-warp-2741-target. Tested commit: the PR head itself, which is exactly one commit on top of origin/main (merge-base = origin/main, so no temporary merge was needed). In victory-shader's host tests VICTORY_WARP=1 makes both the "hardware" and "warp" labels run on WARP (Host::new), so no physical GPU was used.

Commands/results:

  • Baseline (origin/main): cargo test --locked -p victory-shader — 267 passed, 3 failed, 3 ignored. Pre-existing failures on main: emit::synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out. cargo clippy --locked -p victory-shader --all-targets -- -D warnings — pass.
  • PR: cargo test --locked -p victory-shader --lib ldexp_f64 — 3/3 passed. cargo test --locked -p victory-shader — 270 passed (+3), the same 3 failed (identical names to baseline, so no new failure), 3 ignored. cargo clippy --locked -p victory-shader --all-targets -- -D warnings — pass.
  • Negative controls (tests kept, each change restored afterwards, tree clean): "v_ldexp_f64" arm removed -> all 3 new tests FAILED. Round-up direction inverted (1 => negative) -> ldexp_f64_uses_the_round_mode_for_underflow_and_overflow FAILED, the other two passed. Subnormal-result flush disabled (if false) -> ldexp_f64_uses_the_denormal_mode_for_both_operands_and_results FAILED, the other two passed. So each of the three tests pins a different part of the lowering.

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 v_ldexp_f64 refuses (Err) when either mode is unknown instead of guessing; the test also asserts the SFI0 doubles/int64 feature bits are clear, which is a good guard for the no-native-double goal. Subnormal rounding (sticky across the dword boundary, carry into the minimum normal, flush only if the result is still subnormal), overflow by round mode, NaN quieting and power clamping are all covered by cases. Scope notes: clamp, omod, SDWA, DPP and abs/neg on the exponent operand are rejected as unsupported (explicit errors, not silent); the lowering is only checked against hand-written expected bit patterns, not against a hardware reference, and the new files are not rustfmt-formatted (neither is most of main, so not counted against it).

Not tested: physical GPU, retail title/game behavior, release build (debug profile only).

AI disclosure: Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173410008 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7173410008). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T20:15:42Z. --- Independent WARP/CPU verification for head 99161fd6fe5ce773cb2e0e5a3458d8492643784d against origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. 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). `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set (WARP only, no physical GPU); no game files. `CARGO_TARGET_DIR=D:\victory-warp-2741-target`. Tested commit: the PR head itself, which is exactly one commit on top of `origin/main` (merge-base = `origin/main`, so no temporary merge was needed). In victory-shader's host tests `VICTORY_WARP=1` makes both the "hardware" and "warp" labels run on WARP (`Host::new`), so no physical GPU was used. Commands/results: - Baseline (origin/main): `cargo test --locked -p victory-shader` — 267 passed, **3 failed**, 3 ignored. Pre-existing failures on main: `emit::synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`. `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` — pass. - PR: `cargo test --locked -p victory-shader --lib ldexp_f64` — 3/3 passed. `cargo test --locked -p victory-shader` — 270 passed (+3), the same 3 failed (identical names to baseline, so no new failure), 3 ignored. `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` — pass. - Negative controls (tests kept, each change restored afterwards, tree clean): `"v_ldexp_f64"` arm removed -> all 3 new tests FAILED. Round-up direction inverted (`1 => negative`) -> `ldexp_f64_uses_the_round_mode_for_underflow_and_overflow` FAILED, the other two passed. Subnormal-result flush disabled (`if false`) -> `ldexp_f64_uses_the_denormal_mode_for_both_operands_and_results` FAILED, the other two passed. So each of the three tests pins a different part of the lowering. 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 `v_ldexp_f64` refuses (`Err`) when either mode is unknown instead of guessing; the test also asserts the SFI0 doubles/int64 feature bits are clear, which is a good guard for the no-native-double goal. Subnormal rounding (sticky across the dword boundary, carry into the minimum normal, flush only if the result is still subnormal), overflow by round mode, NaN quieting and power clamping are all covered by cases. Scope notes: `clamp`, `omod`, SDWA, DPP and abs/neg on the exponent operand are rejected as unsupported (explicit errors, not silent); the lowering is only checked against hand-written expected bit patterns, not against a hardware reference, and the new files are not rustfmt-formatted (neither is most of main, so not counted against it). Not tested: physical GPU, retail title/game behavior, release build (debug profile only). AI disclosure: Claude Code (Claude Sonnet 5.5).
kotekompotek commented 2026-11-25 21:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:39:36Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173997865 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7173997865). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:39:36Z. --- 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<u8>; whichever lands second needs mode16.round.
Marvisak commented 2026-11-26 00:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:24:40Z.


Automated triage for the maintainers. This adds a lowering for v_ldexp_f64 in crates/victory-shader/src/emit/lower/ldexp.rs using only 32-bit integer ops, and replaces round16 in emit/lower.rs with FpMode16, which tracks MODE bits 3:2 (round) and 7:6 (FP16/64 denorm) on their own. I checked the subnormal normalization (FirstbitHi counted from the MSB), the right shift into subnormal units with sticky bits across the dword boundary, the directed and nearest-even rounding, the flush rules for the RDNA2 denorm field (bit 0 input, bit 1 output), overflow to Inf or max-finite by round mode, NaN quieting, and the 64-bit literal and inline-constant handling. Things to note: the entry assumption that subnormals are preserved comes from the AMDHSA defaults, not from the title's own shader float mode, and #2782 reads mode16 as Option<u8>, so whichever lands second needs mode16.round. CI: check passing. This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177522047 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7177522047). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:24:40Z. --- <!-- victory-triage v1 head=177f0e52bf457774caebce2299c617499efaed1a verdict=merge-candidate at=2026-11-25T23:24:32Z --> Automated triage for the maintainers. This adds a lowering for `v_ldexp_f64` in `crates/victory-shader/src/emit/lower/ldexp.rs` using only 32-bit integer ops, and replaces `round16` in `emit/lower.rs` with `FpMode16`, which tracks MODE bits 3:2 (round) and 7:6 (FP16/64 denorm) on their own. I checked the subnormal normalization (FirstbitHi counted from the MSB), the right shift into subnormal units with sticky bits across the dword boundary, the directed and nearest-even rounding, the flush rules for the RDNA2 denorm field (bit 0 input, bit 1 output), overflow to Inf or max-finite by round mode, NaN quieting, and the 64-bit literal and inline-constant handling. Things to note: the entry assumption that subnormals are preserved comes from the AMDHSA defaults, not from the title's own shader float mode, and #2782 reads `mode16` as `Option<u8>`, so whichever lands second needs `mode16.round`. CI: `check` passing. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
HAL9000RELOADED commented 2026-11-26 00:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by HAL9000RELOADED on 2026-11-25T23:25:47Z.


First Radeon run of 177f0e5: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 in the shader test binaries through #486. Base: 481d699 (main 842b0cb + #486).

  • victory-shader: 304 passed, 1 failed. The three new tests pass on the card: ldexp_f64_scales_normal_and_subnormal_values, ldexp_f64_uses_the_denormal_mode_for_both_operands_and_results and ldexp_f64_uses_the_round_mode_for_underflow_and_overflow.
  • The one failure is pops_wait_loop_exits_immediately_for_inactive_lanes, which wants an SM 6.6 WARP device (this Windows 10 WARP reports SM 6.2). It fails the same way on the base without this PR.

So the lowered binary64 scaling, denormal and round modes included, matches on RDNA3 hardware as well as on the RTX 5090 and WARP.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177547749 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7177547749). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T23:25:47Z. --- First Radeon run of `177f0e5`: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 in the shader test binaries through #486. Base: `481d699` (main `842b0cb` + #486). - `victory-shader`: 304 passed, 1 failed. The three new tests pass on the card: `ldexp_f64_scales_normal_and_subnormal_values`, `ldexp_f64_uses_the_denormal_mode_for_both_operands_and_results` and `ldexp_f64_uses_the_round_mode_for_underflow_and_overflow`. - The one failure is `pops_wait_loop_exits_immediately_for_inactive_lanes`, which wants an SM 6.6 WARP device (this Windows 10 WARP reports SM 6.2). It fails the same way on the base without this PR. So the lowered binary64 scaling, denormal and round modes included, matches on RDNA3 hardware as well as on the RTX 5090 and WARP.
Dukestar69 commented 2026-11-26 04:07:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:07:41Z.

Review: APPROVED


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, and ldexp_f64_uses_the_round_mode_for_underflow_and_overflow pass 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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068420260 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#pullrequestreview-6068420260). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T04:07:41Z. **Review:** APPROVED --- 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`, and `ldexp_f64_uses_the_round_mode_for_underflow_and_overflow` pass 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 commented 2026-11-27 01:33:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:33:02Z.

Review: APPROVED


Looks good — verified locally at 177f0e52:

  • cargo xtask policy (192 files ok) and cargo clippy --all-targets --all-features -- -D warnings pass with 0 warnings.
  • emit::valu_tests::ldexp_f64 passes 3/3 on both RTX 5090 (VICTORY_WARP=0) and WARP (VICTORY_WARP=1), verifying SFI0 & 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):

  1. Pre-existing from round16_after, the whole-wave section loop (lower.rs around for j in i + 1..end { self.section_inst(b, j, i); }) jumps i = end; continue; without advancing self.mode16 = self.mode16.after(&p.blocks[b].insts[j]). Advancing self.mode16 inside that loop keeps intra-block mode16 tracking consistent with fp_modes16 if a s_round_mode / s_denorm_mode appears inside a section.
  2. rustfmt --edition 2024 --check flags minor line-wrapping diffs in crates/victory-shader/src/emit/lower/ldexp.rs and the added lines in lower.rs / valu_tests.rs.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082301242 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#pullrequestreview-6082301242). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T01:33:02Z. **Review:** APPROVED --- Looks good — verified locally at `177f0e52`: - `cargo xtask policy` (`192 files ok`) and `cargo clippy --all-targets --all-features -- -D warnings` pass with 0 warnings. - `emit::valu_tests::ldexp_f64` passes **3/3** on both RTX 5090 (`VICTORY_WARP=0`) and WARP (`VICTORY_WARP=1`), verifying `SFI0 & 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)*: 1. Pre-existing from `round16_after`, the whole-wave section loop (`lower.rs` around `for j in i + 1..end { self.section_inst(b, j, i); }`) jumps `i = end; continue;` without advancing `self.mode16 = self.mode16.after(&p.blocks[b].insts[j])`. Advancing `self.mode16` inside that loop keeps intra-block `mode16` tracking consistent with `fp_modes16` if a `s_round_mode` / `s_denorm_mode` appears inside a section. 2. `rustfmt --edition 2024 --check` flags minor line-wrapping diffs in `crates/victory-shader/src/emit/lower/ldexp.rs` and the added lines in `lower.rs` / `valu_tests.rs`.
andrewpozdnakov7-jpg commented 2026-11-27 09:17:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T09:17:23Z.


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 177f0e5 with unknown floating-point modes. All four ldexp_f64 tests passed on the updated head with WARP 1.0.22, as did strict all-features shader Clippy and asset policy.

I also tested #2743, #2791 and #2782 together on current main. The integration uses the same separate bits for ldexp and sqrt, and reads the rounding field for s_getreg_b32. All 46 VALU tests passed on WARP, plus strict shader Clippy and asset policy. The branch keeps the three published PR heads.

AI-assisted with Codex. Synthetic shaders only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7214503467 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2743#issuecomment-7214503467). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T09:17:23Z. --- [460bea6](https://github.com/Marvisak/VIctory/pull/2743/commits/460bea63c85e37e6eaeb5affa60d0375fc43a810) 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 `177f0e5` with unknown floating-point modes. All four `ldexp_f64` tests passed on the updated head with WARP 1.0.22, as did strict all-features shader Clippy and asset policy. I also tested [#2743, #2791 and #2782 together on current main](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/test/mode-ldexp-sqrt-read-integration). The integration uses the same separate bits for `ldexp` and `sqrt`, and reads the rounding field for `s_getreg_b32`. All 46 VALU tests passed on WARP, plus strict shader Clippy and asset policy. The branch keeps the three published PR heads. AI-assisted with Codex. Synthetic shaders only.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2743:upstream-pr/2743'
git switch 'upstream-pr/2743'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2743'
git switch 'upstream-pr/2743'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2743'
git switch 'upstream-pr/2743'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2743'
git switch 'main'
git merge --squash 'upstream-pr/2743'
git switch 'main'
git merge --ff-only 'upstream-pr/2743'
git switch 'main'
git merge 'upstream-pr/2743'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2741
No description provided.