Fix #726: NaN-safe v_med3_f32 lowering #2010
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!2010
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2010/head"
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?
@tharun-37 on GitHub · 2026-11-25 02:51 UTC · original
tharun-37:fix/med3-nan→main· +21 −5 · 1 files · 1 commits · closed without mergingSplit from #2000 (shader-only, covered by macOS test queue). NaN-safe min/max so a NaN operand yields the smaller of the two numbers. v_med3_f32_matches_rdna2_with_nan passes.
@Dathinel on GitHub · 2026-11-25 03:10 UTC · original
The existing
v_med3_f32_matches_rdna2_with_nantest runs on Windows. On an RTX 3050 Laptop (driver 610.62) and WARP it passes on both940d32fand this PR's36451bd, including the original(1, 2, NaN)case. A macOS test run omits this module.I also compared all 216 ordered triples drawn from −1, −0, +0, +2 and two quiet NaNs with different signs and payloads. Both revisions matched the same reference for every triple on each backend. I compared signed zeros by bit pattern and accepted any NaN for the all-NaN case.
The remaining check that can distinguish the fix is a before/after run on the Intel UHD setup that reproduces #726. The patch still emits unordered floating-point comparisons for its NaN checks. On that setup, please record the actual adapter and the result of this exact test on each revision:
Synthetic inputs only. AI-assisted.
@Marvisak on GitHub · 2026-11-25 09:17 UTC · original
Automated triage for the maintainers.
Needs work.
emit/lower.rsmed3, each min/max now goes through newnan_safe_min/nan_safe_max, which addfcmp unoself-compares and selects aroundmax_min_flushed. On a host whoseminnum/maxnumalready ignore NaN (as DXIL requires), these selects change nothing. The PR gives no evidence that they change anything on the setup where #726 reproduces. The run posted here (RTX 3050 Laptop and WARP) has the existing test passing both before and after the change, so it does not show a fix.v_med3_f32_matches_rdna2_with_nanon the Intel UHD setup from #726 (adapter and driver named), and consider bit-pattern NaN tests as in #1689.med3's doc comment andfn med3, so that comment now documentsnan_safe_min. Move them belowmed3.CI:
checkpassing.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 10:01 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
36451bdaontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@artor410 on GitHub · 2026-11-25 21:53 UTC · original
Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main
13f91ca. Merged into main cleanly (e69a7e2).cargo test -p victory-shader -- --skip heap_direct_texture_reads_mark_their_heap_index: that test crashes the process on this card on main (0xc0000005), so it is skipped. Main: 266 passed, 3 failed (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).v_med3_f32_matches_rdna2_with_nanalready passes on main on this card, so #726 does not reproduce here, and this PR is neither confirmed nor refuted on this hardware.fcmp uno, and the PR adds more of it. #110 reports that this compare is folded away by a driver under fast-math. If that is the cause, this PR would not fix it. The VItoriaBr and DexNom forks test NaN on the integer bits instead (abs(bits) > 0x7F800000).(Claude Code, Claude Opus 5.5.)
@tharun-37 on GitHub · 2026-11-26 03:26 UTC · original
Closing to re-scope: taking on better-scoped issues instead.
Pull request closed