fix: match RDNA2 rounded f32-to-i32 conversions in VIctory #321

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

@⁠mauroalvare on GitHub · 2026-11-26 02:50 UTC · original
mauroalvare:codex/victory-rounded-f32-i32 → main · +122 −21 · 2 files · 1 commits · open

Change

Neptune lowered v_cvt_rpi_i32_f32 as a binary32 add of 0.5 followed by floor. On the RTX 5070 Ti, the float immediately below 0.5 returned 1 where the RDNA 2 result is 0. The same shader also returned 0 for a positive NaN, which should saturate to INT32_MAX in the rounded forms.

Use the in-tree HLSL recompiler's floor-and-fraction rule for RPI and apply the source modifiers at the bit level for the rounded conversions. RPI and FLR select the saturation endpoint from the resulting NaN sign. The fixtures also cover truncating conversions as a NaN-to-zero control.

The change is in the Rust DXIL emitter used by Neptune through tools/lancer_victory.ps1.

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880. Fix c6385d8cb05f59f774b32076818899e9f57456cc.

The synthetic shaders take f32 bits from root constants and store one converted dword to a UAV. The SDK DXIL validator accepted the shaders and the D3D12 pipelines ran on the RTX 5070 Ti (driver 621.40, 32-lane waves) and WARP (4-lane waves). The fix matched all 112 expected outputs per adapter. The cases include VOP1 and VOP3, halfway values, large odd integers, saturation limits, infinities, and quiet and signaling NaNs under the four VOP3 abs/neg combinations. The AnyXboxX interpreter independently agreed on the same 112 expected outputs.

From third_party/victory:

cargo test --locked --offline -j 2 -p victory-shader --lib rounded_f32_to_i32_ -- --nocapture --test-threads=1
Base with tests: 0 passed, 2 failed, 244 filtered out.
  RTX VOP1 RPI 0x3effffff: got 1, expected 0.
  RTX RPI 0x7fc00000: got 0, expected 2147483647.
Fix: 2 passed, 0 failed, 244 filtered out.

cargo test --locked --offline -p victory-shader -- --nocapture --test-threads=1
244 passed, 0 failed, 2 ignored.

cargo test --locked --offline -p victory-loader --test load_probe
2 passed, 0 failed.

cargo xtask policy
asset policy: 199 files ok

cargo check --locked --offline -j 2 -p victory
Passed, with two warnings emitted by victory-gpu.

The shader suite also reports four console-compiler comparisons that skip locally and two adapter-specific skips in existing wave-sum tests.

From the repository root, with ANYXBOXX_REQUIRE_RUNTIME=1, the SDK's DXC, and the C++/Rust/TomBox binaries already built in this worktree from the same base:

python -m pytest -rs
1665 passed, 0 skipped (87.76 s, Python 3.13.15).

python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools
All checks passed!

Oracle and test data

All shader words and inputs are constructed in the tests. AMD's ISA defines the conversion rules, and Lyrnc's published gfx1036 measurements establish the exact RPI threshold and NaN saturation. The original Rust change here also verifies VOP3 source sign modifiers in Neptune on Windows. AMD RDNA 2 ISA, §12.8 · gfx1036 measurements · In-tree HLSL reference

  • One reviewable behavior with synthetic regressions that fail on the base.
  • Verification commands, skips and results are recorded above.
  • README consistency checked by the full pytest suite.

AI assistance from OpenAI Codex for investigation, implementation and validation.

**@⁠mauroalvare** on GitHub · 2026-11-26 02:50 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/321) `mauroalvare:codex/victory-rounded-f32-i32` → `main` · +122 −21 · 2 files · 1 commits · open ## Change Neptune lowered `v_cvt_rpi_i32_f32` as a binary32 add of 0.5 followed by floor. On the RTX 5070 Ti, the float immediately below 0.5 returned 1 where the RDNA 2 result is 0. The same shader also returned 0 for a positive NaN, which should saturate to `INT32_MAX` in the rounded forms. Use the in-tree HLSL recompiler's floor-and-fraction rule for RPI and apply the source modifiers at the bit level for the rounded conversions. RPI and FLR select the saturation endpoint from the resulting NaN sign. The fixtures also cover truncating conversions as a NaN-to-zero control. The change is in the Rust DXIL emitter used by Neptune through `tools/lancer_victory.ps1`. ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`. Fix `c6385d8cb05f59f774b32076818899e9f57456cc`. The synthetic shaders take f32 bits from root constants and store one converted dword to a UAV. The SDK DXIL validator accepted the shaders and the D3D12 pipelines ran on the RTX 5070 Ti (driver 621.40, 32-lane waves) and WARP (4-lane waves). The fix matched all 112 expected outputs per adapter. The cases include VOP1 and VOP3, halfway values, large odd integers, saturation limits, infinities, and quiet and signaling NaNs under the four VOP3 abs/neg combinations. The AnyXboxX interpreter independently agreed on the same 112 expected outputs. From `third_party/victory`: ```text cargo test --locked --offline -j 2 -p victory-shader --lib rounded_f32_to_i32_ -- --nocapture --test-threads=1 Base with tests: 0 passed, 2 failed, 244 filtered out. RTX VOP1 RPI 0x3effffff: got 1, expected 0. RTX RPI 0x7fc00000: got 0, expected 2147483647. Fix: 2 passed, 0 failed, 244 filtered out. cargo test --locked --offline -p victory-shader -- --nocapture --test-threads=1 244 passed, 0 failed, 2 ignored. cargo test --locked --offline -p victory-loader --test load_probe 2 passed, 0 failed. cargo xtask policy asset policy: 199 files ok cargo check --locked --offline -j 2 -p victory Passed, with two warnings emitted by victory-gpu. ``` The shader suite also reports four console-compiler comparisons that skip locally and two adapter-specific skips in existing wave-sum tests. From the repository root, with `ANYXBOXX_REQUIRE_RUNTIME=1`, the SDK's DXC, and the C++/Rust/TomBox binaries already built in this worktree from the same base: ```text python -m pytest -rs 1665 passed, 0 skipped (87.76 s, Python 3.13.15). python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed! ``` ## Oracle and test data All shader words and inputs are constructed in the tests. AMD's ISA defines the conversion rules, and Lyrnc's published gfx1036 measurements establish the exact RPI threshold and NaN saturation. The original Rust change here also verifies VOP3 source sign modifiers in Neptune on Windows. [AMD RDNA 2 ISA, §12.8](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) · [gfx1036 measurements](https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580) · [In-tree HLSL reference](https://github.com/LooperSalty/AnyXboxX/blob/c4c93bdc413191a9dc909998d2d53080a3f0c880/PrototypeScarlett/emu/rdna2_hlsl_helpers.py#L37-L44) - [x] One reviewable behavior with synthetic regressions that fail on the base. - [x] Verification commands, skips and results are recorded above. - [x] README consistency checked by the full pytest suite. AI assistance from OpenAI Codex for investigation, implementation and validation.
Use the floor and fraction rule from the in-tree HLSL recompiler, and saturate NaNs using the sign after applying source modifiers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:58 +00:00
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/321/head:github-bot/gh-321'
git switch 'github-bot/gh-321'

Merge

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