Recompiler: round normalized f32 conversions once (#659) #683
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!683
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-683"
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?
@ilyaux on GitHub · 2026-11-24 03:27 UTC · original
ilyaux:review/issue-659-exact-normalized-f32→main· +204 −6 · 3 files · 1 commits · draftFixes #659. Avoid rounding an FP32 product to a halfway value before converting it to UNORM/SNORM.
The runtime fix and first two regression tests are @acaracargo's existing proposal, carried from f4c03b5 and 0bca2d7. This PR adds independent packed-format coverage and native Windows validation. acaracargo is credited as a co-author in the commit.
What is in it
emit.rs: round the significand/scale product once with integer arithmetic, preserving clamps and NaN handling.tests.rs: the original two regressions plus eight packed UNORM/SNORM formats, with 64 boundary/edge vectors and different values per channel.Tested
Head:
02fd1b03c357e5cb4457ca56fd343202de1d3736(clean tree), based onmain91f9a5e9f03156ea82dc55a18f7704862da7a5db. Windows 11 Home 26300, Ryzen AI 7 350, Rust 1.98.1 MSVC, debug, DXC/DXIL 1.8.2502.11.XCL_ADAPTER=nvidia:cargo build --workspace --locked;cargo test --workspace --no-fail-fast --locked -- --test-threads=4:695 passed, 0 failed, 41 ignored. Two
SKIPPED: no wave64tests are included in that passed count:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware. All three normalization regressions and the synthetic-title end-to-end test ran and passed.XCL_ADAPTER=radeon,XCL_REQUIRE_GPU=wave64:cargo test -p xcl --lib gpu_pknorm_f32_rounds_once -- --nocapture;cargo test -p xcl --lib norm_formats_round_once -- --nocapture;cargo test -p xcl --lib gpu_wave32_program_in_wave64_hardware -- --nocapture:3 normalization tests + 1 wave64 control passed, 0 failed/ignored/skipped.
maindd2ae9a, keeping tests but removing the runtime fix: 41 pknorm and 54 typed-store mismatches. The added packed-format test also fails (11_11_10_UNORM, got 6291458, expected 6291457).git diff --checkpassed.Regression run
Pending: matched
scripts/smoke.ps1runs on main and this PR's clean head. No complete retail title was available locally, so no smoke blocks were generated. Keeping this PR draft until that validation is available.Not tested
Retail gameplay/performance, real console rounding, Intel GPUs, and the full suite on AMD.
XCL_SAMPLE_*was unset, so opt-in real-game-data paths were not exercised.AI use
@acaracargo on GitHub · 2026-11-24 04:04 UTC · original
Thanks for extending my fix and for the attribution! I was actually preparing to open the original branch as a draft PR.
I've also completed local retail regression runs, and @requiemsnkrp offered independent smoke testing on #659.
Let's coordinate so we don't end up with duplicate PRs. I'm happy to help validate this version and get the fix merged.
@ItsMrDubey on GitHub · 2026-11-24 04:57 UTC · original
Test report for
02fd1b03c357e5cb4457ca56fd343202de1d3736(this PR's head)Tested
stable-x86_64-pc-windows-msvc), debug; DXC 1.9.2602.17 from Windows SDK 10.0.2610016 test binaries: 694 passed, 1 failed, 41 ignored. Same machine,
main64b3f3559: 700 passed, 1 failed, 41 ignored.This PR's tests:
gpu::recomp::tests::gpu_buffer_store_norm_formats_round_once: okgpu::recomp::tests::gpu_pknorm_f32_rounds_once: okgpu::recomp::tests::gpu_packed_norm_formats_round_once: okFailures:
hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memoryfails on this machine on every run, on this PR's head and onmain64b3f3559alike (5 of 5 reruns onmain), so it is not from this PR. #650 fixes it here.16 test binaries instead of
main's 17 because this branch predatestests/sparse_reinit.rs; nothing crashed.SKIPPED (no wave64 on this GPU):
gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.AI use: Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.
@Anon64 on GitHub · 2026-11-24 06:43 UTC · original
Regression runs for this PR's head
02fd1b0and for its basemain91f9a5e, on a retail title (same title, 60 s each), made withscripts/smoke.ps1(release, clean tree at each commit) and pasted unedited, for Regression run.main:
this PR:
Tested
Not tested
Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
@KENAJBBY on GitHub · 2026-11-24 09:31 UTC · original
Native RDNA2 (
gfx1036): every double-rounding input, and no MODE dependenceThis extends @luckyteagirl's 13-input native check on #659 to the whole problem set. I ran
v_cvt_pknorm_u16_f32andv_cvt_pknorm_i16_f32on raw f32 bits on an RDNA2 GPU. The inputs were every f32 in (0, 1) whose binary32 product with the scale is exactly k + 0.5: 65,536 inputs for 65535 and 32,768 for 32767, each also negated for SNORM16. On top of that came 20,000 random bit patterns and 26 special values. Both halves were checked, withsrc0andsrc1holding different inputs.main'sround(f * scale)(CPU model)v_cvt_pknorm_u16_f32v_cvt_pknorm_i16_f32The result was 0 in each of 11 MODE values: f32 round RNE / +inf / −inf / RTZ, f32 and f16 denormals flushed or kept, DX10_CLAMP 0/1 and IEEE 0/1. Each mode was set with
s_setreg_b32and read back withs_getreg_b32. The round mode does not apply here: these conversions always round to nearest even.The special inputs give the same result in all 1024 values of MODE[9:0], and every one matches this PR's helpers:
0x00000001,0x80000001,0x007FFFFF),0x00800000, 2^-170x00000x00000x3F7FFFFF0xFFFF0x7FFF0xBF7FFFFF0x00000x80010x7F8000110x00000x00000x8000/0x00000x4000/0xC0000x37C000C0(#659's example)0x00010x00010x38400180/0xB84001800x0003/0x00000x0001/0xFFFF@Kadthicu's negative SNORM16 case on #659,
-0x38400180, gives0xFFFF(−1) on the hardware, as they computed. So it is a valid vector forgpu_buffer_store_norm_formats_round_once, if the store path rounds like the ALU instruction (not measured, see below).Tested
gfx1036, RDNA2), driver 32.0.21030.2001, AMD OpenCL3652.0 (PAL,LC), native wave64; Windows 11 Pro 26200.s_setreg_b32 hwreg(HW_REG_MODE, 0, 10), reads it back withs_getreg_b32(checked against the requested value in every run), runs the instruction and restores MODE. Reference: this PR'scvt_norm_u16_f32/cvt_norm_i16_f32transcribed to Python with exact rational arithmetic.Not tested
buffer_store_format_*) and the f16-sourcev_cvt_pknorm_*_f16on the hardware.AI use
@DavidM1911 on GitHub · 2026-11-25 12:06 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.