shader: lower v_frexp_{exp,mant}_{f32,f16} in pure 32-bit DXIL #1659

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

@⁠geiyiliyabumo on GitHub · 2026-11-24 20:33 UTC · original
geiyiliyabumo:fix/shader-frexp-f32-f16 → main · +290 −24 · 2 files · 1 commits · open

Summary

  • Lowers RDNA2 v_frexp_exp_i32_f32 (VOP1 0x03f / VOP3 0x1bf), v_frexp_mant_f32 (VOP1 0x040 / VOP3 0x1c0), v_frexp_mant_f16 (VOP1 0x059 / VOP3 0x1d9), and v_frexp_exp_i16_f16 (VOP1 0x05a / VOP3 0x1da) in crates/victory-shader/src/emit/lower.rs (Lower::frexp).
  • Matches AMD RDNA 2 ISA §12.8 in pure 32-bit integer/f32 DXIL arithmetic (neither Double nor Int64 feature bits are set in SFI0):
    • Normalizes subnormals via bit-level FirstbitHi (unaryBits.i32 op 33) so DXIL f32 denormal flushing cannot corrupt subnormal inputs.
    • Preserves signed zero (±0.0), ±inf, and NaN in the mantissa (and flushes -0.0 to +0.0 under omod per RDNA2 ISA §6.2.2); returns 0 for their exponents.
    • Honors VOP3 abs/neg source modifiers, clamp/omod float output modifiers, and SDWA / VOP3 op_sel half selection while preserving the untouched VGPR half on 16-bit writes.

Verification

  • cargo test -p victory-shader --lib: 123 passed, 0 failed, 1 ignored on both AMD Radeon RX 9060 XT (D3D12 hardware) and Microsoft Basic Render Driver (WARP), including 3 new regression tests (v_frexp_f32_decomposes_normals_and_subnormals_and_handles_special_values, v_frexp_f16_decomposes_and_preserves_the_other_destination_half, v_frexp_vop3_applies_float_modifiers — 108 synthetic GPU dispatches per backend, asserting Double and Int64 SFI0 flags are clear).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: pass (154 files).

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 20:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1659) `geiyiliyabumo:fix/shader-frexp-f32-f16` → `main` · +290 −24 · 2 files · 1 commits · open ## Summary - Lowers RDNA2 `v_frexp_exp_i32_f32` (`VOP1 0x03f` / `VOP3 0x1bf`), `v_frexp_mant_f32` (`VOP1 0x040` / `VOP3 0x1c0`), `v_frexp_mant_f16` (`VOP1 0x059` / `VOP3 0x1d9`), and `v_frexp_exp_i16_f16` (`VOP1 0x05a` / `VOP3 0x1da`) in `crates/victory-shader/src/emit/lower.rs` (`Lower::frexp`). - Matches AMD RDNA 2 ISA §12.8 in pure 32-bit integer/f32 DXIL arithmetic (neither `Double` nor `Int64` feature bits are set in `SFI0`): - Normalizes subnormals via bit-level `FirstbitHi` (`unaryBits.i32` op 33) so DXIL f32 denormal flushing cannot corrupt subnormal inputs. - Preserves signed zero (`±0.0`), `±inf`, and `NaN` in the mantissa (and flushes `-0.0` to `+0.0` under `omod` per RDNA2 ISA §6.2.2); returns `0` for their exponents. - Honors VOP3 `abs`/`neg` source modifiers, `clamp`/`omod` float output modifiers, and SDWA / VOP3 `op_sel` half selection while preserving the untouched VGPR half on 16-bit writes. ## Verification - `cargo test -p victory-shader --lib`: **123 passed, 0 failed, 1 ignored** on both **AMD Radeon RX 9060 XT (D3D12 hardware)** and **Microsoft Basic Render Driver (WARP)**, including 3 new regression tests (`v_frexp_f32_decomposes_normals_and_subnormals_and_handles_special_values`, `v_frexp_f16_decomposes_and_preserves_the_other_destination_half`, `v_frexp_vop3_applies_float_modifiers` — 108 synthetic GPU dispatches per backend, asserting `Double` and `Int64` `SFI0` flags are clear). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: pass (154 files). *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:20 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:33 UTC · original · edited 2026-11-25 22:25 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1659#issuecomment-7149687444) · edited 2026-11-25 22:25 UTC <!-- victory-triage v1 head=f9dda94f1286f269680f51925ffc87ebed12c571 verdict=needs-rebase at=2026-11-25T22:28:30Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:36 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 79107fd applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 pre-existing unused-import errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1659#issuecomment-7149749930) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `79107fd` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 96 passed, 0 failed, 1 ignored. All tests pass. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 pre-existing unused-import errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-25 02:25 UTC · original

Rebased cleanly onto \main\ (\ccfb029), preserving \main's \ tz/denormal-flush \omod\ handling inside \ loat_output_modifiers. \cargo test -p victory-shader --locked frexp\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings, and \cargo xtask policy\ all pass.

**@⁠geiyiliyabumo** on GitHub · 2026-11-25 02:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1659#issuecomment-7150701721) Rebased cleanly onto \main\ (\ccfb029\), preserving \main\'s \ tz\/denormal-flush \omod\ handling inside \ loat_output_modifiers\. \cargo test -p victory-shader --locked frexp\ (verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll\), \cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings\, and \cargo xtask policy\ all pass.
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-25 03:49 UTC · original

Updated per triage feedback: applied \Lower::ftz\ to f32 \ _frexp_exp_i32_f32\ / \ _frexp_mant_f32\ inputs (preserving signed-zero mantissa and zero exponent for flushed f32 subnormals while keeping f16 subnormal decomposition unchanged) and updated the f32 subnormal tests. Rebased onto \main\ (\940d32f); verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll: \ rexp\ (3 passed, 0 failed), \semantics_tests\ (32 passed, 0 failed), \clippy -D warnings, and \xtask policy\ all pass.

**@⁠geiyiliyabumo** on GitHub · 2026-11-25 03:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1659#issuecomment-7152280971) Updated per triage feedback: applied \Lower::ftz\ to f32 \ _frexp_exp_i32_f32\ / \ _frexp_mant_f32\ inputs (preserving signed-zero mantissa and zero exponent for flushed f32 subnormals while keeping f16 subnormal decomposition unchanged) and updated the f32 subnormal tests. Rebased onto \main\ (\940d32f\); verified on physical AMD RX 9060 XT + WARP + Microsoft \dxil.dll\: \ rexp\ (3 passed, 0 failed), \semantics_tests\ (32 passed, 0 failed), \clippy -D warnings\, and \xtask policy\ all pass.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1659'
git switch 'github-bot/gh-1659'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1659'
git switch 'github-bot/gh-1659'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1659'
git switch 'main'
git merge --squash 'github-bot/gh-1659'
git switch 'main'
git merge --ff-only 'github-bot/gh-1659'
git switch 'main'
git merge 'github-bot/gh-1659'
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!1659
No description provided.