Shaders: preserve NaN bits in f16 transcendentals #3717

Open
Moon0755 wants to merge 2 commits from upstream-pr/3717 into main
Moon0755 commented 2026-11-28 10:47:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-28T10:47:23Z.


Preserves source NaN bit patterns (sign and payload, including signalling NaNs) in the seven 16-bit floating-point transcendentals (v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16, v_sin_f16, v_cos_f16).

Problem

Measured natively on RDNA2 (gfx1031 full 65,536-input sweep across wave32/wave64, IEEE off), these seven instructions pass input NaNs (both signalling and quiet) through with their sign and payload preserved after source abs/neg modifiers. Previously, lowering converted the result through narrow16, which quieted signalling NaNs (for example v_rcp_f16(0x7c01) produced 0x7e01 instead of 0x7c01) and could alter NaN payloads on the host.

Changes

  • crates/victory-shader/src/emit/lower.rs (522,761 B < 524,288 B): add half_fsrc_bits to retain the 16-bit source bits alongside the f32 value; for the seven f16 transcendentals without clamp, apply bit-level abs/neg to the source halfword and select it when (nan & 0x7FFF) > 0x7C00. The clamp path and rules covered by #3206, #3609, #3617, #3365 are left untouched.
  • crates/victory-shader/src/emit/valu_tests.rs: add f16_transcendentals_preserve_nan_bits covering 0x7c01, 0xfc35, 0x7e42, and 0xfe7f across all seven instructions.

Verification

  • Before this fix (upstream/main 63bcca4, confirmed in fork negative CI 46131133362 and locally): f16_transcendentals_preserve_nan_bits fails (v_rcp_f16(0x7c01)=0x7e01, want 0x7c01).
  • After this fix:
    • cargo test --locked -p victory-shader --lib --features host -- f16_transcendentals_preserve_nan_bits: 1 passed (local hardware adapter + WARP).
    • Regressions: transcendental, v_sin_and_v_cos, f16_results_round all PASS.
    • cargo clippy --locked -p victory-shader --all-targets --features host -- -D warnings: clean (exit 0).
    • cargo run --locked -p xtask -- policy: asset policy: 191 files ok.

AI-assisted; synthetic tests only, no game files.

— Devin & Neon

<!-- greyfinch-sync:Marvisak/VIctory:issue:5539323688 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-28T10:47:23Z. --- Preserves source NaN bit patterns (sign and payload, including signalling NaNs) in the seven 16-bit floating-point transcendentals (`v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`, `v_sin_f16`, `v_cos_f16`). ### Problem Measured natively on RDNA2 (`gfx1031` full 65,536-input sweep across wave32/wave64, IEEE off), these seven instructions pass input NaNs (both signalling and quiet) through with their sign and payload preserved after source `abs`/`neg` modifiers. Previously, lowering converted the result through `narrow16`, which quieted signalling NaNs (for example `v_rcp_f16(0x7c01)` produced `0x7e01` instead of `0x7c01`) and could alter NaN payloads on the host. ### Changes - **`crates/victory-shader/src/emit/lower.rs`** (`522,761 B` < `524,288 B`): add `half_fsrc_bits` to retain the 16-bit source bits alongside the f32 value; for the seven f16 transcendentals without `clamp`, apply bit-level `abs`/`neg` to the source halfword and select it when `(nan & 0x7FFF) > 0x7C00`. The `clamp` path and rules covered by `#3206`, `#3609`, `#3617`, `#3365` are left untouched. - **`crates/victory-shader/src/emit/valu_tests.rs`**: add `f16_transcendentals_preserve_nan_bits` covering `0x7c01`, `0xfc35`, `0x7e42`, and `0xfe7f` across all seven instructions. ### Verification - Before this fix (`upstream/main` `63bcca4`, confirmed in fork negative CI `46131133362` and locally): `f16_transcendentals_preserve_nan_bits` fails (`v_rcp_f16(0x7c01)=0x7e01, want 0x7c01`). - After this fix: - `cargo test --locked -p victory-shader --lib --features host -- f16_transcendentals_preserve_nan_bits`: **1 passed** (local hardware adapter + WARP). - Regressions: `transcendental`, `v_sin_and_v_cos`, `f16_results_round` all **PASS**. - `cargo clippy --locked -p victory-shader --all-targets --features host -- -D warnings`: **clean** (exit 0). - `cargo run --locked -p xtask -- policy`: `asset policy: 191 files ok`. AI-assisted; synthetic tests only, no game files. — Devin & Neon
cloph-dsp commented 2026-11-28 11:38:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T11:38:20Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3717 at head cb593fcf6651068eb796eec471f64d6c7fbba0c6, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::valu_tests::f16_transcendentals_preserve_nan_bits --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check 63bcca4 HEAD clean (2 files, +89/-5).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only shader IR test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7238683809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7238683809). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T11:38:20Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3717 at head `cb593fcf6651068eb796eec471f64d6c7fbba0c6`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::valu_tests::f16_transcendentals_preserve_nan_bits --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check 63bcca4 HEAD` clean (2 files, +89/-5). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only shader IR test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
andrewpozdnakov7-jpg commented 2026-11-28 12:27:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T12:27:42Z.


I combined your exact cb593fc with #3729 5f57f5e in integration commit d1b369e. Both commits are direct parents.

The extra WARP test covers reciprocal and square root with all four abs/neg combinations, both source and destination half selections, and four signaling or quiet NaN patterns. In all 128 cases, the expected sign and payload matched and the untouched destination half kept its sentinel value.

Your seven-operation regression, the new modifier test, and the inverse-bitcast regression all passed on Windows WARP with Agility 1.620.2. Strict shader Clippy and the asset policy passed. @Moon0755, the integration test is available for merge coordination. Please retain the original Git authors on cherry-pick or rebase.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7239242838 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7239242838). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T12:27:42Z. --- I combined your exact `cb593fc` with #3729 `5f57f5e` in [integration commit `d1b369e`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/d1b369ee49032746678fd4268003ed4229b046c8). Both commits are direct parents. The extra WARP test covers reciprocal and square root with all four `abs`/`neg` combinations, both source and destination half selections, and four signaling or quiet NaN patterns. In all 128 cases, the expected sign and payload matched and the untouched destination half kept its sentinel value. Your seven-operation regression, the new modifier test, and the inverse-bitcast regression all passed on Windows WARP with Agility 1.620.2. Strict shader Clippy and the asset policy passed. @Moon0755, the integration test is available for merge coordination. Please retain the original Git authors on cherry-pick or rebase. AI-assisted with OpenAI Codex.
upipibi commented 2026-11-28 14:58:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T14:58:08Z.


NVIDIA row for this PR: it passes on Ampere, and the test fails on this card without the fix.

RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head cb593fc on main 63bcca4 (one commit, clean).

  • f16_transcendentals_preserve_nan_bits: 1 passed, 0 failed, in 3 of 3 runs. It ran on both the hardware adapter and WARP: no "skipped" line.

  • Negative control: the same test with main's crates/victory-shader/src/emit/lower.rs (git diff --stat HEAD: 1 file, 5 insertions, 63 deletions) fails in 3 of 3 runs, on the hardware adapter, at the first case: hardware: v_rcp_f16(0x7c01) = 0x7fff, want 0x7c01. On this card main returns the canonical 0x7fff, not the 0x7e01 the description quotes; with the PR the source bits come back on both adapters.

  • cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index:

    • this PR: 299 passed, 3 failed, 3 ignored;
    • main 63bcca4: 298 passed, 3 failed, 3 ignored.

    The 3 failures are the same on both: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and synthetic_tests::gathers_at_a_level_match_the_hardware. The skipped test crashes the binary on this card (open issue #2571).

Not tested: a title run; the combination with #3729.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241080346 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7241080346). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T14:58:08Z. --- NVIDIA row for this PR: it passes on Ampere, and the test fails on this card without the fix. RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head `cb593fc` on main `63bcca4` (one commit, clean). - `f16_transcendentals_preserve_nan_bits`: 1 passed, 0 failed, in 3 of 3 runs. It ran on both the hardware adapter and WARP: no "skipped" line. - Negative control: the same test with main's `crates/victory-shader/src/emit/lower.rs` (`git diff --stat HEAD`: 1 file, 5 insertions, 63 deletions) fails in 3 of 3 runs, on the hardware adapter, at the first case: `hardware: v_rcp_f16(0x7c01) = 0x7fff, want 0x7c01`. On this card main returns the canonical `0x7fff`, not the `0x7e01` the description quotes; with the PR the source bits come back on both adapters. - `cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index`: - this PR: 299 passed, 3 failed, 3 ignored; - main `63bcca4`: 298 passed, 3 failed, 3 ignored. The 3 failures are the same on both: `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` and `synthetic_tests::gathers_at_a_level_match_the_hardware`. The skipped test crashes the binary on this card (open issue #2571). Not tested: a title run; the combination with #3729. AI-assisted (Claude Code, Claude Opus 5.5).
ColorMeBoom commented 2026-11-28 15:51:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T15:51:49Z.


Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head cb593fc on 63bcca4.

  • f16_transcendentals_preserve_nan_bits passes on the hardware adapter and on WARP; neither was skipped.
  • Full victory-shader --lib --features host: 303 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241792977 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7241792977). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-28T15:51:49Z. --- Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head `cb593fc` on `63bcca4`. - `f16_transcendentals_preserve_nan_bits` passes on the hardware adapter and on WARP; neither was skipped. - Full `victory-shader --lib --features host`: 303 passed, 0 failed, 3 ignored. AI use: Claude Code (Claude Opus 5.5).
kilolimaVI commented 2026-11-28 21:56:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T21:56:22Z.


AMD Radeon 780M (RDNA3) + WARP, Windows 11, head cb593fc. Before (main 63bcca4 + this PR's test): fails on the hardware adapter, v_rcp_f16(0x7c01) gives 0x7e01 (quieted) where 0x7c01 is wanted. After: passes, 5 of 5 runs. Full suite: 552 passed. AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246381687 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246381687). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T21:56:22Z. --- AMD Radeon 780M (RDNA3) + WARP, Windows 11, head `cb593fc`. Before (main `63bcca4` + this PR's test): fails on the hardware adapter, `v_rcp_f16(0x7c01)` gives `0x7e01` (quieted) where `0x7c01` is wanted. After: passes, 5 of 5 runs. Full suite: 552 passed. AI-assisted (Claude).
andrewpozdnakov7-jpg commented 2026-11-28 22:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T22:04:09Z.


I tested #3717 and #3617 together at their exact heads cb593fc and 8bfad4c. Git merged them cleanly, but the new NaN path returned before the rounding rule in #3617 was reached. The plain merge produced 14 mismatches across 168 WARP readbacks, all for finite inputs with FP_ROUND=3.

c6dbf69 applies nearest-even rounding inside the transcendental path. The extended test mixes finite inputs and four signaling or quiet NaNs in the same shader for each of the seven operations, with FP_ROUND set to 0 and 3. On WARP 1.0.22 with Agility 1.620.2, all 168 readbacks matched, including the untouched destination half. The existing NaN and FP32-to-FP16 conversion controls also passed.

Strict shader Clippy passed with default features and all features. The asset policy passed with lower.rs at 522,941 bytes.

Integration branch. Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding my changes into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246473417 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246473417). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T22:04:09Z. --- I tested #3717 and #3617 together at their exact heads `cb593fc` and `8bfad4c`. Git merged them cleanly, but the new NaN path returned before the rounding rule in #3617 was reached. The plain merge produced 14 mismatches across 168 WARP readbacks, all for finite inputs with `FP_ROUND=3`. [`c6dbf69`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/c6dbf69aafdb8e8af6bf4389a7370650b2dae7a3) applies nearest-even rounding inside the transcendental path. The extended test mixes finite inputs and four signaling or quiet NaNs in the same shader for each of the seven operations, with `FP_ROUND` set to 0 and 3. On WARP 1.0.22 with Agility 1.620.2, all 168 readbacks matched, including the untouched destination half. The existing NaN and FP32-to-FP16 conversion controls also passed. Strict shader Clippy passed with default features and all features. The asset policy passed with `lower.rs` at 522,941 bytes. [Integration branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/3617-3717-f16-transcendentals). Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding my changes into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 22:07:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T22:07:08Z.


@Moon0755, I checked this PR at cb593fc combined with #3617 at 8bfad4c. Git merged both exact heads into 15edfeb. With FP_ROUND=3, that tree fails the half-transcendental rounding test for all seven opcodes. The reciprocal case returns 0x2b87 where 0x2b88 is expected. The NaN regression passes on the same tree.

Follow-up 15f2978 puts nearest-even rounding in the seven-operation path that also preserves source NaN bits. Other half results keep their MODE rounding. Both PR heads remain parents of the merge below the fix.

Both regressions passed on signed WARP 1.0.22 with Agility 1.620.2 and DXIL validation. Four adjacent rounding and sine/cosine tests, all 33 lowerer tests, both strict shader Clippy configurations and the asset policy passed. The combined lowerer is 522,948 bytes. Your native report and the recent Radeon 780M runs tested the individual PR heads. The next step is author review and a native run of the comparison branch. #3717 Radeon report · #3617 Radeon report

Please retain the Git authors on cherry-pick or rebase, or include Co-authored-by: andrewpozdnakov7-jpg [email protected] if folding the fix into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246508662 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246508662). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T22:07:08Z. --- @Moon0755, I checked this PR at cb593fc combined with #3617 at 8bfad4c. Git merged both exact heads into 15edfeb. With FP_ROUND=3, that tree fails the half-transcendental rounding test for all seven opcodes. The reciprocal case returns 0x2b87 where 0x2b88 is expected. The NaN regression passes on the same tree. [Follow-up 15f2978](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/15f297817992600086f74c76ab099caf7b2a6275) puts nearest-even rounding in the seven-operation path that also preserves source NaN bits. Other half results keep their MODE rounding. Both PR heads remain parents of the merge below the fix. Both regressions passed on signed WARP 1.0.22 with Agility 1.620.2 and DXIL validation. Four adjacent rounding and sine/cosine tests, all 33 lowerer tests, both strict shader Clippy configurations and the asset policy passed. The combined lowerer is 522,948 bytes. Your native report and the recent Radeon 780M runs tested the individual PR heads. The next step is author review and a native run of the comparison branch. [#3717 Radeon report](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246381687) · [#3617 Radeon report](https://github.com/Marvisak/VIctory/pull/3617#issuecomment-7246372663) Please retain the Git authors on cherry-pick or rebase, or include Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the fix into another commit. AI-assisted with OpenAI Codex.
kilolimaVI commented 2026-11-28 22:18:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T22:18:31Z.


@andrewpozdnakov7-jpg native run of both comparison branches on AMD Radeon 780M (RDNA3, driver 32.0.13022.3006, Windows 11), each tree built in its own target directory:

tree half_transcendentals_round_to_nearest_in_both_modes f16_transcendentals_preserve_nan_bits
plain merge 15edfeb fail pass
15f2978 (codex2/pr3717-rounding-nan) pass pass
c6dbf69 (review/3617-3717-f16-transcendentals) pass pass

On the plain merge the hardware fails on more than reciprocal: rcp(0x4c40) gives 0xa55a2b87 (expected …2b88, as on WARP), and sqrt(0x3200) gives 0xa55a36ed (expected …36ee), both with FP_ROUND=3. The untouched destination half 0xa55a is kept in every case. Both fixes clear it, and all 37 emit::valu_tests pass on 15f2978.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246644226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246644226). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T22:18:31Z. --- @andrewpozdnakov7-jpg native run of both comparison branches on AMD Radeon 780M (RDNA3, driver 32.0.13022.3006, Windows 11), each tree built in its own target directory: | tree | `half_transcendentals_round_to_nearest_in_both_modes` | `f16_transcendentals_preserve_nan_bits` | |---|---|---| | plain merge `15edfeb` | fail | pass | | `15f2978` (codex2/pr3717-rounding-nan) | pass | pass | | `c6dbf69` (review/3617-3717-f16-transcendentals) | pass | pass | On the plain merge the hardware fails on more than reciprocal: `rcp(0x4c40)` gives `0xa55a2b87` (expected `…2b88`, as on WARP), and `sqrt(0x3200)` gives `0xa55a36ed` (expected `…36ee`), both with FP_ROUND=3. The untouched destination half `0xa55a` is kept in every case. Both fixes clear it, and all 37 `emit::valu_tests` pass on `15f2978`. AI-assisted (Claude).
Moon0755 commented 2026-11-28 22:43:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-28T22:43:18Z.


@andrewpozdnakov7-jpg thank you, you are right. 32a02eb is on this PR now.

Reproduced. The plain merge of cb593fc and 8bfad4c fails half_transcendentals_round_to_nearest_in_both_modes here on WARP, on an RTX 2060 and on an AMD Vega iGPU (rcp(0x4c40) with FP_ROUND=3: 0x2b87 for 0x2b88), and the NaN test passes. The path that keeps NaN bits returned through narrow16 before #3617's rule was reached.

The change. 32a02eb takes the lower.rs change of your c6dbf69 as it is (the file is byte-identical to yours) with Co-authored-by for you: in the path that keeps NaN bits, the seven instructions narrow to nearest even whatever FP_ROUND says. It does not bring #3617 itself into this PR. A new test, f16_transcendentals_keep_nearest_rounding_with_nan_inputs, pins it at FP_ROUND=3. The rule is Leonida's sweep on an RX 6700 XT (a73a57e, all 65,536 inputs: the f16 field of FP_ROUND is ignored).

Together. This head merged with #3617 8bfad4c passes all three tests on WARP, the RTX 2060 and the Radeon, so either PR can go in first.

lower.rs is 522,941 bytes here (+180). Merged with #3617 it is 523,395, because #3617's rule in float_result can then no longer be reached for these seven; your c6dbf69 removes it and gets back to 522,941. That clean-up fits whichever of the two lands second.

Your note on #3716 is right as well: #3716, #3617 and this one together pass the size limit. That needs code moved out of lower.rs, which is not for this PR.

— Devin & Fable

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246934135 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7246934135). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-28T22:43:18Z. --- @andrewpozdnakov7-jpg thank you, you are right. `32a02eb` is on this PR now. **Reproduced.** The plain merge of `cb593fc` and `8bfad4c` fails `half_transcendentals_round_to_nearest_in_both_modes` here on WARP, on an RTX 2060 and on an AMD Vega iGPU (`rcp(0x4c40)` with `FP_ROUND=3`: `0x2b87` for `0x2b88`), and the NaN test passes. The path that keeps NaN bits returned through `narrow16` before #3617's rule was reached. **The change.** `32a02eb` takes the `lower.rs` change of your `c6dbf69` as it is (the file is byte-identical to yours) with `Co-authored-by` for you: in the path that keeps NaN bits, the seven instructions narrow to nearest even whatever `FP_ROUND` says. It does not bring #3617 itself into this PR. A new test, `f16_transcendentals_keep_nearest_rounding_with_nan_inputs`, pins it at `FP_ROUND=3`. The rule is Leonida's sweep on an RX 6700 XT ([`a73a57e`](https://github.com/ubiquitarianism/leonida/blob/a73a57e1339be072baf5522351c8ec7f1482b56b/docs/shader_validation.md), all 65,536 inputs: the f16 field of `FP_ROUND` is ignored). **Together.** This head merged with #3617 `8bfad4c` passes all three tests on WARP, the RTX 2060 and the Radeon, so either PR can go in first. `lower.rs` is 522,941 bytes here (+180). Merged with #3617 it is 523,395, because #3617's rule in `float_result` can then no longer be reached for these seven; your `c6dbf69` removes it and gets back to 522,941. That clean-up fits whichever of the two lands second. Your note on #3716 is right as well: #3716, #3617 and this one together pass the size limit. That needs code moved out of `lower.rs`, which is not for this PR. — Devin & Fable
upipibi commented 2026-11-28 23:39:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T23:39:39Z.


Follow-up to my NVIDIA report above, at the new head: 32a02eb fixes the interaction with #3617 on the RTX 3070 too.

RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head 32a02eb on main 63bcca4 (two commits, clean).

  • f16_transcendentals_preserve_nan_bits and f16_transcendentals_keep_nearest_rounding_with_nan_inputs: 2 passed, 0 failed, 0 ignored, in 3 of 3 default runs (hardware adapter and WARP, no "skipped" line) and in 3 of 3 runs with VICTORY_WARP=1.
  • Merged locally with #3617 8bfad4c (--no-ff; lower.rs is 523,395 bytes, as you measured): those two plus half_transcendentals_round_to_nearest_in_both_modes: 3 passed, 0 failed, 0 ignored, in 3 of 3 default runs and 3 of 3 VICTORY_WARP=1 runs.
  • Old head cb593fc merged with 8bfad4c, once each: half_transcendentals_round_to_nearest_in_both_modes fails on the hardware adapter and on WARP, for all seven opcodes with FP_ROUND=3, one ulp low (rcp(0x4c40): 0xa55a2b87, expected 0xa55a2b88; sqrt(0x3200): 0xa55a36ed, expected 0xa55a36ee). The untouched high half is kept, and f16_transcendentals_preserve_nan_bits passes on that tree. So this card showed the same failure as the RTX 2060 and the Vega.
  • cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index: 300 passed, 3 failed, 3 ignored (at cb593fc it was 299 passed). The 3 failures are the same ones main has on this card: the two stride_tests and synthetic_tests::gathers_at_a_level_match_the_hardware.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7247578736 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7247578736). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T23:39:39Z. --- Follow-up to my NVIDIA report above, at the new head: `32a02eb` fixes the interaction with #3617 on the RTX 3070 too. RTX 3070 (desktop), driver 616.56, Windows 11 Pro 10.0.26100, debug. Head `32a02eb` on main `63bcca4` (two commits, clean). - `f16_transcendentals_preserve_nan_bits` and `f16_transcendentals_keep_nearest_rounding_with_nan_inputs`: 2 passed, 0 failed, 0 ignored, in 3 of 3 default runs (hardware adapter and WARP, no "skipped" line) and in 3 of 3 runs with `VICTORY_WARP=1`. - Merged locally with #3617 `8bfad4c` (`--no-ff`; `lower.rs` is 523,395 bytes, as you measured): those two plus `half_transcendentals_round_to_nearest_in_both_modes`: 3 passed, 0 failed, 0 ignored, in 3 of 3 default runs and 3 of 3 `VICTORY_WARP=1` runs. - Old head `cb593fc` merged with `8bfad4c`, once each: `half_transcendentals_round_to_nearest_in_both_modes` fails on the hardware adapter and on WARP, for all seven opcodes with `FP_ROUND=3`, one ulp low (`rcp(0x4c40)`: `0xa55a2b87`, expected `0xa55a2b88`; `sqrt(0x3200)`: `0xa55a36ed`, expected `0xa55a36ee`). The untouched high half is kept, and `f16_transcendentals_preserve_nan_bits` passes on that tree. So this card showed the same failure as the RTX 2060 and the Vega. - `cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index`: 300 passed, 3 failed, 3 ignored (at `cb593fc` it was 299 passed). The 3 failures are the same ones main has on this card: the two `stride_tests` and `synthetic_tests::gathers_at_a_level_match_the_hardware`. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
ColorMeBoom commented 2026-11-29 18:48:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-29T18:48:21Z.


RDNA1 row for the new head 32a02eb: RX 5700 XT (Navi 10, driver 32.0.21045.29003), Windows 11 26200. The fixture runs the hardware adapter and WARP in turn, and neither was skipped.

tree f16_transcendentals_preserve_nan_bits + f16_transcendentals_keep_nearest_rounding_with_nan_inputs half_transcendentals_round_to_nearest_in_both_modes
32a02eb alone 2 passed, 2 of 2 runs (#3617's test, not on this head)
32a02eb merged with #3617 8bfad4c (--no-ff, ef92bd2) 3 passed, 3 of 3 runs passes

Full victory-shader --lib --features host at 32a02eb: 304 passed, 0 failed, 3 ignored. A third run of the PR head alone didn't build because of a local file lock, so it's left out.

With Moon0755's RTX 2060 and Vega iGPU rows, upipibi's RTX 3070 and kilolimaVI's 780M, the fixed interaction with #3617 now checks out on RDNA1 too.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7260772464 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7260772464). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-29T18:48:21Z. --- RDNA1 row for the new head `32a02eb`: RX 5700 XT (Navi 10, driver 32.0.21045.29003), Windows 11 26200. The fixture runs the hardware adapter and WARP in turn, and neither was skipped. | tree | `f16_transcendentals_preserve_nan_bits` + `f16_transcendentals_keep_nearest_rounding_with_nan_inputs` | `half_transcendentals_round_to_nearest_in_both_modes` | |---|---|---| | `32a02eb` alone | 2 passed, 2 of 2 runs | (#3617's test, not on this head) | | `32a02eb` merged with #3617 `8bfad4c` (`--no-ff`, `ef92bd2`) | 3 passed, 3 of 3 runs | passes | Full `victory-shader --lib --features host` at `32a02eb`: 304 passed, 0 failed, 3 ignored. A third run of the PR head alone didn't build because of a local file lock, so it's left out. With Moon0755's RTX 2060 and Vega iGPU rows, upipibi's RTX 3070 and kilolimaVI's 780M, the fixed interaction with #3617 now checks out on RDNA1 too. AI use: Claude Code (Claude Opus 5.5).
passerbyyhx commented 2026-11-30 23:21:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-30T23:21:08Z.


Exhaustive half-NaN payload readback on 32a02eb33fdcbe3abe669762305cb5541eff827c: each of the seven guest operations ran on all 2,046 binary16 NaN encodings. The RTX 4090 Laptop GPU and Microsoft WARP each matched all 14,322 expected bit patterns. With the same fixture on the clean base 63bcca43c6a00a758510398fa43096ce7e4f7df0, the mismatch counts were 14,315 and 7,154 respectively. For example, reciprocal of 0x7c01 returned 0x7fff on the base 4090 path and 0x7e01 on base WARP. This checks NaN payload bits on the updated head; the finite-input rounding checks in the other reports cover a different case.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7295015378 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3717#issuecomment-7295015378). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-30T23:21:08Z. --- Exhaustive half-NaN payload readback on `32a02eb33fdcbe3abe669762305cb5541eff827c`: each of the seven guest operations ran on all 2,046 binary16 NaN encodings. The RTX 4090 Laptop GPU and Microsoft WARP each matched all 14,322 expected bit patterns. With the same fixture on the clean base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, the mismatch counts were 14,315 and 7,154 respectively. For example, reciprocal of `0x7c01` returned `0x7fff` on the base 4090 path and `0x7e01` on base WARP. This checks NaN payload bits on the updated head; the finite-input rounding checks in the other reports cover a different case.
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/3717:upstream-pr/3717'
git switch 'upstream-pr/3717'

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/3717'
git switch 'upstream-pr/3717'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3717'
git switch 'upstream-pr/3717'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3717'
git switch 'main'
git merge --squash 'upstream-pr/3717'
git switch 'main'
git merge --ff-only 'upstream-pr/3717'
git switch 'main'
git merge 'upstream-pr/3717'
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!3717
No description provided.