Shaders: lower nearest-even binary64 rounding #2645
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2647"
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 Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T17:30:35Z.
Problem
The shader decoder recognizes V_RNDNE_F64, but lowering rejects it in both VOP1 and VOP3. The instruction rounds a binary64 value to a whole number, with halfway values rounded to even. AMD RDNA 2 ISA reference, VOP1 instructions
Change
Round the binary64 bit pattern using its two 32-bit words, including the carry across the words and the signed-zero result for small magnitudes. Apply the source sign modifiers before rounding. The generated DXIL does not require optional double-precision or Int64 shader features.
Verification
13f91caand pass after the patch. The VOP1 fixture compares both result words for 28 values through VGPR and SGPR pairs. It covers ties, values adjacent to halfway, signed zero, subnormals, the 31/32/33-bit fractional boundary, and infinities. The VOP3 fixture checks a negated literal and the DXIL feature flags.Coordination claim
AI-assisted (Codex 2). Please retain the Git author on cherry-pick or rebase. If folding this change into another commit, please retain Co-authored-by: andrewpozdnakov7-jpg [email protected].
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:53:32Z.
Reviewed: lowering
v_rndne_f64without requiring host doubles is the right direction (GTX hosts lack f64). Source operand handling covers register pairs, inline constants (incl. the sign-extended const range 193–208), and literal high words. CI green.Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T17:58:13Z.
Independent verification of head
7636aedbe624fcae2c7bb0c970798dba70708186merged ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca.-j 4, WARP only (VICTORY_WARP=1,VICTORY_D3D12_WARP=1; d3d10warp 10.0.26100.9818), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0 x64 dxil.dll on PATH). No physical GPU device was created by the test runs. The new tests run on WARP (run_casesusesHost::new, which honoursVICTORY_WARP=1for both of its loop labels).lower.rs(v_rndne_f64lowering without host doubles/i64) plus 2 tests invalu_tests.rs. Merges cleanly.-p victory-shader --all-targets): no warnings.cargo test --locked --no-fail-fast -p victory-shader: 269 passed, 3 failed, 3 ignored (origin/main: 267/3/3). The 3 failures are the same pre-existing WARP baseline ones (a_mask_joined_with_data_at_a_uniform_loop_is_its_number,gathers_at_a_level_match_the_hardware,permutes_read_the_lane_named_and_zero_from_lanes_left_out: "no pipeline for a wave of 32"); the 2 new tests pass."v_rndne_f64"dispatch line removed, bothv_rndne_f64_rounds_ties_to_even_across_both_wordsandv_rndne_f64_rounds_a_negated_vop3_literalfail.Independent verification by Claude Code (Claude Sonnet 5.5), an AI. No game files, dumps or shader names were used. Each PR head was merged (no conflicts) onto
origin/mainand run with--locked; clippy used--all-targets.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:16:41Z.
Tested
7636aedbmerged cleanly ontomain(13f91ca) on Windows 11 with NVIDIA GeForce RTX 5090 (32.0.16.1656), D3D12 WARP, and Windows SDKdxil.dll:cargo test -p victory-shader --lib v_rndne_f64): 2 passed, 0 failed (v_rndne_f64_rounds_ties_to_even_across_both_wordsandv_rndne_f64_rounds_a_negated_vop3_literalpass on both adapters withdxil.dllvalidation and nodoubles/int64SFI0feature bits set)VICTORY_WARP=1 cargo test -p victory-shader --lib emit::valu_tests): 32 passed, 0 failedcargo clippy -p victory-shader --all-targets -- -D warnings: clean (0 warnings)Walked through the bit-level ties-to-even paths (
±0.0, subnormals,|x| < 1.0,n == 32,n == 33..=52includingn = 52,n == 1..=31cross-word carry,|x| >= 2^52,±inf,NaN) — all look clean.Imported from Marvisak/VIctory. Originally posted by Mericas77 on 2026-11-25T18:27:57Z.
Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head
7636aedagainstmain13f91ca.v_rndne_f64_rounds_ties_to_even_across_both_wordsandv_rndne_f64_rounds_a_negated_vop3_literal: 2/2 pass, throughrun_cases, so on the NVIDIA hardware adapter as well as WARP (noskippedline).cargo test -p victory-shader --lib --locked(with--skip heap_direct_texture_reads_mark_their_heap_index, which crashes the process onmainhere, #2571):main266 passed / 3 failed / 3 ignored, this PR 268 / 3 / 3. The 3 failures are the known NVIDIA ones onmain(a_heap_buffer_read_by_element_takes_the_views_stride,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,gathers_at_a_level_match_the_hardware) and are the same.So the lowering gives the same bits on NVIDIA hardware, no regression. No game data; the title was not run.
AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:17:47Z.
Automated triage for the maintainers.
Verdict: merge candidate (unchanged). The new head
c49835amergesmainand movesround_ne_f64fromemit/lower.rsintocrates/victory-shader/src/emit/lower/rndne.rs. I compared it with the reviewed7636aed. The function body is the same apart fromrustfmtline breaks andpub(super), thev_rndne_f64dispatch line inlower.rsis unchanged, and thevalu_tests.rsadditions are identical. My earlier review of the rounding arithmetic still applies.The branch contains a merge commit from
main, so a squash merge would keep the history tidy.CI: passing (
check). Merges cleanly.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:47:27Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP,dxil.dllvalidator active):cargo test -p victory-shader --lib emit::valu_tests::v_rndne_f64: 2 passed, 0 failed (v_rndne_f64_rounds_ties_to_even_across_both_wordsandv_rndne_f64_rounds_a_negated_vop3_literalpass on both RTX 5090 hardware and WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:26:35Z.
Review: APPROVED
Reviewed
c49835aebf1919435a1f02de69ac8a4178d7483c.LGTM —
Lower::round_ne_f64accurately lowersv_rndne_f64using pure 32-bit integer DXIL ops (noDOUBLE/INT64SFI0feature bits), handling ties-to-even with implicit units bit atexp = 0, cross-word sticky/parity carries acrossexp = 19/20/21, subnormals,±0.0,±Inf, andabs/negmodifiers before rounding.Verified locally on RTX 5090 + WARP:
cargo xtask policy(192 files ok),cargo clippy -p victory-shader --all-targets/--all-features(-D warnings), andrustfmt --edition 2024 --checkonrndne.rspass cleanly (zero newrustfmtdiffs inlower.rs;lower.rsis 520,635 bytes).v_rndne_f64_*tests pass underVICTORY_WARP=0andVICTORY_WARP=1withSFI0 & 0x8001 == 0, andemit::lower::testspasses (33 passed).Non-blocking notes:
rustfmt --edition 2024 --checkflags one line-wrapping diff on the newassert_eq!atcrates/victory-shader/src/emit/valu_tests.rs:622.clamp/omodmodifiers return an unsupported error.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.