Shaders: match RDNA2 NaN bits for negative F16 logarithms #3206

Open
github-bot wants to merge 1 commit from github-bot/gh-3206 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 12:42 UTC · original
andrewpozdnakov7-jpg:fix/v-log-f16-negative-domain → main · +46 −0 · 2 files · 1 commits · open

AMD specifies 0xfe00 for v_log_f16(-1) and v_log_f16(-inf). A native RX 6700 XT sweep also records this word for negative nonzero inputs. In the current VIctory lowering the host logarithm supplies the NaN bits. WARP 1.0.22 returned 0xffff after narrowing. AMD RDNA 2 ISA · Native RDNA2 sweep

Select the documented quiet NaN for ordered x < 0 in the F16 log lowering. This keeps both zero signs on the existing logarithm path.

The same synthetic test on upstream 63bcca4 reported four mismatches for fc00, bc00, 8400, and 8001. With the fix all 11 input/output pairs pass on WARP 1.0.22 with D3D12 Agility 1.620.2. The controls cover both zero signs, a positive subnormal, powers of two and positive infinity. Every case checks that the high half of the destination is preserved.

cargo test --locked -p victory-shader --lib emit::valu_tests::v_log_f16_matches_rdna2_special_values -- --exact --test-threads=1

WARP suites passed (36 VALU, 34 semantics with 1 ignored), as did strict shader Clippy and cargo xtask policy. Physical GPU and in-game behavior were outside this run.

Claim in #1633

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 12:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3206) `andrewpozdnakov7-jpg:fix/v-log-f16-negative-domain` → `main` · +46 −0 · 2 files · 1 commits · open AMD specifies `0xfe00` for `v_log_f16(-1)` and `v_log_f16(-inf)`. A native RX 6700 XT sweep also records this word for negative nonzero inputs. In the current VIctory lowering the host logarithm supplies the NaN bits. WARP 1.0.22 returned `0xffff` after narrowing. [AMD RDNA 2 ISA](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) · [Native RDNA2 sweep](https://github.com/ubiquitarianism/leonida/blob/a73a57e1339be072baf5522351c8ec7f1482b56b/docs/shader_validation.md#L1538-L1607) Select the documented quiet NaN for ordered `x < 0` in the F16 log lowering. This keeps both zero signs on the existing logarithm path. The same synthetic test on upstream `63bcca4` reported four mismatches for `fc00`, `bc00`, `8400`, and `8001`. With the fix all 11 input/output pairs pass on WARP 1.0.22 with D3D12 Agility 1.620.2. The controls cover both zero signs, a positive subnormal, powers of two and positive infinity. Every case checks that the high half of the destination is preserved. ```text cargo test --locked -p victory-shader --lib emit::valu_tests::v_log_f16_matches_rdna2_special_values -- --exact --test-threads=1 ``` WARP suites passed (36 VALU, 34 semantics with 1 ignored), as did strict shader Clippy and `cargo xtask policy`. Physical GPU and in-game behavior were outside this run. [Claim in #1633](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:44:21 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 12:47 UTC · original · approved these changes

Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib v_log_f16_matches_rdna2_special_values -- --test-threads=1: passed on RTX 5090 and WARP.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Clean fix matching RDNA2 NaN bits for negative F16 logarithms.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 12:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/3206#pullrequestreview-6074372044) · **approved these changes** Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib v_log_f16_matches_rdna2_special_values -- --test-threads=1`: passed on RTX 5090 and WARP. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Clean fix matching RDNA2 NaN bits for negative F16 logarithms. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 13:06 UTC · original

WARP test report (claim: #1633)

  • Head: 5398738488fb9c0f9a5304ae22d6ba15516799e0, base: origin/main 63bcca43c6 (head sits directly on it, no merge needed)
  • Backend: WARP (VICTORY_D3D12_WARP=1). Windows 11, Rust per rust-toolchain.toml, cargo test --locked -p victory-shader --lib -- --test-threads=1, VICTORY_D3D12_WARP=1 and VICTORY_WARP=1 (the shader tests only honour the latter, so every device in the run was WARP; no physical GPU). Validator: Windows SDK 10.0.26100 dxil.dll. Synthetic word streams only, no game data.
  • victory-shader suite: 299 passed, 4 failed, 3 ignored. New test v_log_f16_matches_rdna2_special_values passes, not skipped (all 11 cases on WARP, including -inf, -1.0 and negative denormals expecting 0xfe00).
  • Control: with only the new test applied to main it fails on all four negative inputs (got 0xabcdffff, want 0xabcdfe00 for 0xfc00, 0xbc00, 0x8400, 0x8001). Suite on main alone: 298 passed, 4 failed, 3 ignored; the same 4 unrelated failures as on the PR (a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out).
  • Review: no defect found. -0 and +0 are not < 0, so they still give -inf (0xfc00), and a NaN input is not < 0, so it still goes through the log. The 0xfe00 result relies on the host turning the f32 NaN 0xffc00000 into f16 0xfe00, which holds on WARP; the comment says so. I could not check other hosts.

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).

**@⁠oni-swr** on GitHub · 2026-11-26 13:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3206#issuecomment-7192894360) **WARP test report (claim: #1633)** - Head: `5398738488fb9c0f9a5304ae22d6ba15516799e0`, base: `origin/main` 63bcca43c6a0 (head sits directly on it, no merge needed) - Backend: WARP (VICTORY_D3D12_WARP=1). Windows 11, Rust per `rust-toolchain.toml`, `cargo test --locked -p victory-shader --lib -- --test-threads=1`, `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1` (the shader tests only honour the latter, so every device in the run was WARP; no physical GPU). Validator: Windows SDK 10.0.26100 `dxil.dll`. Synthetic word streams only, no game data. - `victory-shader` suite: **299 passed, 4 failed, 3 ignored**. New test `v_log_f16_matches_rdna2_special_values` passes, not skipped (all 11 cases on WARP, including -inf, -1.0 and negative denormals expecting 0xfe00). - Control: with only the new test applied to `main` it **fails** on all four negative inputs (`got 0xabcdffff, want 0xabcdfe00` for 0xfc00, 0xbc00, 0x8400, 0x8001). Suite on main alone: 298 passed, 4 failed, 3 ignored; the same 4 unrelated failures as on the PR (`a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_mask_high_address_bits_and_divergent_branches`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`). - Review: no defect found. `-0` and `+0` are not `< 0`, so they still give -inf (0xfc00), and a NaN input is not `< 0`, so it still goes through the log. The 0xfe00 result relies on the host turning the f32 NaN `0xffc00000` into f16 0xfe00, which holds on WARP; the comment says so. I could not check other hosts. AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 16:06 UTC · original · edited 2026-11-26 16:08 UTC

AMD check on a Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), victory-shader built with --features host:

  • On 63bcca4 with only the test applied, the hardware backend reports no mismatch — the card already returns 0xfe00 for the four negative cases; only WARP returns 0xffff.
  • With the PR both agree, 11/11.

So on AMD hardware this is a WARP/CI-facing fix. Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 16:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3206#issuecomment-7197193351) · edited 2026-11-26 16:08 UTC AMD check on a Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), `victory-shader` built with `--features host`: - On 63bcca4 with only the test applied, the hardware backend reports no mismatch — the card already returns `0xfe00` for the four negative cases; only WARP returns `0xffff`. - With the PR both agree, 11/11. So on AMD hardware this is a WARP/CI-facing fix. Synthetic only. AI-assisted.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3206/head:github-bot/gh-3206'
git switch 'github-bot/gh-3206'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3206'
git switch 'github-bot/gh-3206'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3206'
git switch 'github-bot/gh-3206'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3206'
git switch 'main'
git merge --squash 'github-bot/gh-3206'
git switch 'main'
git merge --ff-only 'github-bot/gh-3206'
git switch 'main'
git merge 'github-bot/gh-3206'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3206
No description provided.