Shaders: lower binary64 reciprocal square root with dwords #2811
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!2811
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2811"
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 21:14 UTC · original
andrewpozdnakov7-jpg:codex2/rsq-f64→main· +465 −47 · 3 files · 2 commits · openMain stops translation on
V_RSQ_F64. This lowering normalizes a binary64 input, computes the square root of its significand to 28 bits, and divides to obtain a 26-bit reciprocal. The 32-bit DXIL arithmetic retains the known rounding direction and input-denormal mode, handles signed zeros and infinities, and quiets NaNs. AMD specifies a 2^29 binary64 ULP bound for this instruction. RDNA 2 ISA referenceBoth synthetic shaders stop on unsupported
v_rsq_f64at13f91ca. The same tests pass all 112 cases on app-local WARP SM 6.6 with the DXIL validator. They cover VOP1 VGPR and VOP3 SGPR sources, all four rounding modes, input-subnormal modes, special values, and the two-dword normalization boundary. Feature-flag checks confirm the 32-bit lowering. An independent integer model stayed within the bound for all 327,520 CPU comparisons across the finite exponent fields.The paired full shader suite moved from 268 passed, 5 failed and 3 ignored to 270 passed, 3 failed and 3 ignored. The other three failures were the same gather-at-level, lane-permute and edge-flagged-triangle tests in both runs. All 33 patched VALU tests including runtime identity passed. Strict shader Clippy and staged asset policy passed.
The mode analysis follows the same approach as #2743, #2791 and #2799. 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:33 UTC · original
Verified
e1de9799on Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll):cargo xtask policy: 185 files ok;cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default &--features host): 0 warnings.cargo test -p victory-shader --features host --lib --locked -- valu_tests::: 32/32 passed on RTX 5090 + WARP +dxil.dll, includingrsqrt_f64_tracks_binary64_range_and_roundingandrsqrt_f64_obeys_the_input_denormal_mode(andSFI0 & 0x8001 == 0confirms pure 32-bit DXIL with no double/int64 flags).lower/rsqrt.rs: special values (±0.0 -> ±Inf, negative/-Inf -> qNaN,+Inf -> +0.0, sNaN quieted preserving sign/payload,MODE[7:6]input denormal flush vs normalize viaunaryBits.i32op 33), 28-bit integer sqrt + opposite-direction rounding + 26-bit long division, and modifier rejection (clamp/omod/sdwa/dpp,absbeforeneg, 32-bit literal as high dword) all check out.git merge-tree: clean againstorigin/main13f91caand #2812; conflicts with #2743/#2791/#2799 inlower.rson the sharedFpMode16refactor, and shares the sameLower::mode16 -> FpMode16compile interaction with #2782 (lower.rs:3384needsself.mode16.round.ok_or(...)if both land).@Marvisak on GitHub · 2026-11-26 02:19 UTC · original
Automated triage for the maintainers.
This lowers
v_rsq_f64, which translation refuses today, in 32-bit integer DXIL (emit/lower/rsqrt.rs): it normalizes the input, takes a 28-bit integer square root of the significand, then divides. It handles signed zeros, infinities, negative inputs and NaN quieting, and refuses the modifiers it does not model. It also generalizesround16intoFpMode16, which now tracks the f64/f16 denorm bits (MODE 7:6) as well as the round mode. I read the mode tracking:s_denorm_mode's bits 3:2 and thes_setregfield arithmetic are right, and an unknown mode is refused rather than guessed. The accuracy target is AMD's public RDNA2 ISA bound, and the tests run on hardware and WARP. Note that it overlaps theFpMode16refactor in #2743/#2791/#2799, so whichever lands second needs a rebase.CI: passing.
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.