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

Open
vladbondarenko97 wants to merge 1 commit from upstream-pr/320 into main
vladbondarenko97 commented 2026-11-24 23:32:14 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by vladbondarenko97 on 2026-11-24T23:32:14Z.


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.
  • 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. One finding: WARP's uitofp is not correctly rounded for some u32 ≥ 2^31 (0xffffff7f gives 0x4f800000 = 2^32, not 0x4f7fffff), so WARP gets one ULP on that op with a printed note; hardware stays exact. Port of Marvisak/VIctory#1602 (same author). Tests only.

Tested

  • NVIDIA GeForce RTX 3080 Ti and WARP, Windows 11, on fork main 2119b0e: both new tests pass on both; WARP shows the one-ULP uitofp difference.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.

Not tested

  • AMD and Intel hardware; the full victory-shader suite on this head.

AI use

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593563701 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/320). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-24T23:32:14Z. --- 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. - `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. One finding: WARP's `uitofp` is not correctly rounded for some u32 ≥ 2^31 (`0xffffff7f` gives `0x4f800000` = 2^32, not `0x4f7fffff`), so WARP gets one ULP on that op with a printed note; hardware stays exact. Port of Marvisak/VIctory#1602 (same author). Tests only. **Tested** - NVIDIA GeForce RTX 3080 Ti and WARP, Windows 11, on fork main `2119b0e`: both new tests pass on both; WARP shows the one-ULP `uitofp` difference. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. **Not tested** - AMD and Intel hardware; the full `victory-shader` suite on this head. **AI use** - Claude Code with Claude Opus 5.5 ported the tests, ran them on the hardware above and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HAL9000RELOADED commented 2026-11-25 08:09:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T08:08:32Z.


An AMD run for the "not tested on AMD" note.

Setup: Radeon RX 7900 XTX (RDNA3, waves of 32 to 64 lanes), Adrenalin 32.0.32015.7029, i7-13700KF, Windows 10 Pro 22H2 (19045), Rust 1.98.1. Windows 10's in-box D3D12 stops at SM 6.5, so the tree also carries the D3D12 Agility SDK 1.620 (the same approach as #69). The DXIL validator comes from SDK 10.0.26100 (VICTORY_DXIL). WARP stays below SM 6.6 on this machine, so the GPU cases ran on the card only. No game data used.

Base: main c96b4f2 plus the Agility patch and the stack-headroom test fix from Marvisak/VIctory#742. The PR head d0b8108 was merged on top of it.

v_cvt_f32_i32_u32_and_ubyte_round_to_nearest_even and v_cvt_i32_and_u32_f32_truncate_saturate_and_take_nan_as_zero pass on the card. Only WARP printed "skipped", so the hardware device ran every case. The whole workspace with this PR: 507 passed, 0 failed.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156656677 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/320#issuecomment-7156656677). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T08:08:32Z. --- An AMD run for the "not tested on AMD" note. **Setup:** Radeon RX 7900 XTX (RDNA3, waves of 32 to 64 lanes), Adrenalin 32.0.32015.7029, i7-13700KF, Windows 10 Pro 22H2 (19045), Rust 1.98.1. Windows 10's in-box D3D12 stops at SM 6.5, so the tree also carries the D3D12 Agility SDK 1.620 (the same approach as #69). The DXIL validator comes from SDK 10.0.26100 (`VICTORY_DXIL`). WARP stays below SM 6.6 on this machine, so the GPU cases ran on the card only. No game data used. **Base:** `main` `c96b4f2` plus the Agility patch and the stack-headroom test fix from Marvisak/VIctory#742. The PR head `d0b8108` was merged on top of it. `v_cvt_f32_i32_u32_and_ubyte_round_to_nearest_even` and `v_cvt_i32_and_u32_f32_truncate_saturate_and_take_nan_as_zero` pass on the card. Only WARP printed "skipped", so the hardware device ran every case. The whole workspace with this PR: 507 passed, 0 failed.
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/320:upstream-pr/320'
git switch 'upstream-pr/320'

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/320'
git switch 'upstream-pr/320'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/320'
git switch 'upstream-pr/320'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/320'
git switch 'main'
git merge --squash 'upstream-pr/320'
git switch 'main'
git merge --ff-only 'upstream-pr/320'
git switch 'main'
git merge 'upstream-pr/320'
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
fxceless/victory-fork!320
No description provided.