Skip to content

Fix #726: NaN-safe v_med3_f32 lowering - #2010

Closed
tharun-37 wants to merge 1 commit into
Marvisak:mainfrom
tharun-37:fix/med3-nan
Closed

tharun-37 wants to merge 1 commit into
Marvisak:mainfrom
tharun-37:fix/med3-nan

Conversation

@tharun-37

Copy link
Copy Markdown

Split 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

Copy link
Copy Markdown
Contributor

The existing v_med3_f32_matches_rdna2_with_nan test runs on Windows. On an RTX 3050 Laptop (driver 610.62) and WARP it passes on both 940d32f and this PR's 36451bd, 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:

cargo test --locked -p victory-shader --lib emit::valu_tests::v_med3_f32_matches_rdna2_with_nan -- --exact --nocapture

Synthetic inputs only. AI-assisted.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed. NaN-safe v_med3_f32 lowering — fixes issue #726. Note: #2000 claimed #726 too (as part of #721/#722/#726); #2009+#2010 split it. Also relates to #1259 (v_med3 -0/+0 ordering) — check the three compose.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work.

CI: check passing.


Generated by Claude Code

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 36451bd onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 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

Copy link
Copy Markdown
Contributor

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).
  • With this PR: 266 passed, same 3 failed. No new test.
  • v_med3_f32_matches_rdna2_with_nan already passes on main on this card, so v_med3_f32 with NaN returns wrong side on NVIDIA (NVIDIA-specific test failure) #726 does not reproduce here, and this PR is neither confirmed nor refuted on this hardware.
  • Note: the NaN detection here is still fcmp uno, and the PR adds more of it. Shaders: use DXIL IsNaN in med3 so Intel Xe does not fold fcmp uno #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

Copy link
Copy Markdown
Author

Closing to re-scope: taking on better-scoped issues instead.

@tharun-37 tharun-37 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants