fix: match RDNA2 rounded f32-to-i32 conversions in VIctory #321
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/321"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T02:50:36Z.
Change
Neptune lowered
v_cvt_rpi_i32_f32as 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 toINT32_MAXin 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. Fixc6385d8cb05f59f774b32076818899e9f57456cc.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: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: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
AI assistance from OpenAI Codex for investigation, implementation and validation.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T13:03:10Z.
Rebase on current main (
fa6b209e) is needed: recent merges into main now conflict with this PR. Please rebase and push so the PR can be reviewed again.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:02:05Z.
Updated this PR to
a4453083. I retained the binary64 comparison tests from #313 alongside this PR's two rounded-conversion regressions. Both conversion tests passed locally.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T17:31:06Z.
This changes the DXIL of the rounded f32-to-i32 conversions for shaders that translated before, so
TRANSLATOR_VERSION(victory-shader/src/lib.rs) needs a bump, as its doc comment asks; otherwise caches from earlier builds keep serving the old rounding. Please take the next free value (#456 uses 3, #485 4, #306 asks for 5) and re-bump if another one lands first.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:57:30Z.
Bumped
TRANSLATOR_VERSIONto6inc2c2cc0(leaving3for #456,4for #485,5for #306; will re-bump if another translation bump lands first). Re-verified bothrounded_f32_to_i32_*tests andcargo xtask policy(286 files ok).