Shaders: lower binary64 reciprocal with 32-bit operations #2799
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!2799
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2799"
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 20:49 UTC · original
andrewpozdnakov7-jpg:codex2/rcp-f64→main· +446 −49 · 3 files · 2 commits · openMain stops translation on
V_RCP_F64. This lowering normalizes the binary64 input and computes a 26-bit quotient with 32-bit operations. It applies the known rounding direction and input/output denormal modes. It also handles signed zeros and infinities, quiets NaNs, and uses the exact exponent to classify overflow. AMD specifies an accuracy bound of 2^29 binary64 ULP for this instruction. RDNA 2 ISA referenceBoth synthetic shaders stop on unsupported
v_rcp_f64at13f91ca. The same fixtures pass all 160 cases on app-local WARP SM 6.6 with the DXIL validator. The cases cover VOP1 VGPR and VOP3 SGPR sources, both signs, the four rounding and denormal modes, and the finite boundary next to overflow. The fixtures verify that the emitted DXIL requires neither doubles nor int64. An independent integer model passed 1,572,096 comparisons to CPU binary64, with the largest measured finite discrepancy below 197 million ULP (the limit is 536,870,912).The full serial shader suite changed from 268 passed, 5 failed, and 3 ignored to 270 passed, 3 failed, and 3 ignored with both new tests present. The other three failures were the same gather-at-level, lane-permute, and edge-flagged-triangle tests on both revisions. The patched VALU run passed all 33 tests including runtime identity. Strict shader Clippy and staged asset policy passed.
This uses the same FP16/FP64 mode analysis as #2743 and #2791. Coordination claim
Please retain the Git author on cherry-pick or rebase. If you fold this change into another commit, please include
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@fuzeofficlal on GitHub · 2026-11-25 21:20 UTC · original
Reviewed and verified
f37bb61aon Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).Code review
SFI0 & 0x8001 == 0, no double/int64 capability required).±0.0 -> ±Inf,±Inf -> ±0.0,sNaN -> qNaNwith sign/payload preserved (including low-word-only payloads),MODE[7:6]input/output denormal flush vs.FirstbitHinormalization (2^1022 -> MIN_NORMALnot flushed), exact-exponent overflow &coarse_overflowclamp to±f64::MAX, and 26-bit long division across all 4 rounding modes (within RDNA2's<= 2^29binary64 ULP bound) all check out cleanly.git merge-treevs13f91ca; conflicts inlower.rswith#2743and#2791(sharedFpMode16refactor); textually clean vs#2782, but changingLower::mode16toFpMode16requires updating#2782'sself.mode16.ok_or(...)(lower.rs:3384) toself.mode16.round.ok_or(...)when both land.Verification (Windows 11, RTX 5090 + WARP +
dxil.dll)cargo test --locked -p victory-shader --features host --lib -- valu_tests::: 32 passed, 0 failed (including both newreciprocal_f64_*tests on RTX 5090 and WARP).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 185 files ok.@Marvisak on GitHub · 2026-11-25 23:23 UTC · original
Automated triage for the maintainers.
This adds a lowering for
v_rcp_f64(Lower::reciprocal_f64in the newcrates/victory-shader/src/emit/lower/reciprocal.rs) using only 32-bit operations, with a 26-bit quotient held to the 2^29 binary64 ULP bound the public RDNA2 ISA reference gives for V_RCP_F64, plus zero/infinity/NaN handling and the 16/64-bit round and denormal modes. To get the denormal mode it replacesround16/round16_afterinlower.rswith anFpMode16analysis that also tracks MODE bits 7:6 (s_denorm_mode,s_setreg); I checked that the round-mode part keepsmain's behaviour fornarrow16andv_fma_f16, and the lowering refuses to translate when either mode is unknown. Two things for the maintainer to weigh: the entry valueFpMode16::INITIALassumes denormals preserved for 16/64-bit with no cited source, and the sameFpMode16refactor is in #2743 and #2791, so whichever lands second will need a rebase. CI (check) passes.This is a recommendation for a maintainer to look, not an approval.
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.