Recompiler: v_cvt_rpi rounds the exact x + 0.5; v_cvt_rpi / v_cvt_flr saturate NaN by sign #1020
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1020
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1020"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@upipibi on GitHub · 2026-11-24 10:26 UTC · original
upipibi:fix/cvt-rpi-flr→main· +62 −2 · 2 files · 1 commits · openBranch
fix/cvt-rpi-flr, commit7aa6682(one50836b). 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_f32is the floor of the exact x + 0.5. XCL emittedfloor(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_f32andv_cvt_flr_i32_f32give0x7FFFFFFFfor a positive NaN and0x80000000for a negative NaN, quiet or signalling. XCL gave 0.v_cvt_i32_f32keeps giving 0 for any NaN, as before.The fix
emit.rs: two helpers in the prelude,cvt_rpiandcvt_flr.cvt_rpitakesfloor(x)and adds 1 whenx - 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_signsaturates a NaN based on its sign bit.flrof 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.maine50836bit fails with 13 mismatches.Tested
RTX 3070, driver 616.56, Windows 11. Each branch has its own target dir.
cargo test --workspace --no-fail-fast -- --test-threads=4: 705 passed, 0 failed, 41 ignored, with the usual two no-wave64 skips.maine50836b, 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::d3d12xtests. On rerun they did not come back:hle::d3d12x::runs: 105/105 each time.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 arePoisonErrors 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
From Kalmarv's run (https://github.com/ivall/xcl/pull/1020#issuecomment-7137388571), thanks:
main:
PR:
Not tested
v_cvt_flrof 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
🤖 Generated with Claude Code
@DavidM1911 on GitHub · 2026-11-24 11:04 UTC · original
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_signruns on the Radeon (a bogusXCL_ADAPTERvalue printsSKIPPED ... no GPU, so the pass is a real GPU run).XCL_ADAPTER=radeon cargo test -p xcl --lib recomp -- --test-threads=4: 187 passed, 0 failed, 18 ignored (the ignored ones are theXCL_SAMPLE_*retail-survey tests; GPU wave64 tests ran and passed).AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@4usphs on GitHub · 2026-11-24 11:23 UTC · original
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
7aa6682merged ontomain47efa2e(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)orXCL_ADAPTER=9070picks the GPU (backend 'real' – AMD Radeon(TM) Graphics (485 MiB VRAM)/AMD Radeon RX 9070 XT).gpu_cvt_rpi_flr_round_exactly_and_saturate_nan_by_sign(XCL_REQUIRE_GPU=wave64)cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDSKIPPEDemit.rschange reverted, the new test fails with the same 13 mismatches as on your RTX 3070. These arerpi(0x3EFFFFFF) = 1,rpi(0x4B000001) = 0x00800002,rpi(0x4B7FFFFF) = 0x01000000,rpi(0xCB000001) = 0xFF800000, andrpi/flrof the four NaNs = 0.ROWSthroughv_cvt_rpi_i32_f32,v_cvt_flr_i32_f32andv_cvt_i32_f32as 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 (
gfx1036is a desktop RDNA2 APU of the same generation),flrof 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 on GitHub · 2026-11-24 11:29 UTC · original
Independent verification, merged onto current
main384f7f7locally (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 newv_cvt_rpi/v_cvt_flrNaN-by-sign cases. The generatedcvt_rpi/cvt_flrHLSL helpers look correct: NaN saturates by sign vianan_by_sign,rpiavoids thex + 0.5fdouble-rounding by comparingx - floor(x) >= 0.5fexactly, and the< 2^23guard keepsfl + 1exact.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@Kalmarv on GitHub · 2026-11-24 16:16 UTC · original · edited 2026-11-24 16:50 UTC
Regression pair for
7aa6682againstmaine50836b(this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 93 % ofmain's frames, 97 % of its peak commit.Tested
scripts/smoke.ps1, the same retail title for 60 s each:mainate50836b(this PR's base, 67 commits behind today'smain) first, then this PR's head, one after the other on the same machine.maine50836b:this PR,
7aa6682: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 21The 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
maine50836b(this PR's base) right after, same machine and setup:this PR,
7aa6682, run first:maine50836b, run second:This PR has 98 % of
main's frames here (1232 / 1252), against 93 % withmainfirst, so the 93 % above was mostly run-to-run spread rather than this change.Not tested
v_cvt_rpi/v_cvt_flron values the change affects: not counted.AI use: Claude Code (Claude Opus 5.5)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.