fix(victory-shader): implement ties-to-even rounding in integer DXIL for NVIDIA #306
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/306"
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-26T01:57:18Z.
Change
In VIctory's RDNA2-to-DXIL translator (
third_party/victory/crates/victory-shader/src/emit/lower.rs),v_rndne_f32,v_rndne_f16, andv_cvt_pk_u8_f32lowered round-to-nearest-even to DXILdx.op.unary.f32(26)(Round_ne).On NVIDIA driver 621.xx (measured on RTX 5070 Ti
621.40; previously observed inPrototypeScarlettin #227 / PR #260), the driver constant-foldsRound_ne(2.5)after a barrier to3.0(0x40400000, round half away from zero) instead of2.0(0x40000000, ties to even), and replaces NaN payloads with0x7FFFFFFF(while WARP leaves signalling NaNs unquieted).Fix:
Lower::rndne_f32, computing branchless IEEE-754 ties-to-even rounding in 32-bit integer bit arithmetic (matching RDNA 2 for ties-to-even, signed zeros±0.0, subnormals, integers>= 2^23, infinities, qNaN payload preservation, and sNaN quieting).v_rndne_f32,v_rndne_f16, andv_cvt_pk_u8_f32throughLower::rndne_f32.Linked issue: Refs #227
Verification
Base SHA:
c4c93bdc413191a9dc909998d2d53080a3f0c880(LooperSalty/AnyXboxX:main)Hardware: Windows 11, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver
621.40), WARP,dxil.dll10.0.26100.0, Rust1.98.1(MSVC).Before the fix (failing on base
c4c93bdon RTX 5070 Ti):After the fix (from
third_party/victory):Oracle and test data
The new regression test
v_rndne_f32_ties_to_even_and_specialsinthird_party/victory/crates/victory-shader/src/emit/valu_tests.rssynthesizes minimal GFX10 compute shaders for:v_rndne_f32across ties-to-even (±0.5,±1.5,±2.5,±3.5,4.5,8388607.5), signed zeros, subnormals, infinities, quiet NaNs (0x7FC00000,0x7FC00001,0xFFC00000), and signalling NaNs (0x7F800001,0xFF800001);2.5,-2.5,0.5,-0.5intov_rndne_f32acrosss_barrier;2.5acrosss_barrierintov_rndne_f16(0x4100 -> 0x4000) andv_cvt_pk_u8_f32(2.5 -> 2).All shaders are validated with
dxil.dlland executed bit-for-bit on both RTX 5070 Ti and WARP against IEEE-754 / AMD RDNA 2 ISA semantics. No game, console, or SDK files were used.Checklist
E_NOTIMPL), never a fake success.Round_nedriver bug identified in #227 / PR #260).AI assistance: investigated, implemented, tested on RTX 5070 Ti and WARP, and drafted with Antigravity (Gemini).
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T18:41:30Z.
The branch was rebased while I was testing. I kept the new commit and pushed a follow-up that moves the rounding helper into its own module, keeping
lower.rsunder the 512 KiB asset-policy limit. The new arithmetic tests from main and the rounding regression are both present.The regression reproduced the NVIDIA NaN-payload mismatch on the base and passed on the fix. The full shader suite reported 258 passed and two ignored. GitHub now reports the PR as mergeable.
GitHub Actions for this revision.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T16:24:27Z.
Thanks, the integer ties-to-even sequence reads correctly. Two
Round_necall sites are still left on the DXIL op:lower.rs:4540(let whole = self.unary(26, x), the trig range reduction) andlower.rs:12289(self.unary(26, lod), LOD rounding). On the NVIDIA drivers where op 26 folds half-way cases, these still round 0.5 differently from RDNA 2. Please route them throughrndne_f32too, or say in the commit why they are exempt (for example if a half-way input cannot reach them).Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:20:35Z.
Addressed in
dd63f35: routed the two remaining \dx.op.unary.f32(26, ...)\ sites (\ rig_turns\ and \image_gather4_l\ explicit LOD rounding) throughndne_f32\ so zero \Round_ne\ DXIL op 26 calls remain, and bumped \TRANSLATOR_VERSION\ (\2 -> 3). Re-verified on RTX 5070 Ti + WARP + \dxil.dll\ (\cargo test --locked -p victory-shader -- --test-threads=1: 318 passed, 0 failed, 4 ignored; \cargo xtask policy: 286 files ok).
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T17:31:04Z.
Thanks, both remaining sites are covered now. One collision: this bumps
TRANSLATOR_VERSIONto 3, but #456 (open) also sets 3, and #485 now sets 4. If both #306 and #456 land at 3, a cache built with only one of them would be reused after the other merges, and serve stale DXIL. Each merged translation change needs its own value, so please take the next free one (5 today) or, if this lands right after another bump, rebase and bump again.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:57:27Z.
Updated
TRANSLATOR_VERSIONto5in40554f0(leaving3for #456 and4for #485; will re-bump if another version change merges ahead of this). Re-verifiedv_rndne_f32_ties_to_even_and_specialsandcargo xtask policy(286 files ok).