Shaders: lower v_div_fixup_f16 (port of upstream VIctory #379) #1040

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

@⁠Moon0755 on GitHub · 2026-11-25 17:04 UTC · original
Moon0755:fix/v-div-fixup-f16 → main · +116 −0 · 2 files · 1 commits · open

Port of upstream Marvisak/VIctory#379 (originally authored by @LouisRiverstone).

Summary

Adds DXIL lowering for the RDNA2 16-bit division fixup instruction v_div_fixup_f16.

Previously, Lower::valu16 did not handle v_div_fixup_f16, rejecting shaders that use half-precision division fixup sequences.

Changes

  • crates/victory-shader/src/emit/lower.rs:
    • Added "v_div_fixup_f16" to FLOAT3 in Lower::valu16 and dispatched it to Lower::div_fixup(a, b, acc) in Lower::valu16_op (so half_fsrc / float_result apply source/destination op_sel, abs/neg, omod, clamp, and half preservation automatically).
    • Implemented Lower::div_fixup following the RDNA2 (gfx1036) ISA special-case precedence order on exact f32 representations: numerator NaN, denominator NaN, 0/0 or inf/inf -> qNaN, x/0 or inf/x -> signed infinity, 0/x or x/inf -> signed zero, quotient overflow / NaN -> signed infinity, otherwise copysign(|q|, num ^ den).
  • crates/victory-shader/src/emit/valu_tests.rs: added div_fixup_f16_reference and D3D12 WARP regression test v_div_fixup_f16_follows_the_isa_special_cases exercising 400 combinations of quotients, denominators, and numerators (including ±0, subnormals, ±inf, qNaN, sNaN, and verifying the upper 16 bits of the destination VGPR remain unchanged).

Verification

Verified on windows-latest via GitHub Actions (run 45660058837):

  • cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings — passed
  • cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings — passed
  • cargo test -p victory-shader -p xtask --locked -- --nocapture — 216 passed; 0 failed; 3 ignored (including v_div_fixup_f16_follows_the_isa_special_cases executed on D3D12 WARP, plus xtask 4 passed, repository_passes_policy passed)

— Neon

**@⁠Moon0755** on GitHub · 2026-11-25 17:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/1040) `Moon0755:fix/v-div-fixup-f16` → `main` · +116 −0 · 2 files · 1 commits · open Port of upstream `Marvisak/VIctory#379` (originally authored by `@LouisRiverstone`). ### Summary Adds DXIL lowering for the RDNA2 16-bit division fixup instruction `v_div_fixup_f16`. Previously, `Lower::valu16` did not handle `v_div_fixup_f16`, rejecting shaders that use half-precision division fixup sequences. ### Changes - `crates/victory-shader/src/emit/lower.rs`: - Added `"v_div_fixup_f16"` to `FLOAT3` in `Lower::valu16` and dispatched it to `Lower::div_fixup(a, b, acc)` in `Lower::valu16_op` (so `half_fsrc` / `float_result` apply source/destination `op_sel`, `abs`/`neg`, `omod`, `clamp`, and half preservation automatically). - Implemented `Lower::div_fixup` following the RDNA2 (`gfx1036`) ISA special-case precedence order on exact f32 representations: numerator NaN, denominator NaN, `0/0` or `inf/inf` -> qNaN, `x/0` or `inf/x` -> signed infinity, `0/x` or `x/inf` -> signed zero, quotient overflow / NaN -> signed infinity, otherwise `copysign(|q|, num ^ den)`. - `crates/victory-shader/src/emit/valu_tests.rs`: added `div_fixup_f16_reference` and D3D12 WARP regression test `v_div_fixup_f16_follows_the_isa_special_cases` exercising 400 combinations of quotients, denominators, and numerators (including `±0`, subnormals, `±inf`, qNaN, sNaN, and verifying the upper 16 bits of the destination VGPR remain unchanged). ### Verification Verified on `windows-latest` via GitHub Actions ([run 45660058837](https://github.com/Moon0755/victory-fork/actions/runs/45660058837)): - `cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings` — passed - `cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings` — passed - `cargo test -p victory-shader -p xtask --locked -- --nocapture` — `216 passed; 0 failed; 3 ignored` (including `v_div_fixup_f16_follows_the_isa_special_cases` executed on D3D12 WARP, plus `xtask` `4 passed`, `repository_passes_policy` passed) — Neon
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:28 +00:00
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 18:01 UTC · original

A hardware run of this PR's new test: v_div_fixup_f16_follows_the_isa_special_cases passes on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. It ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: #1030

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 18:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/1040#issuecomment-7170319781) A hardware run of this PR's new test: `v_div_fixup_f16_follows_the_isa_special_cases` passes on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. It ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: https://git.gtahub.st/github/fxceless--victory-fork/pulls/1030
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1040/head:github-bot/gh-1040'
git switch 'github-bot/gh-1040'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1040'
git switch 'github-bot/gh-1040'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1040'
git switch 'github-bot/gh-1040'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1040'
git switch 'main'
git merge --squash 'github-bot/gh-1040'
git switch 'main'
git merge --ff-only 'github-bot/gh-1040'
git switch 'main'
git merge 'github-bot/gh-1040'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.