Shaders: lower nearest-even binary64 rounding #2647
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2647
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:30 UTC · original
andrewpozdnakov7-jpg:codex2/rndne-f64→main· +192 −0 · 3 files · 2 commits · openProblem
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].
@kotekompotek on GitHub · 2026-11-25 17:53 UTC · original
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.@oni-swr on GitHub · 2026-11-25 17:58 UTC · original
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.@fuzeofficlal on GitHub · 2026-11-25 18:16 UTC · original
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.@Mericas77 on GitHub · 2026-11-25 18:27 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 22:17 UTC · original · edited 2026-11-26 03:25 UTC
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
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.