Shaders: invalid f32 sqrt, rsq and log inputs return negative quiet NaN #3612
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!3612
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3612"
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?
@Moon0755 on GitHub · 2026-11-27 21:09 UTC · original
Moon0755:fix/transcendental-invalid-qnan→main· +58 −0 · 2 files · 1 commits · openOn RDNA2 (
gfx1030, measured by the Leonida project),v_sqrt_f32,v_rsq_f32, andv_log_f32return the negative quiet NaN0xffc00000for any invalid negative input, while-0.0remains valid (-0.0forv_sqrt_f32, and-infforv_rsq_f32andv_log_f32). Without a guard, D3D12 hosts return0x7fffffffon NVIDIA across all three instructions and0xffffffffon WARP forv_log_f32.Changes
crates/victory-shader/src/emit/lower.rs: in thev_rsq_f32/v_sqrt_f32/v_log_f32lowering arm (matches!(op, 23..=25)), select0xFFC0_0000whenpred::OLT(a, 0.0)holds, leaving-0.0, positive inputs, and NaNs untouched (lower.rssize:521,221 B<524,288 B).crates/victory-shader/src/emit/valu_tests.rs: addtranscendental_invalid_results_are_negative_qnancovering negative inputs (-1.0,-4.0,-1000.0,-inf) and valid-0.0control cases forv_sqrt_f32,v_rsq_f32, andv_log_f32.Verification
AMD Radeon(TM) Graphics,NVIDIA GeForce RTX 2060 with Max-Q Design,WARP):main(63bcca4): NVIDIA returned0x7ffffffffor all three operations (v_sqrt_f32,v_rsq_f32,v_log_f32), and WARP returned0xffffffffforv_log_f32.aa63053):cargo test --locked -p victory-shader --lib --features host -- transcendental_invalid_results_are_negative_qnan --nocapturepassed on AMD Radeon(TM) Graphics, NVIDIA GeForce RTX 2060 with Max-Q Design, and WARP (1 passed; 0 failed).cargo xtask policy:191 files ok.cargo clippy: bothcargo clippy --locked -p victory-shader --lib --tests -- -D warningsand--all-features -- -D warningspassed cleanly.gemini/ci-transcendental-invalid-qnan): https://github.com/Moon0755/VIctory/actions/runs/46067684463 (SUCCESS;victory-shader303 passed / 0 failed / 3 ignored,victory-gpu231 passed / 0 failed,xtask6/6, both Clippy checks clean).gemini/ci-transcendental-invalid-qnan-negative, test only on63bcca4): https://github.com/Moon0755/VIctory/actions/runs/46067684675 (FAILURE;victory-shader302 passed / 1 failed exclusively onemit::valu_tests::transcendental_invalid_results_are_negative_qnan:warp: v_log_f32(0xbf800000) = 0xffffffff, want 0xffc00000).— Devin & Neon
@oni-swr on GitHub · 2026-11-27 22:03 UTC · original
Independent verification of
aa6305357c3b90c6d64309c6c94bab3895df0547againstmainat63bcca43c6a00a758510398fa43096ce7e4f7df0. Clean merge. Native Windows x64, D3D12 WARP only, with both WARP switches set and SDKdxil.dll. Tests (passed / failed / ignored, unit and integration combined) were 301 / 4 / 4 on base and 302 / 4 / 4 on head. Both runs had the same four WARP failures (three wave-32 pipeline checks and one texture gather check). The backported regression returned0xfffffffffor a negative logarithm input on base and passed on head. Signed-zero cases passed, and 30 sampled outputs for inputs the guard leaves unchanged matched bit for bit. Clippy passed with all targets, all features, and-D warnings. Review found no blocking defects. Asset policy passed, andlower.rswas 521,221 bytes on head and after merging withmain, 3,067 bytes below the 524,288-byte limit.AI-assisted (Codex, gpt-6.2-sol).
@ColorMeBoom on GitHub · 2026-11-27 23:48 UTC · original
Hardware run on AMD, since the report so far is WARP only: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head
aa63053on63bcca4. The test fixture checks the hardware adapter and WARP in turn, and neither was skipped.transcendental_invalid_results_are_negative_qnanpasses on both.victory-shader --lib --features host: 303 passed, 0 failed, 3 ignored.AI use: Claude Code (Claude Opus 5.5).
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.