d3d12/shader: fix clippy warnings in valu_tests IEEE-754 comparisons #3360

Open
wagney wants to merge 1 commit from upstream-pr/3360 into main
wagney commented 2026-12-03 16:21:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by wagney on 2026-12-03T16:21:27Z.


Claim: D3D12-SHADER-VALU-TESTS-CLIPPY (#3312)

Summary

Clears the 6 remaining cargo clippy --workspace --all-targets --locked -- -D warnings warnings on main in d3d12/crates/leonida-shader/src/emit/valu_tests.rs (float_compares_with_nan_on_the_device) without altering IEEE-754 NaN semantics:

  • 0x5 (v_cmp_lg_f32): a < b || a > b -> !nan && a != b (avoids clippy::double_comparisons, while keeping false when either operand is NaN)
  • 0x9 (v_cmp_nge_f32): !(a >= b) -> nan || a < b
  • 0xa (v_cmp_nlg_f32): !(a < b || a > b) -> nan || a == b
  • 0xb (v_cmp_ngt_f32): !(a > b) -> nan || a <= b
  • 0xc (v_cmp_nle_f32): !(a <= b) -> nan || a > b
  • 0xe (v_cmp_nlt_f32): !(a < b) -> nan || a >= b

Verification

  • cargo clippy --offline --workspace --all-targets --locked -- -D warnings in d3d12/: exited 0 (0 warnings across all workspace crates and targets).
  • cargo test --offline --locked -p leonida-shader --lib float_compares_with_nan_on_the_device: 1 passed, 0 failed.

AI Disclosure

  • AI-assisted using Gemini 4 Hydrogen (Medium) for implementation and an independent read-only reviewer subagent (Gemini Pro) for diff/IEEE-754/clean-room audit (Verdict: APPROVED).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5630452954 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3360). Originally posted by [wagney](https://github.com/wagney) on 2026-12-03T16:21:27Z. --- Claim: `D3D12-SHADER-VALU-TESTS-CLIPPY` (#3312) ### Summary Clears the 6 remaining `cargo clippy --workspace --all-targets --locked -- -D warnings` warnings on `main` in `d3d12/crates/leonida-shader/src/emit/valu_tests.rs` (`float_compares_with_nan_on_the_device`) without altering IEEE-754 `NaN` semantics: - `0x5` (`v_cmp_lg_f32`): `a < b || a > b` -> `!nan && a != b` (avoids `clippy::double_comparisons`, while keeping `false` when either operand is `NaN`) - `0x9` (`v_cmp_nge_f32`): `!(a >= b)` -> `nan || a < b` - `0xa` (`v_cmp_nlg_f32`): `!(a < b || a > b)` -> `nan || a == b` - `0xb` (`v_cmp_ngt_f32`): `!(a > b)` -> `nan || a <= b` - `0xc` (`v_cmp_nle_f32`): `!(a <= b)` -> `nan || a > b` - `0xe` (`v_cmp_nlt_f32`): `!(a < b)` -> `nan || a >= b` ### Verification - `cargo clippy --offline --workspace --all-targets --locked -- -D warnings` in `d3d12/`: exited 0 (0 warnings across all workspace crates and targets). - `cargo test --offline --locked -p leonida-shader --lib float_compares_with_nan_on_the_device`: 1 passed, 0 failed. ### AI Disclosure - AI-assisted using Gemini 4 Hydrogen (Medium) for implementation and an independent read-only reviewer subagent (Gemini Pro) for diff/IEEE-754/clean-room audit (**Verdict: APPROVED**).
Kal0s-design commented 2026-12-03 17:14:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-03T17:14:37Z.


Ran natively on Windows 11, head 5f98ad6f8 merged into current main (717b90233, clean merge).

No findings.

check main merge
cargo clippy -p leonida-shader --all-targets -- -D warnings 6 errors, all in valu_tests.rs lines 1065-1074 clean
cargo clippy --workspace --all-targets -- -D warnings (in d3d12/) (not run) clean
float_compares_with_nan_on_the_device pass pass

The test ran on both the hardware D3D12 device and WARP (no "skipped" line with --nocapture). Each rewritten arm is the same predicate for NaN and non-NaN inputs, including 0.0 vs -0.0 for 0xa (read).

Not checked: the rest of the leonida-shader tests.

GPUs tested: one NVIDIA desktop card.
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7386195779 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3360#issuecomment-7386195779). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-03T17:14:37Z. --- Ran natively on Windows 11, head `5f98ad6f8` merged into current `main` (`717b90233`, clean merge). No findings. | check | `main` | merge | |---|---|---| | `cargo clippy -p leonida-shader --all-targets -- -D warnings` | 6 errors, all in `valu_tests.rs` lines 1065-1074 | clean | | `cargo clippy --workspace --all-targets -- -D warnings` (in `d3d12/`) | (not run) | clean | | `float_compares_with_nan_on_the_device` | pass | pass | The test ran on both the hardware D3D12 device and WARP (no "skipped" line with `--nocapture`). Each rewritten arm is the same predicate for NaN and non-NaN inputs, including `0.0` vs `-0.0` for `0xa` (read). Not checked: the rest of the `leonida-shader` tests. GPUs tested: one NVIDIA desktop card. AI-assisted: yes (Claude Code).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3360:upstream-pr/3360'
git switch 'upstream-pr/3360'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3360'
git switch 'upstream-pr/3360'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3360'
git switch 'upstream-pr/3360'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3360'
git switch 'main'
git merge --squash 'upstream-pr/3360'
git switch 'main'
git merge --ff-only 'upstream-pr/3360'
git switch 'main'
git merge 'upstream-pr/3360'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3360
No description provided.