Recompiler: a 2-bit SNORM store component rounds a half away from zero #2051
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!2051
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2051"
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-25 02:02 UTC · original
upipibi:fix/snorm2-store-half-away→main· +61 −2 · 3 files · 2 commits · openfmt_encoderounded every SNORM component to nearest even. So 0.5 and −0.5 stored 0 in the 2-bit W of2_10_10_10_SNORM, where RDNA2 stores 1 and −1. Storing x = w = 0.5, y = 0.25, z = −0.75 gave0x28120100instead of0x68120100.Source for the rule: boykopovar/AnyPS5#25877 ran a store sweep of
tbuffer_store_format_xyzwin 75 formats on gfx1036. Only this 2-bit component differed from nearest-even rounding. 8-, 10- and 16-bit SNORM components and every UNORM width round to nearest even on the hardware too, so they stay as they are. These formats are common for packed normals and tangents, where the 2-bit component carries the handedness sign.What is in it
recomp/emit.rs: the SNORM arm offmt_encodeusessign(s) · floor(|s| + 0.5)when the component is 2 bits wide, andround(s)otherwise.dxil/lower_mem.rs: the same inLw::fmt_encode.recomp/tests.rs:gpu_buffer_store_two_bit_snorm_rounds_half_away. It stores eight W values (±0.5, ±1, 0.49, −0.75, 0.4999999, 0.5000001) with x = 0.5, y = 0.25, z = −0.75, and compares the packed words.98e83c0: the 2-bit magnitude (at most 1) is compared with 0.5 directly.floor(|x| + 0.5)rounded 0.49999997 + 0.5 to exactly 1.0 in f32, so0x3effffff/0xbeffffffstored ±1 (found by nnonno91). Exactly ±0.5 still stores ±1; other SNORM widths unchanged.Tested
d25e85f, as-is: Radeon RX 7800 XT (RDNA3, driver 32.0.31035.1003), Windows 11, debug, DXC 1.9.0.5512.gpu_buffer_store_two_bit_snorm_rounds_half_awaypasses;cargo test --workspace --no-fail-fast -- --test-threads=4: 1242 passed, 2 failed, 46 ignored. The 2 failures are not this PR's:fuzz_validate_and_gpu_1fails the same way onmain1a0bbe3there, andgpu_image_get_resinfo_past_last_levelcomes from this head's base, which predatesmain's fixea088a5.d25e85f1(rebased ontomain426a5a74, the firstmainwith green CI after5478c4a7, whose two failing tests main fixed in0d13b071), RTX 3070 (616.56):gpu_suite (--skip gpu_sparse_vram) 144 passed, 0 failed withXCL_DIRECT_DXIL=0and with=1.main426a5a74gives 143 passed on both.98e83c0, RTX 3070 (616.56): the test, extended with0x3effffff/0xbeffffff(W = 0) and0x3f000000/0xbf000000(W = ±1), fails at1e29ff4and passes after the fix withXCL_DIRECT_DXIL=0and1.gpu_suite: 133 passed with0; with1, 132 passed and 1 failed:gpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046).main5ce558f:mainfails on both paths (w = 0.5: 0x28120100, want 0x68120100). This branch passes withXCL_DIRECT_DXIL=0and1.gpu_tests (--skip gpu_sparse_vram): 133 passed withXCL_DIRECT_DXIL=0; with1, 132 passed and 1 failed,gpu_image_get_resinfo_1d_array, which also fails onmain5ce558f(#2046 fixes it).dxil::andbuffer_formatunits: 138 passed.Regression run
Pair for the current head
d25e85fagainstmain1a0bbe3, run by thehollowedone (comment, thanks): RTX 3080 Ti (621.35), stockscripts/smoke.ps1, clean release builds, 60 s offline. Pasted unedited.Earlier: The earlier pair, comment, was for
98e83c0, before the rebase ontomain5478c4a7..A second pair, by ThiagoAlexsander on an RTX 5080 (comment, thanks):
main426a5a71529 frames shown, this headd25e85f1599, 0 crashes and 0 device removals on both.Not tested
AI use
🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-25 02:06 UTC · original
Independent AMD check on
1b617e31db8414bd1ae0d23d4376f4108a6429bd. The existing regression test passed through both backends. The closest representable inputs with magnitude below 0.5 exposed a new boundary failure on both.Tested
cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_buffer_store_two_bit_snorm_rounds_half_away -- --exact --nocapture --test-threads=1withXCL_ADAPTER=AMD Radeon,XCL_REQUIRE_GPU=wave64andXCL_DIRECT_DXIL=0and1in separate runs. The original test passed on the head (1 passed, 0 failed per backend).f32::from_bits(0x3eff_ffff)andf32::from_bits(0xbeff_ffff)as the last two W inputs and printed all readbacks before asserting. Both should store W = 0 (packed0x28120100). The head stored W = +1 and −1 (packed0x68120100and0xe8120100) on both backends. On the exact parentc00f3fcfce59bb4dfd3a1f96bbc84c60e765b538, both of these inputs stored W = 0, and the exact ±0.5 cases also stored W = 0. The adapted test failed once per backend on each revision at the respective boundary. All runs had 0 ignored and no skips.0.4999999701976776 + 0.5to binary32 gave exactly1.0. That matches the below-half values crossing the threshold withfloor(abs(s) + 0.5).Not tested
Retail smoke, the full workspace suite, and other GPUs.
AI use
OpenAI Codex (GPT-6.2 Sol) adapted and ran the test, verified the logs, and wrote this report.
@JoaoPauluu on GitHub · 2026-11-25 02:20 UTC · original
A run with vkd3d-proton as the host D3D12 (DXIL → SPIR-V through dxil-spirv, then the NVIDIA Vulkan driver), so the DXIL goes through a different compiler than the native-Windows runs here: this PR's test passes.
Tested
x86_64-pc-windows-gnu.1e29ff4as it is (merge base withmain5ce558f), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_buffer_store_two_bit_snorm_rounds_half_away: ok, not skippedNot tested
AI use
@JJAutoCompare on GitHub · 2026-11-25 02:22 UTC · original
Arc A770 verification of PR #2051 at
1e29ff44c7fa0afea70f24ff4c46c0e3311817c5.Tested
cargo test --locked -p xcl --lib --no-run --message-format=json. Used the unoptimized test profile, two Cargo jobs,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0, andCARGO_TARGET_DIR=L:/XclTooling/pr1512-tiling-edges-fddfa267/target. BothTEMPandTMPpointed toL:/XclTooling/pr2051.XCL_ADAPTER=A770andXCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. The working directory wascrates/xcl. Each backend ran in a separate child PowerShell with-NoProfile -NonInteractive -ExecutionPolicy RemoteSignedto load the local mutex wrapper.XCL_DIRECT_DXIL01Both runs acquired and released the Arc lock. Readback assertions matched these 32-bit words on both backends, with X = 0.5, Y = 0.25 and Z = −0.75.
0x681201000xE81201000x281201000xE81201000x681201000xE81201000x281201000x68120100Not tested
The immediate binary32 neighbors of the half ties, including
0x3effffffand0xbefffffffrom the earlier AMD report, are outside this fixture. This run also leaves other GPUs, the full workspace suite, and retail smoke untested. Earlier AMD reportAI use
T3 Code / Codex (gpt-6.2-sol) ran the checked-in test, verified the logs, and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 04:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@upipibi on GitHub · 2026-11-25 06:26 UTC · original
Thanks nnonno91, that's a real bug. In f32, 0.49999997 + 0.5 rounds to exactly 1.0, so
floor(|x| + 0.5)stored ±1 for0x3effffff/0xbeffffff. The 2-bit magnitude is at most 1, so98e83c0compares it with 0.5 directly on both paths; exactly ±0.5 still stores ±1. The test now also covers0x3effffffand0xbeffffff(W = 0) and0x3f000000and0xbf000000(W = ±1). On an RTX 3070 (616.56), the extended test fails at1e29ff4and passes after the fix withXCL_DIRECT_DXIL=0and1. Thegpu_suite passes on both paths, apart fromgpu_image_get_resinfo_1d_arraywith direct DXIL, which also fails onmain.AI-assisted (Claude Code).
@Toons29 on GitHub · 2026-11-25 09:45 UTC · original
Regression run of
98e83c04on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon568e7db7, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 104 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.@raylitebull on GitHub · 2026-11-25 10:47 UTC · original
98e83c0now conflicts incrates/xcl/src/gpu/recomp/tests.rsafter #2054 merged onmain.Please rebase onto
main; once rebased and CI is green, an exact-head AMD GPU test rerun (the earlier AMD run predated98e83c0) will unblock merge.@oni-swr on GitHub · 2026-11-25 12:22 UTC · original
AMD synthetic GPU run of
d25e85f1b183f8290dd1c9b6f5f9ecf79805873d(exact PR head, tested as-is, not merged ontomain; the diff touches the recompiler and its test only). Synthetic Cargo tests only: no retail title, nosmoke.ps1.Tested
Compiling xcl v0.1.0came from the PR checkout.cargo build --workspace, thencargo test -p xcl --lib gpu_buffer_store_two_bit_snorm -- --nocapture:gpu::recomp::tests::gpu_buffer_store_two_bit_snorm_rounds_half_away ... ok(1 passed, 0 failed, 0 ignored).cargo test --workspace --no-fail-fast -- --test-threads=4: 1242 passed, 2 failed, 46 ignored, 7 distinctSKIPPEDlines. These are not coverage: f16/f32 per-lane form refused (6, wave32 and wave64) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff). It fails the same way onmain1a0bbe3on this machine.gpu::recomp::tests::gpu_image_get_resinfo_past_last_level(2D mip 0x1: [4, 2, 0, 1], RDNA2 gives [0, 0, 0, 1]). This head does not containmain's commitea088a5("image_get_resinfo past the last level gives 0 sizes on AMD too"), so it is probably fixed by rebasing. I did not run the merged tree.Not tested
scripts/smoke.ps1regression run, NVIDIA, Intel, Wine/vkd3d.main.AI use
Claude Code, Claude Sonnet 5.5 ran the tests, checked the diff, and wrote this report.
@thehollowedone on GitHub · 2026-11-25 12:49 UTC · original
Here is the requested
scripts/smoke.ps1pair from clean release builds of main 1a0bbe3 and PR head d25e85f.RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC. The 60 s offline runs used separate copies of the same starting profile and DXIL seed, no input, PSO preload off, a 16 GiB job commit cap, and a 12 GiB system commit floor.
On the exact head,
cargo test --offline --locked -p xcl --lib gpu_buffer_store_two_bit_snorm -- --nocapture --test-threads=1reported 1 passed, 0 failed, 0 ignored, and no runtime skip notices in each ofXCL_DIRECT_DXIL=0and=1. The fixture checks the two-bit SNORM component at both half-way values and immediately below them.The smoke pair covers startup. AMD hardware, Wine, and world load were outside this test.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.
@DavidM1911 on GitHub · 2026-11-26 07:13 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.