Recompiler: v_cvt_rpi rounds the exact x + 0.5; v_cvt_rpi / v_cvt_flr saturate NaN by sign #1013

Open
upipibi wants to merge 2 commits from upstream-pr/1020 into main
upipibi commented 2026-11-24 10:26:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T10:26:47Z.


Branch fix/cvt-rpi-flr, commit 7aa6682 (on e50836b). AI-assisted (Claude Code).

The hardware result

Measured on RDNA2 silicon (gfx1036), identical in all four FLOAT_MODE settings:
https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580

  • v_cvt_rpi_i32_f32 is the floor of the exact x + 0.5. XCL emitted floor(x + 0.5f), which rounds the sum first: 0.49999997 (0x3EFFFFFF) gave 1 instead of 0, 2^23 + 1 gave 2^23 + 2, and 2^24 - 1 gave 2^24.
  • v_cvt_rpi_i32_f32 and v_cvt_flr_i32_f32 give 0x7FFFFFFF for a positive NaN and 0x80000000 for a negative NaN, quiet or signalling. XCL gave 0. v_cvt_i32_f32 keeps giving 0 for any NaN, as before.

The fix

emit.rs: two helpers in the prelude, cvt_rpi and cvt_flr.

  • cvt_rpi takes floor(x) and adds 1 when x - floor(x) >= 0.5. Both operations are exact in f32. This only applies below 2^23, because from 2^23 up every f32 is already an integer.
  • nan_by_sign saturates a NaN based on its sign bit.
  • A flr of a negative denormal depends on the denormal mode, so it is left as XCL already treats denormals. The test does not cover it.

Test

gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign (crates/xcl/src/gpu/recomp/tests.rs) runs 16 rows of the measured table through rpi, flr and i32 across 64 lanes and compares bits.

  • On main e50836b it fails with 13 mismatches.
  • On the branch it passes.

New commit 0f69a2f, for Foniass's request (https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7300943776): the direct-DXIL lowering (dxil/lower_valu.rs, helpers cvt_rpi, cvt_flr, nan_by_sign in dxil/prelude.rs) now does what the HLSL path does: rpi = floor(x) + 1 when x - floor(x) >= 0.5 below 2^23, and a NaN gives 0x7FFFFFFF or 0x80000000 by its sign. gpu_f32_math_and_bit_scans_random had flr(NaN) = 0 in its reference, which is now by sign, as measured on RDNA2 for this PR.

Tested

At the current head 0f69a2f (rebased onto main e99b0bd on 2026-12-03): NVIDIA GeForce RTX 3070, driver 621.40, Windows 11 Pro, rustc 1.100.0, debug.

  • cargo test -p xcl --lib -- --test-threads=4 (default, direct backend): 2864 passed, 0 failed, 37 ignored
  • gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign, gpu_f32_math_and_bit_scans_random, gpu_mullit_and_cvt_off_match_rdna2, 3 runs each with XCL_DIRECT_DXIL=0 and =1: 3 passed, 0 failed every run.
  • Red on the direct path (the new lower_valu.rs change taken out, main's floor(x + 0.5) and NaN -> 0 back): XCL_DIRECT_DXIL=1 0 passed, 2 failed; the rpi/flr test fails on its 13 direct rows (NaN rows give 0; rpi(0x3EFFFFFF) gives 1; rpi of 0x4B000001, 0x4B000003, 0x4B7FFFFF, 0xCB000001 off by one).

Earlier, at 7aa6682:

RTX 3070, driver 616.56, Windows 11. Each branch has its own target dir.

  • Branch, cargo test --workspace --no-fail-fast -- --test-threads=4: 705 passed, 0 failed, 41 ignored, with the usual two no-wave64 skips.
  • main e50836b, same command: 704 passed, 0 failed, 41 ignored.

Two earlier full runs on the branch, made right after the disk filled and was cleaned up, each failed the same three hle::d3d12x tests. On rerun they did not come back:

  • 3 back-to-back hle::d3d12x:: runs: 105/105 each time.
  • 3 lib runs: clean.
  • 2 workspace runs: clean.

The root failure is placed_title_textures_share_vram_and_preserve_pixels (title_textures.rs:1897, "cubemap extra_pages must be reused at same va"). The other two failures are PoisonErrors from the shared lock that this test's panic left poisoned. That test depends on global VRAM allocator state, and this change does not touch that code. It is worth reporting as a separate flake finding.

Regression run

The pair below is for the earlier head 7aa6682, before the 2026-12-03 rebase; a pair on 0f69a2f is needed.

From Kalmarv's run (https://github.com/ivall/xcl/pull/1020#issuecomment-7137388571), thanks:

main:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1271 (PresentX 1271)
presents per 2 s (last 3): 17 34 21
device removals: 0
crashes: 0
peak commit: 27590 MB

PR:

xcl-smoke v1
commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1182 (PresentX 1182)
presents per 2 s (last 3): 2 11 16
device removals: 0
crashes: 0
peak commit: 26659 MB

Not tested

  • Retail titles; AMD hardware (the expected values are the RDNA2 measurement cited in the test, not a run of this code on AMD).
  • v_cvt_flr of a negative denormal: it depends on the float mode (0 flushed, -1 kept), so it stays as XCL already treats denormals and isn't tested.

AI use

  • AI-assisted (Claude Code): checked the hardware reports against the code, wrote the fix, the test and this description, and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5470384179 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1020). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T10:26:47Z. --- Branch `fix/cvt-rpi-flr`, commit `7aa6682` (on `e50836b`). AI-assisted (Claude Code). ## The hardware result Measured on RDNA2 silicon (gfx1036), identical in all four FLOAT_MODE settings: https://github.com/Marvisak/VIctory/pull/605#issuecomment-7123302580 - `v_cvt_rpi_i32_f32` is the floor of the **exact** x + 0.5. XCL emitted `floor(x + 0.5f)`, which rounds the sum first: 0.49999997 (`0x3EFFFFFF`) gave 1 instead of 0, 2^23 + 1 gave 2^23 + 2, and 2^24 - 1 gave 2^24. - `v_cvt_rpi_i32_f32` and `v_cvt_flr_i32_f32` give `0x7FFFFFFF` for a positive NaN and `0x80000000` for a negative NaN, quiet or signalling. XCL gave 0. `v_cvt_i32_f32` keeps giving 0 for any NaN, as before. ## The fix `emit.rs`: two helpers in the prelude, `cvt_rpi` and `cvt_flr`. - `cvt_rpi` takes `floor(x)` and adds 1 when `x - floor(x) >= 0.5`. Both operations are exact in f32. This only applies below 2^23, because from 2^23 up every f32 is already an integer. - `nan_by_sign` saturates a NaN based on its sign bit. - A `flr` of a negative denormal depends on the denormal mode, so it is left as XCL already treats denormals. The test does not cover it. ## Test `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign` (`crates/xcl/src/gpu/recomp/tests.rs`) runs 16 rows of the measured table through rpi, flr and i32 across 64 lanes and compares bits. - On `main` `e50836b` it fails with 13 mismatches. - On the branch it passes. New commit 0f69a2f, for Foniass's request (https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7300943776): the direct-DXIL lowering (`dxil/lower_valu.rs`, helpers `cvt_rpi`, `cvt_flr`, `nan_by_sign` in `dxil/prelude.rs`) now does what the HLSL path does: rpi = floor(x) + 1 when x - floor(x) >= 0.5 below 2^23, and a NaN gives 0x7FFFFFFF or 0x80000000 by its sign. `gpu_f32_math_and_bit_scans_random` had `flr(NaN) = 0` in its reference, which is now by sign, as measured on RDNA2 for this PR. **Tested** At the current head 0f69a2f (rebased onto `main` e99b0bd on 2026-12-03): NVIDIA GeForce RTX 3070, driver 621.40, Windows 11 Pro, rustc 1.100.0, debug. - `cargo test -p xcl --lib -- --test-threads=4` (default, direct backend): 2864 passed, 0 failed, 37 ignored - `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign`, `gpu_f32_math_and_bit_scans_random`, `gpu_mullit_and_cvt_off_match_rdna2`, 3 runs each with `XCL_DIRECT_DXIL=0` and `=1`: 3 passed, 0 failed every run. - Red on the direct path (the new `lower_valu.rs` change taken out, `main`'s floor(x + 0.5) and NaN -> 0 back): `XCL_DIRECT_DXIL=1` 0 passed, 2 failed; the rpi/flr test fails on its 13 direct rows (NaN rows give 0; rpi(0x3EFFFFFF) gives 1; rpi of 0x4B000001, 0x4B000003, 0x4B7FFFFF, 0xCB000001 off by one). Earlier, at 7aa6682: RTX 3070, driver 616.56, Windows 11. Each branch has its own target dir. - Branch, `cargo test --workspace --no-fail-fast -- --test-threads=4`: **705 passed, 0 failed, 41 ignored**, with the usual two no-wave64 skips. - `main` `e50836b`, same command: 704 passed, 0 failed, 41 ignored. Two earlier full runs on the branch, made right after the disk filled and was cleaned up, each failed the same three `hle::d3d12x` tests. On rerun they did not come back: - 3 back-to-back `hle::d3d12x::` runs: 105/105 each time. - 3 lib runs: clean. - 2 workspace runs: clean. The root failure is `placed_title_textures_share_vram_and_preserve_pixels` (`title_textures.rs:1897`, "cubemap extra_pages must be reused at same va"). The other two failures are `PoisonError`s from the shared lock that this test's panic left poisoned. That test depends on global VRAM allocator state, and this change does not touch that code. It is worth reporting as a separate flake finding. **Regression run** The pair below is for the earlier head 7aa6682, before the 2026-12-03 rebase; a pair on 0f69a2f is needed. From Kalmarv's run (https://github.com/ivall/xcl/pull/1020#issuecomment-7137388571), thanks: main: ``` xcl-smoke v1 commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1271 (PresentX 1271) presents per 2 s (last 3): 17 34 21 device removals: 0 crashes: 0 peak commit: 27590 MB ``` PR: ``` xcl-smoke v1 commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1182 (PresentX 1182) presents per 2 s (last 3): 2 11 16 device removals: 0 crashes: 0 peak commit: 26659 MB ``` **Not tested** - Retail titles; AMD hardware (the expected values are the RDNA2 measurement cited in the test, not a run of this code on AMD). - `v_cvt_flr` of a negative denormal: it depends on the float mode (0 flushed, -1 kept), so it stays as XCL already treats denormals and isn't tested. **AI use** - AI-assisted (Claude Code): checked the hardware reports against the code, wrote the fix, the test and this description, and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 11:06:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T11:04:12Z.


Independent verification on the hardware the measurements came from.

Machine: Windows 11, Ryzen 9 7900X with Radeon iGPU (gfx1036, RDNA2, native wave64), NVIDIA RTX 3060 Ti also present; Rust stable MSVC, debug build of head 7aa6682.

  • XCL_ADAPTER=radeon cargo test -p xcl --lib gpu_cvt_rpi_flr: 1 passed — gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign runs on the Radeon (a bogus XCL_ADAPTER value prints SKIPPED ... no GPU, so the pass is a real GPU run).
  • Same test with the default adapter (RTX 3060 Ti): 1 passed.
  • XCL_ADAPTER=radeon cargo test -p xcl --lib recomp -- --test-threads=4: 187 passed, 0 failed, 18 ignored (the ignored ones are the XCL_SAMPLE_* retail-survey tests; GPU wave64 tests ran and passed).

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7129614652 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1020#issuecomment-7129614652). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T11:04:12Z. --- Independent verification on the hardware the measurements came from. **Machine:** Windows 11, Ryzen 9 7900X with Radeon iGPU (gfx1036, RDNA2, native wave64), NVIDIA RTX 3060 Ti also present; Rust stable MSVC, debug build of head `7aa6682`. - `XCL_ADAPTER=radeon cargo test -p xcl --lib gpu_cvt_rpi_flr`: **1 passed** — `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign` runs on the Radeon (a bogus `XCL_ADAPTER` value prints `SKIPPED ... no GPU`, so the pass is a real GPU run). - Same test with the default adapter (RTX 3060 Ti): **1 passed**. - `XCL_ADAPTER=radeon cargo test -p xcl --lib recomp -- --test-threads=4`: **187 passed, 0 failed, 18 ignored** (the ignored ones are the `XCL_SAMPLE_*` retail-survey tests; GPU wave64 tests ran and passed). AI use: test runs by Devin (Cognition, SWE-2); no code changes.
4usphs commented 2026-11-24 12:05:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T11:23:34Z.


AMD run for Not tested: the fix on RDNA2 (gfx1036, the console's generation) and RDNA4 through XCL's own D3D12 path, plus the test's 16 expected rows checked directly against both chips. It passes everywhere.

Tested: this PR's head 7aa6682 merged onto main 47efa2e (local merge, no conflicts). Ryzen 7 9800X3D with its Radeon iGPU (gfx1036, RDNA2, driver 32.0.21045.29003) and an RX 9070 XT (gfx1201, RDNA4, driver 32.0.32029.2010), Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug. XCL_ADAPTER=Radeon(TM) or XCL_ADAPTER=9070 picks the GPU (backend 'real' – AMD Radeon(TM) Graphics (485 MiB VRAM) / AMD Radeon RX 9070 XT).

RDNA2 iGPU RX 9070 XT
gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign (XCL_REQUIRE_GPU=wave64) 3 / 3 passed 3 / 3 passed
cargo test --workspace --no-fail-fast -- --test-threads=4 742 passed, 0 failed, 41 ignored, 0 SKIPPED 742 passed, 0 failed, 41 ignored, 0 SKIPPED
  • Negative control on the RDNA2 iGPU: with only this PR's emit.rs change reverted, the new test fails with the same 13 mismatches as on your RTX 3070. These are rpi(0x3EFFFFFF) = 1, rpi(0x4B000001) = 0x00800002, rpi(0x4B7FFFFF) = 0x01000000, rpi(0xCB000001) = 0xFF800000, and rpi / flr of the four NaNs = 0.
  • The expected values themselves: I ran the 16 inputs of ROWS through v_cvt_rpi_i32_f32, v_cvt_flr_i32_f32 and v_cvt_i32_f32 as inline assembly in OpenCL on the same two chips (the #518 / #772 method, wave32 and wave64). All 96 results equal the table on both. This agrees with my #639 measurement on the same iGPU: https://github.com/ivall/xcl/pull/639#issuecomment-7127563021. That also covers MODE.IEEE / DX10_CLAMP, which change none of these results.

Not tested: smoke or a retail title (no title here), a release build, the console itself (gfx1036 is a desktop RDNA2 APU of the same generation), flr of negative denormals.

AI use: Claude Code (Claude Opus 5.5) ran the suites, the control and the OpenCL check on my PC and wrote this comment. I have not reviewed the code.

<!-- greyfinch-sync:ivall/xcl:comment:7130037222 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1020#issuecomment-7130037222). Originally posted by [4usphs](https://github.com/4usphs) on 2026-11-24T11:23:34Z. --- AMD run for **Not tested**: the fix on RDNA2 (`gfx1036`, the console's generation) and RDNA4 through XCL's own D3D12 path, plus the test's 16 expected rows checked directly against both chips. It passes everywhere. **Tested:** this PR's head `7aa6682` merged onto `main` `47efa2e` (local merge, no conflicts). Ryzen 7 9800X3D with its Radeon iGPU (`gfx1036`, RDNA2, driver 32.0.21045.29003) and an RX 9070 XT (`gfx1201`, RDNA4, driver 32.0.32029.2010), Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug. `XCL_ADAPTER=Radeon(TM)` or `XCL_ADAPTER=9070` picks the GPU (`backend 'real' – AMD Radeon(TM) Graphics (485 MiB VRAM)` / `AMD Radeon RX 9070 XT`). | | RDNA2 iGPU | RX 9070 XT | |---|---|---| | `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign` (`XCL_REQUIRE_GPU=wave64`) | 3 / 3 passed | 3 / 3 passed | | `cargo test --workspace --no-fail-fast -- --test-threads=4` | **742 passed, 0 failed, 41 ignored**, 0 `SKIPPED` | **742 passed, 0 failed, 41 ignored**, 0 `SKIPPED` | - **Negative control on the RDNA2 iGPU:** with only this PR's `emit.rs` change reverted, the new test fails with the same 13 mismatches as on your RTX 3070. These are `rpi(0x3EFFFFFF) = 1`, `rpi(0x4B000001) = 0x00800002`, `rpi(0x4B7FFFFF) = 0x01000000`, `rpi(0xCB000001) = 0xFF800000`, and `rpi` / `flr` of the four NaNs = 0. - **The expected values themselves:** I ran the 16 inputs of `ROWS` through `v_cvt_rpi_i32_f32`, `v_cvt_flr_i32_f32` and `v_cvt_i32_f32` as inline assembly in OpenCL on the same two chips (the #518 / #772 method, wave32 and wave64). All 96 results equal the table on both. This agrees with my #639 measurement on the same iGPU: https://github.com/ivall/xcl/pull/639#issuecomment-7127563021. That also covers MODE.IEEE / DX10_CLAMP, which change none of these results. **Not tested:** smoke or a retail title (no title here), a release build, the console itself (`gfx1036` is a desktop RDNA2 APU of the same generation), `flr` of negative denormals. **AI use:** Claude Code (Claude Opus 5.5) ran the suites, the control and the OpenCL check on my PC and wrote this comment. I have not reviewed the code.
DavidM1911 commented 2026-11-24 12:05:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T11:29:59Z.


Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

  • cargo test -p xcl --lib recomp: 189 passed, 0 failed, 18 ignored — includes the new v_cvt_rpi/v_cvt_flr NaN-by-sign cases. The generated cvt_rpi/cvt_flr HLSL helpers look correct: NaN saturates by sign via nan_by_sign, rpi avoids the x + 0.5f double-rounding by comparing x - floor(x) >= 0.5f exactly, and the < 2^23 guard keeps fl + 1 exact.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7130175783 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1020#issuecomment-7130175783). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T11:29:59Z. --- Independent verification, merged onto current `main` `384f7f7` locally (clean merge). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug. - `cargo test -p xcl --lib recomp`: **189 passed, 0 failed, 18 ignored** — includes the new `v_cvt_rpi`/`v_cvt_flr` NaN-by-sign cases. The generated `cvt_rpi`/`cvt_flr` HLSL helpers look correct: NaN saturates by sign via `nan_by_sign`, `rpi` avoids the `x + 0.5f` double-rounding by comparing `x - floor(x) >= 0.5f` exactly, and the `< 2^23` guard keeps `fl + 1` exact. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Kalmarv commented 2026-11-24 17:06:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T16:16:13Z.


Regression pair for 7aa6682 against main e50836b (this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 93 % of main's frames, 97 % of its peak commit.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200.
  • scripts/smoke.ps1, the same retail title for 60 s each: main at e50836b (this PR's base, 67 commits behind today's main) first, then this PR's head, one after the other on the same machine.

main e50836b:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1271 (PresentX 1271)
presents per 2 s (last 3): 17 34 21
device removals: 0
crashes: 0
peak commit: 27590 MB

this PR, 7aa6682:

xcl-smoke v1
commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1182 (PresentX 1182)
presents per 2 s (last 3): 2 11 16
device removals: 0
crashes: 0
peak commit: 26659 MB

Presents per 2 s over the whole run (from the activity (2 s) lines):

  • main: 0 26 57 54 35 52 60 60 60 60 60 60 60 60 59 45 53 60 60 60 51 52 31 7 4 6 7 17 34 21
  • PR: 0 19 59 34 37 48 60 52 60 61 60 60 59 60 60 49 46 60 60 60 57 46 37 7 2 0 0 2 11 16

The first 44 s are close (1107 frames against 1144). Most of the 89-frame gap is a slow phase from about 44 s that both runs have, which lasted longer in the PR's run (75 frames in the last 16 s against 127). On #1244 today the same slow phase gave one pair 87 % and the next 103 %, so one pair can't separate this from run-to-run spread.

Addendum: the same pair in the other order. Run as one job, this PR's head first and main e50836b (this PR's base) right after, same machine and setup:

this PR, 7aa6682, run first:

xcl-smoke v1
commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1232 (PresentX 1232)
presents per 2 s (last 3): 37 6 14
device removals: 0
crashes: 0
peak commit: 28829 MB

main e50836b, run second:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1252 (PresentX 1252)
presents per 2 s (last 3): 18 35 8
device removals: 0
crashes: 0
peak commit: 28499 MB

This PR has 98 % of main's frames here (1232 / 1252), against 93 % with main first, so the 93 % above was mostly run-to-run spread rather than this change.

Not tested

  • Whether the title's programs in these 60 s use v_cvt_rpi / v_cvt_flr on values the change affects: not counted.
  • World loading: a 60 s run ends before it.
  • AMD.

AI use: Claude Code (Claude Opus 5.5)

<!-- greyfinch-sync:ivall/xcl:comment:7137388571 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1020#issuecomment-7137388571). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-24T16:16:13Z. --- Regression pair for `7aa6682` against `main` `e50836b` (this PR's base), for the **Regression run** section. Both runs pass: no device removal, no crash, 93 % of `main`'s frames, 97 % of its peak commit. **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200. - `scripts/smoke.ps1`, the same retail title for 60 s each: `main` at `e50836b` (this PR's base, 67 commits behind today's `main`) first, then this PR's head, one after the other on the same machine. `main` `e50836b`: ``` xcl-smoke v1 commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: NVIDIA GeForce RTX 5070 Ti title: GTA VI seconds: 60 exit: 0x0 frames shown: 1271 (PresentX 1271) presents per 2 s (last 3): 17 34 21 device removals: 0 crashes: 0 peak commit: 27590 MB ``` this PR, `7aa6682`: ``` xcl-smoke v1 commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f gpu: NVIDIA GeForce RTX 5070 Ti title: GTA VI seconds: 60 exit: 0x0 frames shown: 1182 (PresentX 1182) presents per 2 s (last 3): 2 11 16 device removals: 0 crashes: 0 peak commit: 26659 MB ``` Presents per 2 s over the whole run (from the `activity (2 s)` lines): - `main`: 0 26 57 54 35 52 60 60 60 60 60 60 60 60 59 45 53 60 60 60 51 52 31 7 4 6 7 17 34 21 - PR: 0 19 59 34 37 48 60 52 60 61 60 60 59 60 60 49 46 60 60 60 57 46 37 7 2 0 0 2 11 16 The first 44 s are close (1107 frames against 1144). Most of the 89-frame gap is a slow phase from about 44 s that both runs have, which lasted longer in the PR's run (75 frames in the last 16 s against 127). On #1244 today the same slow phase gave one pair 87 % and the next 103 %, so one pair can't separate this from run-to-run spread. **Addendum: the same pair in the other order.** Run as one job, this PR's head first and `main` `e50836b` (this PR's base) right after, same machine and setup: this PR, `7aa6682`, run first: ``` xcl-smoke v1 commit: 7aa66822e2ce5cc9abb08246b6ede6d576c0699f gpu: NVIDIA GeForce RTX 5070 Ti title: GTA VI seconds: 60 exit: 0x0 frames shown: 1232 (PresentX 1232) presents per 2 s (last 3): 37 6 14 device removals: 0 crashes: 0 peak commit: 28829 MB ``` `main` `e50836b`, run second: ``` xcl-smoke v1 commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a gpu: NVIDIA GeForce RTX 5070 Ti title: GTA VI seconds: 60 exit: 0x0 frames shown: 1252 (PresentX 1252) presents per 2 s (last 3): 18 35 8 device removals: 0 crashes: 0 peak commit: 28499 MB ``` This PR has 98 % of `main`'s frames here (1232 / 1252), against 93 % with `main` first, so the 93 % above was mostly run-to-run spread rather than this change. **Not tested** - Whether the title's programs in these 60 s use `v_cvt_rpi` / `v_cvt_flr` on values the change affects: not counted. - World loading: a 60 s run ends before it. - AMD. **AI use:** Claude Code (Claude Opus 5.5)
JJAutoCompare commented 2026-11-26 22:49:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T22:49:08Z.


Tested

Independent run at clean PR head 7aa66822e2ce5cc9abb08246b6ede6d576c0699f on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile.

Prebuilt with cargo test --locked -p xcl --lib --no-run --message-format=json-render-diagnostics outside the GPU mutex. Ran <test-exe> gpu::recomp::tests::gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign --exact --nocapture --test-threads=1 under the Arc mutex with XCL_ADAPTER=A770.

1 passed, 0 failed, 0 ignored and 0 GPU skips (0.73 s). All 192 split-wave64 comparisons matched, including rounding around ±0.5, signed bounds, infinities, and RPI/FLR NaN saturation by sign. Plain I32 conversion returned zero for all four NaN inputs.

Not tested

Native wave64, negative signaling NaN, the workspace suite and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.

<!-- greyfinch-sync:ivall/xcl:comment:7205011299 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7205011299). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-26T22:49:08Z. --- **Tested** Independent run at clean PR head `7aa66822e2ce5cc9abb08246b6ede6d576c0699f` on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile. Prebuilt with `cargo test --locked -p xcl --lib --no-run --message-format=json-render-diagnostics` outside the GPU mutex. Ran `<test-exe> gpu::recomp::tests::gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign --exact --nocapture --test-threads=1` under the Arc mutex with `XCL_ADAPTER=A770`. 1 passed, 0 failed, 0 ignored and 0 GPU skips (0.73 s). All 192 split-wave64 comparisons matched, including rounding around ±0.5, signed bounds, infinities, and RPI/FLR NaN saturation by sign. Plain I32 conversion returned zero for all four NaN inputs. **Not tested** Native wave64, negative signaling NaN, the workspace suite and retail smoke. **AI use** T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.
Foniass commented 2026-12-01 04:38:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:38:39Z.


Triage (#1607) – head 7aa6682

No open or merged PR changes v_cvt_rpi_i32_f32 / v_cvt_flr_i32_f32. Main's HLSL path still emits cvt_i32(floor(x + 0.5f)).
Main has gained a direct-DXIL lowering of both instructions since this branch was cut (gpu/dxil/lower_valu.rs: fadd(x, 0.5) + ROUND_NI, NaN gives 0). After a rebase, XCL_DIRECT_DXIL will still produce the old results, and the new GPU test only covers whichever path run_code takes. Please port the fix there too.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300943776 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7300943776). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:38:39Z. --- **Triage (#1607)** – head 7aa6682 No open or merged PR changes `v_cvt_rpi_i32_f32` / `v_cvt_flr_i32_f32`. Main's HLSL path still emits `cvt_i32(floor(x + 0.5f))`. Main has gained a direct-DXIL lowering of both instructions since this branch was cut (`gpu/dxil/lower_valu.rs`: `fadd(x, 0.5)` + `ROUND_NI`, NaN gives 0). After a rebase, `XCL_DIRECT_DXIL` will still produce the old results, and the new GPU test only covers whichever path `run_code` takes. Please port the fix there too. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
upipibi commented 2026-12-03 17:10:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-12-03T17:10:51Z.


Test report for the new head 0f69a2f (rebased onto main e99b0bd). The new commit ports the fix to the direct-DXIL lowering, as asked in https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7300943776: cvt_rpi / cvt_flr / nan_by_sign in dxil/prelude.rs, used by dxil/lower_valu.rs. The reference in gpu_f32_math_and_bit_scans_random had flr(NaN) = 0; it is now saturated by sign, like the HLSL path.

RTX 3070, driver 621.40, debug:

  • gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign, gpu_f32_math_and_bit_scans_random, gpu_mullit_and_cvt_off_match_rdna2, 3 runs each:
    • XCL_DIRECT_DXIL=0: 3 passed, 0 failed (each run)
    • XCL_DIRECT_DXIL=1: 3 passed, 0 failed (each run)
  • Red, the direct lowering as on main (the lower_valu.rs change taken out), XCL_DIRECT_DXIL=1: 0 passed, 2 failed
  • cargo test -p xcl --lib -- --test-threads=4: 2864 passed, 0 failed, 37 ignored

The smoke pair in the description is for 7aa6682, so a pair on 0f69a2f is needed.

Tested with the help of Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7386093288 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7386093288). Originally posted by [upipibi](https://github.com/upipibi) on 2026-12-03T17:10:51Z. --- Test report for the new head `0f69a2f` (rebased onto `main` `e99b0bd`). The new commit ports the fix to the direct-DXIL lowering, as asked in https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7300943776: `cvt_rpi` / `cvt_flr` / `nan_by_sign` in `dxil/prelude.rs`, used by `dxil/lower_valu.rs`. The reference in `gpu_f32_math_and_bit_scans_random` had `flr(NaN) = 0`; it is now saturated by sign, like the HLSL path. RTX 3070, driver 621.40, debug: - `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign`, `gpu_f32_math_and_bit_scans_random`, `gpu_mullit_and_cvt_off_match_rdna2`, 3 runs each: - `XCL_DIRECT_DXIL=0`: 3 passed, 0 failed (each run) - `XCL_DIRECT_DXIL=1`: 3 passed, 0 failed (each run) - Red, the direct lowering as on `main` (the `lower_valu.rs` change taken out), `XCL_DIRECT_DXIL=1`: 0 passed, 2 failed - `cargo test -p xcl --lib -- --test-threads=4`: 2864 passed, 0 failed, 37 ignored The smoke pair in the description is for `7aa6682`, so a pair on `0f69a2f` is needed. *Tested with the help of Claude Code (Claude Opus 5.5).*
Foniass commented 2026-12-03 17:11:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T17:11:56Z.


Follow-up review of 0f69a2fb, since 7aa6682 (code reading only, not a merge-check; PR description red) · 2 medium, 1 nit

In short: Rebased, with a second commit that ports the fix to the direct-DXIL lowering (dxil/lower_valu.rs, helpers in dxil/prelude.rs). That answers the earlier triage point that XCL_DIRECT_DXIL would keep the old results. The new cvt_rpi / cvt_flr / nan_by_sign follow the HLSL helpers operation for operation, and the GPU test now runs both backends. Two process points remain: the first commit alone fails its own test on the default backend, and the whole workspace was not run on this head.

Medium

  1. The first commit alone fails gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign on the default backend.

    • In 165bd3fa the test calls runner::run_code, which takes the direct backend when direct_dxil() is on, the default.
    • That backend keeps floor(x + 0.5) and NaN → 0 until 0f69a2fb.
    • Tested shows the direct path failing on 13 rows without the second commit.

    CONTRIBUTING.md asks that every commit pass the tests, so git bisect works. Squash the two: it is one change to two instructions, in both backends.

  2. The whole workspace is not reported on this head. Tested gives cargo test -p xcl --lib on 0f69a2fb (2864 passed, 0 failed, 37 ignored). The workspace run, with the integration tests, is from before the rebase. CONTRIBUTING.md asks for cargo test --workspace -- --test-threads=4 on the head under review.

Nit

  1. Direct DXIL: is not one of the commit areas. CONTRIBUTING.md lists Recompiler for this code. Squashing (point 1) settles it.
Checked and fine
  • Earlier triage point fixed: the direct lowering now calls cvt_rpi / cvt_flr for the two instructions. v_cvt_i32_f32 keeps cvt_i32 (NaN → 0), as on RDNA2.
  • cvt_rpi matches the HLSL cvt_rpi:
    • ROUND_NI for the floor;
    • |x| < 2^23 on the bits;
    • x - fl >= 0.5 as an ordered compare (false for NaN);
    • cvt_i32(fl) + up, which cannot overflow below 2^23;
    • then nan_by_sign.
  • nan_by_sign checks NaN on the bits (mag > 0x7F80_0000, so infinities are not caught) and picks 0x8000_0000 or 0x7FFF_FFFF by the sign bit, quiet or signalling.
  • The rpi / flr test now translates the program through both backends whatever XCL_DIRECT_DXIL says. It uses the split form when the adapter has no native wave64, as gpu_mullit_and_cvt_off_match_rdna2 does.
  • f32_math_and_bit_scans_random now expects flr and rpi to saturate NaN by sign, and rpi to be the floor of the exact x + 0.5 in f64. For |x| >= 2^23 that is x itself, and Rust's saturating as i32 matches cvt_i32 for out-of-range values and infinities.
  • The head merges cleanly onto main.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7386123623 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1020#issuecomment-7386123623). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T17:11:56Z. --- **Follow-up review** of `0f69a2fb`, since `7aa6682` (code reading only, not a merge-check; `PR description` red) · 2 medium, 1 nit **In short:** Rebased, with a second commit that ports the fix to the direct-DXIL lowering (`dxil/lower_valu.rs`, helpers in `dxil/prelude.rs`). That answers the earlier triage point that `XCL_DIRECT_DXIL` would keep the old results. The new `cvt_rpi` / `cvt_flr` / `nan_by_sign` follow the HLSL helpers operation for operation, and the GPU test now runs both backends. Two process points remain: the first commit alone fails its own test on the default backend, and the whole workspace was not run on this head. #### Medium 1. **The first commit alone fails `gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign` on the default backend.** - In `165bd3fa` the test calls `runner::run_code`, which takes the direct backend when `direct_dxil()` is on, the default. - That backend keeps `floor(x + 0.5)` and NaN → 0 until `0f69a2fb`. - **Tested** shows the direct path failing on 13 rows without the second commit. CONTRIBUTING.md asks that every commit pass the tests, so `git bisect` works. Squash the two: it is one change to two instructions, in both backends. 2. **The whole workspace is not reported on this head.** **Tested** gives `cargo test -p xcl --lib` on `0f69a2fb` (2864 passed, 0 failed, 37 ignored). The workspace run, with the integration tests, is from before the rebase. CONTRIBUTING.md asks for `cargo test --workspace -- --test-threads=4` on the head under review. #### Nit 3. **`Direct DXIL:` is not one of the commit areas.** CONTRIBUTING.md lists `Recompiler` for this code. Squashing (point 1) settles it. <details><summary>Checked and fine</summary> - Earlier triage point fixed: the direct lowering now calls `cvt_rpi` / `cvt_flr` for the two instructions. `v_cvt_i32_f32` keeps `cvt_i32` (NaN → 0), as on RDNA2. - `cvt_rpi` matches the HLSL `cvt_rpi`: - `ROUND_NI` for the floor; - `|x| < 2^23` on the bits; - `x - fl >= 0.5` as an ordered compare (false for NaN); - `cvt_i32(fl) + up`, which cannot overflow below 2^23; - then `nan_by_sign`. - `nan_by_sign` checks NaN on the bits (`mag > 0x7F80_0000`, so infinities are not caught) and picks `0x8000_0000` or `0x7FFF_FFFF` by the sign bit, quiet or signalling. - The rpi / flr test now translates the program through both backends whatever `XCL_DIRECT_DXIL` says. It uses the split form when the adapter has no native wave64, as `gpu_mullit_and_cvt_off_match_rdna2` does. - `f32_math_and_bit_scans_random` now expects flr and rpi to saturate NaN by sign, and rpi to be the floor of the exact `x + 0.5` in f64. For `|x| >= 2^23` that is `x` itself, and Rust's saturating `as i32` matches `cvt_i32` for out-of-range values and infinities. - The head merges cleanly onto `main`. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/1020:upstream-pr/1020'
git switch 'upstream-pr/1020'

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/1020'
git switch 'upstream-pr/1020'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1020'
git switch 'upstream-pr/1020'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1020'
git switch 'main'
git merge --squash 'upstream-pr/1020'
git switch 'main'
git merge --ff-only 'upstream-pr/1020'
git switch 'main'
git merge 'upstream-pr/1020'
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
xcl-dev/xcl!1013
No description provided.