Shader tests: f32/int conversions saturate, take NaN as 0, round to even #1601

Open
vladbondarenko97 wants to merge 1 commit from upstream-pr/1602 into main
vladbondarenko97 commented 2026-11-24 19:41:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by vladbondarenko97 on 2026-11-24T19:41:34Z.


Adds two synthetic GPU tests in crates/victory-shader/src/emit/valu_tests.rs:

  • v_cvt_i32_f32 / v_cvt_u32_f32: truncation, saturation (infinities too) and NaN as 0, over the integer-range edges, a signalling NaN and a denormal.
  • v_cvt_f32_i32 / v_cvt_f32_u32 / v_cvt_f32_ubyte0..3: nearest-even ties past 2^24, 2^31 and 2^32.

The reference is Rust's as, which matches RDNA2. The lowering relies on the host's fptosi / fptoui / uitofp, and its comment says this was checked on an RX 6700 XT and WARP only; this adds an NVIDIA run. One finding on the way: WARP's uitofp is not correctly rounded for some u32 ≥ 2^31 (0xffffff7f gives 0x4f800000 = 2^32, not 0x4f7fffff), in repeated runs. The RTX 3080 Ti is exact. So WARP (what CI runs) gets one ULP on that op for inputs ≥ 2^31, with a printed note; hardware stays exact. Tests only.

Tested

  • NVIDIA GeForce RTX 3080 Ti and WARP, Windows 11, on main ffe310e: both new tests pass on both.
  • cargo test --workspace --locked (idle GPU): 344 passed, 0 failed, 6 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features: clean.

Not tested

  • AMD and Intel hardware.

AI use

  • Claude Code with Claude Opus 5.5 wrote the tests and this description and ran the tests on the hardware named above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5479084638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1602). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-24T19:41:34Z. --- Adds two synthetic GPU tests in `crates/victory-shader/src/emit/valu_tests.rs`: - `v_cvt_i32_f32` / `v_cvt_u32_f32`: truncation, saturation (infinities too) and NaN as 0, over the integer-range edges, a signalling NaN and a denormal. - `v_cvt_f32_i32` / `v_cvt_f32_u32` / `v_cvt_f32_ubyte0..3`: nearest-even ties past 2^24, 2^31 and 2^32. The reference is Rust's `as`, which matches RDNA2. The lowering relies on the host's `fptosi` / `fptoui` / `uitofp`, and its comment says this was checked on an RX 6700 XT and WARP only; this adds an NVIDIA run. One finding on the way: **WARP's `uitofp` is not correctly rounded for some u32 ≥ 2^31** (`0xffffff7f` gives `0x4f800000` = 2^32, not `0x4f7fffff`), in repeated runs. The RTX 3080 Ti is exact. So WARP (what CI runs) gets one ULP on that op for inputs ≥ 2^31, with a printed note; hardware stays exact. Tests only. **Tested** - NVIDIA GeForce RTX 3080 Ti and WARP, Windows 11, on `main` `ffe310e`: both new tests pass on both. - `cargo test --workspace --locked` (idle GPU): 344 passed, 0 failed, 6 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and with `--all-features`: clean. **Not tested** - AMD and Intel hardware. **AI use** - Claude Code with Claude Opus 5.5 wrote the tests and this description and ran the tests on the hardware named above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Calvix2k commented 2026-11-24 21:28:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:13:36Z.


Hardware run of the two new tests on head 94a2e99, since the PR asks for a non-WARP reference:

  • Machine: Windows 10 x64, Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), Rust 1.98.1 MSVC.
  • The system D3D12 runtime here reports SM 6.5, so the test binary was opted into the Agility SDK runtime 1.616 locally (D3D12Core.dll plus the two exports; not part of the repo) to reach SM 6.6.
  • cargo test -p victory-shader --locked v_cvt_ -- --test-threads=1 --nocapture — 4 passed, 0 failed (the two new tests plus the existing v_cvt_norm_* pair).
    • v_cvt_i32_and_u32_f32_truncate_saturate_and_take_nan_as_zero: passed on hardware.
    • v_cvt_f32_i32_u32_and_ubyte_round_to_nearest_even: passed on hardware, including the tie cases past 2^24/2^31/2^32.
  • WARP was skipped: it stays at SM 6.2 on this machine even with the Agility runtime, so I could not reproduce the WARP uitofp rounding note here. The hardware side agrees with the expectations.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7144646963 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1602#issuecomment-7144646963). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:13:36Z. --- Hardware run of the two new tests on head 94a2e99, since the PR asks for a non-WARP reference: - **Machine:** Windows 10 x64, Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), Rust 1.98.1 MSVC. - The system D3D12 runtime here reports SM 6.5, so the test binary was opted into the Agility SDK runtime 1.616 locally (`D3D12Core.dll` plus the two exports; not part of the repo) to reach SM 6.6. - `cargo test -p victory-shader --locked v_cvt_ -- --test-threads=1 --nocapture` — **4 passed, 0 failed** (the two new tests plus the existing `v_cvt_norm_*` pair). - `v_cvt_i32_and_u32_f32_truncate_saturate_and_take_nan_as_zero`: passed on hardware. - `v_cvt_f32_i32_u32_and_ubyte_round_to_nearest_even`: passed on hardware, including the tie cases past 2^24/2^31/2^32. - WARP was skipped: it stays at SM 6.2 on this machine even with the Agility runtime, so I could not reproduce the WARP `uitofp` rounding note here. The hardware side agrees with the expectations.
Marvisak commented 2026-11-25 02:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:31:51Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149651595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1602#issuecomment-7149651595). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:31:51Z. --- <!-- victory-triage v1 head=94a2e994f9d296c2b823b4ffe21fc0a43f149542 verdict=needs-rebase at=2026-11-25T01:31:50Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
catminou4 commented 2026-11-25 03:39:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:39:24Z.

Review: COMMENTED


Shader tests: f32/int conversions saturate, NaN as 0, round to even — merge conflict with main (940d32f69b), verified locally. Conversion-semantics tests are valuable; rebase needed and I will re-run.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051513344 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1602#pullrequestreview-6051513344). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:39:24Z. **Review:** COMMENTED --- Shader tests: f32/int conversions saturate, NaN as 0, round to even — merge conflict with main (940d32f69b), verified locally. Conversion-semantics tests are valuable; rebase needed and I will re-run.
noobezlol commented 2026-11-27 07:17:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by noobezlol on 2026-11-27T07:17:14Z.


Opened #3479 with the remaining v_cvt_f32_i32 rounding midpoint tests rebased onto current main (with co-author credit to @vladbondarenko97).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212325250 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1602#issuecomment-7212325250). Originally posted by [noobezlol](https://github.com/noobezlol) on 2026-11-27T07:17:14Z. --- Opened #3479 with the remaining `v_cvt_f32_i32` rounding midpoint tests rebased onto current `main` (with co-author credit to @vladbondarenko97).
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/1602:upstream-pr/1602'
git switch 'upstream-pr/1602'

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/1602'
git switch 'upstream-pr/1602'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1602'
git switch 'upstream-pr/1602'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1602'
git switch 'main'
git merge --squash 'upstream-pr/1602'
git switch 'main'
git merge --ff-only 'upstream-pr/1602'
git switch 'main'
git merge 'upstream-pr/1602'
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
Marvisak/VIctory!1601
No description provided.