Repository navigation
Shaders: pack half FMA NaNs directly - #2943
Ingenioeren wants to merge 3 commits into
Conversation
|
Code review and RTX 5090 + WARP + DXIL verification at head
|
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::valu_tests::v_fma_f16: 1 passed, 1 failed — the new testv_fma_f16_quiets_nansfails on NVIDIA RTX 5090 hardware:(assertion `left == right` failed: hardware case 0 with [00007c35, 00003c00, 00000000, 00000000]: got 0x00007fff, expected 0x00007e35v_fma_f16_rounds_once_and_preserves_other_halfpassed.)cargo test -p victory-shader --lib emit::lower::tests::f16_fma_packs_nan_without_a_second_rounding_path: 1 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
The lowering refactor (narrow16_nan replacing the narrow16 fallback in fma16) is clean and preserves narrow16's exact behavior, but the new test asserts an exact NaN payload (0x7e35), whereas NVIDIA hardware canonicalizes f32 FMA NaN outputs to 0x7fff_ffff (0x7fff after narrow16_nan), causing v_fma_f16_quiets_nans to fail on NVIDIA GPUs. Testing for a quiet NaN ((low & 0x7E00) == 0x7E00) and preserving the upper half (while optionally asserting exact payload only on WARP, or matching how semantics_tests treats NaNs) would keep the test portable across NVIDIA hardware.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @fuzeofficlal and @Dukestar69, for testing this on the RTX 5090 and reporting the NaN mismatch. In The NaN test passed on the AMD Radeon RX 6750 XT and WARP. All 36 targeted shader tests passed, along with Clippy and the asset policy check. We did not test on NVIDIA. |
|
Automated triage for the maintainers. Merge candidate. The full CI: passing. Generated by Claude Code |
The software nearest-even lowering of
v_fma_f16used the full f32-to-f16 rounding sequence as its NaN fallback. The fallback is selected only for NaNs, so it can pack the quiet bit and upper payload bits directly. The fused operation reuses the sign it already computed and shares the NaN packing code with the general conversion.v_fma_f16with runtime operandsThe count includes the shader's input and output instructions and uses the bitcode writer's live instruction layout. The regression fails at 118 with the old fallback and passes with a budget of 78 after the change. The test-only
Module::written_instructions()counter is the same helper as in open PR #2893, and whichever PR lands second will drop its copy on rebase. The open PR search for"fma_f16" "payload"found no duplicate of this change.Validation
cargo test --locked --offline -p victory-shaderon63bcca4gave 300 passed, 2 failed, 3 ignored. After the change it gave 302 passed, 2 failed, 3 ignored. Both runs had the same localdxil.dllpipeline-state validation failures inrectangles_get_their_fourth_cornerandelements_sharing_a_row_keep_their_order.cargo test --locked --offline -p victory-shader f16_fma_packs_nan_without_a_second_rounding_pathfailed at 118 instructions with the old fallback. The regression passed in the full run with the new lowering.cargo test --locked --offline -p victory-shader v_fma_f16 -- --nocapturepassed both GPU tests. The existing test covered rounding and preservation of the other half on the Radeon RX 6750 XT. The NaN test asserts the exact 32-bit results, in case order,0x00007E35,0x0000FE42,0x0000FE00,0x0000FE35, and0xABCD7E35. Theorigin/mainlowering and this branch produced identical results on the Radeon RX 6750 XT and WARP, including the negative signaling NaN and the preserved upper destination half.cargo test --locked --offline -p victory-shader --test resource_trackinggave 3 passed and 1 ignored.cargo test --locked --offline -p victory-shader --doccompleted with zero doc tests.cargo clippy --locked --offline -p victory-shader --all-targetspassed.cargo run --locked --offline -p xtask -- policy --stagedpassed for all three files in the original commit and for the staged test update in this revision.No game run or game shaders were used. GPU execution time was not measured.
AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.