tombox-xshader: exact v_cvt_rpi_i32_f32 floor and sign-saturated NaN for rpi/flr #377

Closed
github-bot wants to merge 1 commit from gh-pr/377/head into gh-pr/377/base
Owner

@⁠Ctrl-Alt-Haze on GitHub · 2026-11-24 23:31 UTC · original
Ctrl-Alt-Haze:fix/xshader-374-cvt-rpi-flr-nan → main · +41 −16 · 3 files · 1 commits · closed without merging

Library / area: crates/tombox-xshader (hlsl.rs, tests/exec.rs, tests/isa_sweep/ops_v.rs)

Exports changed (exports.txt rows): none (RDNA2-to-HLSL lowering and tests only)

Source of the behaviour: #374 (gfx1036 hardware measurements referenced from Marvisak/VIctory#605 and xcl-dev/xcl#639 / xcl-dev/xcl#1020, implemented independently in tombox-xshader)

Fixes #374

Summary

  • Added tb_cvt_flr_i(float) and tb_cvt_rpi_i(float) helpers in crates/tombox-xshader/src/hlsl.rs:
    • v_cvt_rpi_i32_f32 now computes r = floor(x); d = x - r; TB_SEL(d >= 0.5, r + 1.0, r) so half-way comparisons use the exact residual rather than single-precision x + 0.5 rounding (0x3EFFFFFF -> 0, 8388609.0 -> 8388609, -8388609.0 -> -8388609).
    • Both v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 saturate NaN inputs by sign bit (0x7FFFFFFF for positive NaN, 0x80000000 for negative NaN, qNaN and sNaN), leaving v_cvt_i32_f32 / v_cvt_u32_f32 NaN -> 0 untouched.
  • Updated crates/tombox-xshader/tests/exec.rs (vector_vop1) with exact f64 floor + signed-NaN expectations and added the edge bit patterns from #374 (0x3EFFFFFF, 0x4B000001, 0x4B000003, 0xCB000001, 0xBF000001, ±qNaN, ±sNaN) plus v_cvt_i32_f32 / v_cvt_u32_f32 NaN checks; removed now-unused cvt_i.
  • Updated crates/tombox-xshader/tests/isa_sweep/ops_v.rs reference model (rpi and v_cvt_flr_i32_f32) to match the signed-NaN and exact-floor behavior.
  • Kept all edited .rs files free of added comment lines.

Tested

Windows 11 x64, MSVC toolchain, DXC, NVIDIA GeForce RTX 5070 Ti + WARP at commit 5ce01d5:

  • python .github/scripts/pr_gate.py --base upstream/main --head HEAD: 3 file(s) checked, 0 problem(s)
  • cargo test -p tombox-xshader --test isa_sweep: 2 passed; 0 failed (isa_sweep: 555 mnemonics, 544 pass, 0 fail, 11 known WARP deviations, 28 skipped)
  • cargo test -p tombox-xshader --test exec -- vector_vop1: 1 passed; 0 failed
  • cargo test -p tombox-xshader -- --test-threads=1: 345 passed; 0 failed; 18 ignored across all test targets (lib: 116 passed / 3 ignored; xshader_prelaunch: 4; centroid: 1; dxc_host: 1; dxc_host_crash: 1; exec: 128 passed / 2 ignored; fmask_identity_warp: 1; gcn_dims: 3; isa_sweep: 2; isa_table: 3; linkage: 3; mesh: 24 passed / 1 ignored; mixed_table: 3; msaa_dim: 1; opcodes: 26; ps_linkage: 1; synthetic: 24; xdxr_console: 1; xshader_cli: 2; ignored-only targets: amp 4, f861_repro 1, fixtures 6, hlsl_determinism 1)
  • Note: default-concurrency cargo test -p tombox-xshader earlier hit transient DXGI_ERROR_DEVICE_REMOVED (0x887a0005) during exec; --test-threads=1 completed cleanly with 0 failures.

Checklist

  • cargo test -p tombox-xshader -- --test-threads=1 passes (345 passed; 0 failed; 18 ignored)
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

AI use: Antigravity (Google DeepMind; exact model version not exposed to agent) implemented the fix, tests, and PR text.

**@⁠Ctrl-Alt-Haze** on GitHub · 2026-11-24 23:31 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/377) `Ctrl-Alt-Haze:fix/xshader-374-cvt-rpi-flr-nan` → `main` · +41 −16 · 3 files · 1 commits · closed without merging **Library / area:** `crates/tombox-xshader` (`hlsl.rs`, `tests/exec.rs`, `tests/isa_sweep/ops_v.rs`) **Exports changed (exports.txt rows):** none (RDNA2-to-HLSL lowering and tests only) **Source of the behaviour:** #374 (gfx1036 hardware measurements referenced from `Marvisak/VIctory#605` and `xcl-dev/xcl#639` / `xcl-dev/xcl#1020`, implemented independently in `tombox-xshader`) Fixes #374 ### Summary - Added `tb_cvt_flr_i(float)` and `tb_cvt_rpi_i(float)` helpers in `crates/tombox-xshader/src/hlsl.rs`: - `v_cvt_rpi_i32_f32` now computes `r = floor(x); d = x - r; TB_SEL(d >= 0.5, r + 1.0, r)` so half-way comparisons use the exact residual rather than single-precision `x + 0.5` rounding (`0x3EFFFFFF` -> `0`, `8388609.0` -> `8388609`, `-8388609.0` -> `-8388609`). - Both `v_cvt_flr_i32_f32` and `v_cvt_rpi_i32_f32` saturate NaN inputs by sign bit (`0x7FFFFFFF` for positive NaN, `0x80000000` for negative NaN, qNaN and sNaN), leaving `v_cvt_i32_f32` / `v_cvt_u32_f32` NaN -> `0` untouched. - Updated `crates/tombox-xshader/tests/exec.rs` (`vector_vop1`) with exact `f64` floor + signed-NaN expectations and added the edge bit patterns from #374 (`0x3EFFFFFF`, `0x4B000001`, `0x4B000003`, `0xCB000001`, `0xBF000001`, ±qNaN, ±sNaN) plus `v_cvt_i32_f32` / `v_cvt_u32_f32` NaN checks; removed now-unused `cvt_i`. - Updated `crates/tombox-xshader/tests/isa_sweep/ops_v.rs` reference model (`rpi` and `v_cvt_flr_i32_f32`) to match the signed-NaN and exact-floor behavior. - Kept all edited `.rs` files free of added comment lines. ### Tested Windows 11 x64, MSVC toolchain, DXC, NVIDIA GeForce RTX 5070 Ti + WARP at commit `5ce01d5`: - `python .github/scripts/pr_gate.py --base upstream/main --head HEAD`: `3 file(s) checked, 0 problem(s)` - `cargo test -p tombox-xshader --test isa_sweep`: `2 passed; 0 failed` (`isa_sweep`: 555 mnemonics, 544 pass, 0 fail, 11 known WARP deviations, 28 skipped) - `cargo test -p tombox-xshader --test exec -- vector_vop1`: `1 passed; 0 failed` - `cargo test -p tombox-xshader -- --test-threads=1`: `345 passed; 0 failed; 18 ignored` across all test targets (`lib`: 116 passed / 3 ignored; `xshader_prelaunch`: 4; `centroid`: 1; `dxc_host`: 1; `dxc_host_crash`: 1; `exec`: 128 passed / 2 ignored; `fmask_identity_warp`: 1; `gcn_dims`: 3; `isa_sweep`: 2; `isa_table`: 3; `linkage`: 3; `mesh`: 24 passed / 1 ignored; `mixed_table`: 3; `msaa_dim`: 1; `opcodes`: 26; `ps_linkage`: 1; `synthetic`: 24; `xdxr_console`: 1; `xshader_cli`: 2; ignored-only targets: `amp` 4, `f861_repro` 1, `fixtures` 6, `hlsl_determinism` 1) - Note: default-concurrency `cargo test -p tombox-xshader` earlier hit transient `DXGI_ERROR_DEVICE_REMOVED` (`0x887a0005`) during `exec`; `--test-threads=1` completed cleanly with 0 failures. ### Checklist - [x] `cargo test -p tombox-xshader -- --test-threads=1` passes (`345 passed; 0 failed; 18 ignored`) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note **AI use:** Antigravity (Google DeepMind; exact model version not exposed to agent) implemented the fix, tests, and PR text.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:20:48 +00:00
github-bot closed this pull request 2026-11-26 06:20:48 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:51 UTC · original

Applied on main in 474314f (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:51 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/377#issuecomment-7164380879) Applied on main in 474314f (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.