Recompiler: D16 format loads of UNORM / SNORM data round once to nearest #2027
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!2027
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2027"
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 01:14 UTC · original
upipibi:fix/d16-norm16-single-round→main· +193 −7 · 3 files · 2 commits · openKnown: this PR's D16 normalization uses a 64-bit divide (
d16_fmtindxil/lower_mem.rs,norm16_repinrecomp/emit.rs), so every shader with a D16 load declares Int64 (SFI00x8000) in both backends. A 32-bit fix with tests is onupipibi/xclbranchfix/d16-norm16-no-int64(af15e87, one commit on #2027's head; RTX 3070:gpu_buffer_d162/2 withXCL_DIRECT_DXIL=0and=1, lib suite 1170 passed, 0 failed; a no-GPU test checks that the Int64 flag is clear for all 20 UNORM / SNORM D16 buffer and tbuffer loads). It isn't pushed here because a push needs a new title smoke pair, which I can't make.Part of #2026 (XCL-BT-020's third item, #1488). The image half follows in a second PR.
A D16 buffer format load packed a UNORM / SNORM channel with
f32tof16of the decoded f32. That's two roundings, and on D3D12 the second one rounds toward zero. RDNA2 roundscode / (2^w − 1)once, to nearest even. So about half of all codes came back one unit in the last place low: 16_UNORM0x0801gave0x2800, where RDNA2 gives0x2801.Overlap with #2360 (#1607 group D102): both round UNORM / SNORM codes to f16 once, to nearest. This PR also truncates the other non-integer channels to f16 (
f16_rtz), where #2360 rounds them to nearest. NWProgramming00 measuredbuffer_load_format_d16_xon an RDNA2 gfx1036 (#1607 comment): the hardware truncates 32_FLOAT (6,011 of 6,011 values), and rounds normalized codes once to nearest.What is in it
recomp/emit.rs:norm16_repandd16_fmtin the prelude. The FormatLoad D16 channel goes throughd16_fmtinstead off32tof16.round(f · (2^w − 1)).code / (2^w − 1)has a binary expansion that repeats thew-bit code. So its first 32 bits,floor((code << 32) / (2^w − 1)), decide the rounding, and a tie can't happen.|v| / (2^(w−1) − 1)and adds the sign.f32tof16.dxil/lower_mem.rs: the same asLw::d16_fmt, at the three D16 format-load sites.recomp/tests.rs:gpu_buffer_d16_loads_of_16_bit_norms_round_once, with 64 lanes each loading their own 16_UNORM and 16_SNORM code, against exact single rounding.Second commit (
b0aae2e): float channels of a D16 format load truncate withf16_rtzon both paths, instead of passing throughf32tof16/legacyF32ToF16. That conversion's rounding is the host's: it truncates on the RTX 3070 and WARP, but under vkd3d-proton it rounds to nearest (Marvisak/VIctory#2006), while RDNA2 truncates (boykopovar/AnyPS5#22750). New testgpu_buffer_d16_loads_of_32_bit_floats_truncate: 32_FLOAT values the two roundings tell apart (1 + 1.5 / 1.75 ulp, 65535, ±70000, a denormal half-way), plus -1.5 and +inf.Tested
0cab3ef(rebased ontomain426a5a74, the firstmainwith green CI after5478c4a7, whose two failing tests main fixed in0d13b071), RTX 3070 (616.56):gpu_suite (--skip gpu_sparse_vram) 145 passed, 0 failed withXCL_DIRECT_DXIL=0and with=1.main426a5a74gives 143 passed on both.b0aae2e, RTX 3070 (616.56): thed16tests pass withXCL_DIRECT_DXIL=0and1(6 of 6).gpu_tests: 134 passed with0; with1, 133 passed and 1 failed:gpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046). This GPU already truncates, so the new test passes with or without the second commit here. Its value is on hosts that round to nearest (vkd3d-proton, and AMD perdxil/ops.rs).norm16_rep/d16_fmtagainst exact rational rounding: every code atw= 2…16, UNORM and SNORM, with the decoded value off by up to ±2 ULP (524,272 checks). No mismatches.main5ce558f(rebased; #1947 now keys the translated cache on thegpu/dxilsources, so there is noTRANSLATOR_VERSIONbump):mainfails with 57 of 128 halves one ULP low (for example 16_SNORM0x5b5b:0x39b5, want0x39b6). This branch passes, withXCL_DIRECT_DXIL=0and1.gpu_tests (--skip gpu_sparse_vram), with the whole stack (#2027, #2030, #2042): 135 passed withXCL_DIRECT_DXIL=0; with1, 134 passed and 1 failed,gpu_image_get_resinfo_1d_array, which fails the same way onmain5ce558f(#2046 fixes it).dxil::andbuffer_formatunits: 138 passed.Regression run
Pair for the current head
0cab3efagainstmain1a0bbe3, run by thehollowedone (comment, thanks): RTX 3080 Ti (621.35), stockscripts/smoke.ps1, clean release builds, 60 s offline. Pasted unedited.Earlier: Toons29's pair, comment, was for
b0aae2e, before the rebase ontomain5478c4a7..Not tested
AI use
🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-25 01:18 UTC · original
Tested
Independent Windows/D3D12 check on exact head
d7bd99057d01219b23acb0ec52a68d2e11e88c77. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62, native wave64), and GeForce RTX 5090 (32.0.16.1742, split wave64). Rust 1.100.0 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized dev/test profiles with debug info off.cargo build --workspace --lockedpassed at the PR head.cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_buffer_d16_loads_of_16_bit_norms_round_once -- --exact --test-threads=1 --nocapturepassed on each GPU withXCL_DIRECT_DXIL=0and1(1 passed, 0 failed, 0 ignored, 0 skipped per run). With only the test added to parentde36462e0b1043b915a418d4591ed1e397622ede, all four baseline runs failed as expected (57 of 128 half values differed in each).cargo test --locked -p xcl --test d16_norm_gpu_probe -- --exact all_16_bit_normalized_buffer_codes_match_exact_rounding --test-threads=1 --nocapturecompared all 65,536 codes per format for 16-bit UNORM and SNORM. The temporary compute shader usedBUFFER_LOAD_FORMAT_D16_Xfor both formats and wrote one packed pair to a separate output region per input. The CPU reference found the nearest binary16 value with exact integer cross-products. Both HLSL + DXC and Direct DXIL ran in each test. Each probe process passed (1 passed, 0 failed, 0 ignored, 0 skipped), with the parent run explicitly checking for the old rounding error.The counts were identical on both adapters and both backends. For example, 16_UNORM
0x0801changed from0x2800to the expected0x2801.Not tested
Real-title smoke runs, full workspace test suite, other channel widths, and image format loads. The exhaustive probe covers single-channel 16-bit buffer inputs.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) prepared and ran the temporary probe, checked the outputs, and drafted this report.
@raylitebull on GitHub · 2026-11-25 01:34 UTC · original
Diff audit on
d7bd990looks strong (norm16_rep/d16_fmtinrecomp/emit.rs+dxil/lower_mem.rsmatches exact single rounding across all 65,536 16-bit UNORM/SNORM codes on AMD iGPU, RTX 5090, RTX 3070, and Intel Arc A770).Remaining before merge:
mainto clearCONFLICTING/DIRTY(also drop the manualTRANSLATOR_VERSION = 9bump inkernel.rs, as#1947now auto-hashesgpu/dxilsources viaXCL_DIRECT_DXIL_SOURCE_ID).xcl-smoke v1blocks (mainand PR) soPR descriptionpasses (or ask another contributor with a retail title to post them).@luckyteagirl on GitHub · 2026-11-25 02:19 UTC · original
Tested
83d3d05107998927f48efe501584dacfd934c14cand main5ce558f82a48c51d527f6035234dacbd29db3f05. Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M driver30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800MandXCL_REQUIRE_GPU=1,cargo test --locked -p xcl --lib -j 2 gpu::recomp::tests::gpu_buffer_d16_loads_of_16_bit_norms_round_once -- --exact --test-threads=1 --nocapturepassed under bothXCL_DIRECT_DXIL=0(HLSL/DXC) and=1(direct DXIL): 1 passed, 0 failed, 0 ignored, no explicit skip in each run.cargo build --locked --release -p xcl -j 2passed for both revisions. A locally owned title completed a paired 7-secondscripts/smoke.ps1run on the RX 6800M. Each run showed one frame, with no crash or device removal. Peak process commit was 6,963 MB on main and 7,058 MB on the PR.The two blocks below can be copied into Regression run in the PR description. A comment by itself does not satisfy XCL's description check.
main:
PR head:
Not tested
AI use
OpenAI Codex (GPT-6, exact variant not exposed in this session) ran the tests and smoke comparisons and drafted this report from their logs.
@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.83d3d05as it is (merge base withmain5ce558f), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_buffer_d16_loads_of_16_bit_norms_round_once: ok, not skippedNot tested
AI use
@DavidM1911 on GitHub · 2026-11-25 04:12 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!
@JJAutoCompare on GitHub · 2026-11-25 01:30 UTC · original · edited 2026-11-25 04:17 UTC
Tested
Independent Intel Arc A770 verification for #2026 on clean PR head
d7bd99057d01219b23acb0ec52a68d2e11e88c77. Windows 11 Enterprise Evaluation 25H2 (26200.9974), Ryzen 7 3800X, Arc A770 driver32.0.101.9175, Rust/Cargo 1.100.0 (x86_64-pc-windows-msvc), and DXC/DXIL1.9.2609.5.cargo test --locked -p xcl --lib --no-run(exit 0). The test profile was unoptimized, withCARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0, andCARGO_PROFILE_TEST_DEBUG=0.XCL_ADAPTER=A770,XCL_REQUIRE_GPU=wave64, andXCL_DXC_DIRset to the 1.9.2609 package, ran the prebuilt lib-test executable under the shared Arc lock. For each test below, the command was& $exe gpu::recomp::tests::<name> --exact --nocapture --test-threads=1, in a separate process for each listedXCL_DIRECT_DXILsetting.0(HLSL + DXC)1(direct DXIL for kernel execution)gpu_buffer_d16_loads_of_16_bit_norms_round_oncegpu_typed_buffer_loads_and_storesbuffer_format_d16_packs_and_unpacks_halvesbuffer_format_table_matches_llvm7 passed, 0 failed, 0 ignored, 0 skipped across seven processes. The rounding regression checked 64 UNORM and 64 SNORM output halves per backend.
powershell -NoProfile -ExecutionPolicy Bypass -File L:/XclTooling/pr2027/reference.ps1 -Source <worktree>/crates/xcl/src/gpu/recomp/tests.rs. The reference used exact integer distances between adjacent binary16 values to check all 128 committed fixture values. It also compared a CPU model of the PR conversion against that reference for all 65,536 codes per format at five binary32 magnitude offsets (−2 through +2 ULP, clamped at zero). Each format had 327,680 comparisons and zero mismatches.Not tested
Exhaustive GPU output, other normalized channel widths, D16 image loads, the parent commit, the full workspace suite, and retail-title smoke runs.
AI use
Codex (
gpt-6.2-sol) wrote and ran the temporary reference check, ran the focused tests, and wrote this report.Follow-up on 83d3d05
Tested
Independent STOR-WINLAB Arc A770 rerun for xcl-dev/xcl#2027 at
83d3d05107998927f48efe501584dacfd934c14c. GitHub showed the PR open at that exact head before and after the run. The worktree was clean and detached at the same SHA throughout testing. The existing JJAutoCompare Arc result in comment 7149616157 coversd7bd99057d01219b23acb0ec52a68d2e11e88c77. The PR discussion and reviews had no equivalent exact-head Arc result.Windows 11 Enterprise Evaluation 25H2 x64 (26200.9974), AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 (
stable-x86_64-pc-windows-msvc, rustc0ef1bc386), DXC and DXIL 1.9.2609.5. Cargo used the unoptimized test profile with two jobs and debug info and incremental compilation disabled.cargo test --locked -p xcl --lib --no-runcompleted outside the Arc lock (exit 0). Under& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }, ran the exact prebuilt command below in separate processes forXCL_DIRECT_DXIL=0and1, withXCL_ADAPTER=A770,XCL_REQUIRE_GPU=wave64, and the specified DXC directory.0)1)Each run matched all 128 expected binary16 values across 64 UNORM and 64 SNORM inputs. The wrapper logged both settings, and the stock fixture's
runner::run_codeuses the direct translator without fallback when enabled. Both stderr logs show the DXC version because the fixture checks DXC availability before dispatch. The wrapper exited 0 and logged the mutex release.Not tested
Other buffer widths or codes outside the fixture, image loads, filtered sampling, other shaders or adapters, the parent commit, the full workspace suite, and retail-title smoke runs.
AI use
T3 Code / Codex (gpt-6.2-sol) inspected the existing fixture and backend routing, ran the two tests, and wrote this report.
Raw evidence in
L:/XclTooling/pr2027/run-20261125T041438211Z:environment.log,prebuild.{stdout.log,stderr.log,exit.txt},direct-0.{stdout.log,stderr.log,exit.txt},direct-1.{stdout.log,stderr.log,exit.txt}, andgpu-wrapper.{stdout.log,stderr.log,exit.txt}.@Toons29 on GitHub · 2026-11-25 10:20 UTC · original
Regression run of
b0aae2econ 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.@thehollowedone on GitHub · 2026-11-25 12:21 UTC · original
Here is the requested
scripts/smoke.ps1pair from clean release builds of main 1a0bbe3 and PR head 0cab3ef.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.
The two D16 buffer tests also passed in separate processes with
XCL_DIRECT_DXIL=0and=1.cargo test --offline --locked -p xcl --lib gpu_buffer_d16_loads_of -- --nocapture --test-threads=1gave 2 passed, 0 failed, 0 ignored, and 0 skips in each mode.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.
@throny on GitHub · 2026-11-25 18:29 UTC · original
Two contributors checked independently and found that #2360 solves the same problem (for #2026) in a different way: #1607, group D102. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@raylitebull on GitHub · 2026-11-25 18:41 UTC · original
Diff review (
norm16_rep/d16_fmtinrecomp/emit.rs+dxil/lower_mem.rsandf16_rtzfloat D16 truncation) and green CI look solid, with exact-head0cab3efNVIDIA and smoke runs verified.Remaining before merge:
0cab3efAMD test run (previous RX 6800M and RX 9070 runs were on earlier commits83d3d05andb0aae2e).#2360per the#1607(D102) triage note.@upipibi on GitHub · 2026-11-25 18:49 UTC · original
@raylitebull On the two points:
0cab3ef: I only have an RTX 3070, so this needs someone with a Radeon card. The earlier RX 6800M and RX 9070 runs were on83d3d05andb0aae2e.f16_rtz, in both backends). #2360 keepsf32tof16, which rounds to nearest. NWProgramming00 measuredbuffer_load_format_d16_xon an RDNA2 gfx1036 with 32_FLOAT: the hardware truncates (6,011 of 6,011 values match truncation, 3,028 match round-to-nearest). Separately, SlopTart's run of #2360 at647932f(comment) shows DXC refusing its prelude helper, becausesnormis a reserved HLSL keyword used as a parameter name there.So on those measurements this PR matches the hardware in both parts. If the maintainers prefer one PR, #2360's UNORM / SNORM routine and this one give the same results for those codes.
AI-assisted (Claude Code, Claude Opus 5.5).
@DavidM1911 on GitHub · 2026-11-26 07:05 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
@luckyteagirl on GitHub · 2026-11-26 09:44 UTC · original
RX 6800M follow-up on exact head
0cab3ef3b46a9b522fd8838051f2c404baa5fa62, as requested. The detached checkout was clean, and the remote PR head was unchanged before and after the runs. Upstream main wasb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.Tested
30.0.13002.13003), Rust 1.99.0 MSVC, DXC/DXIL 1.8.2502.11 from Windows SDK 10.0.26100.0.XCL_ADAPTER=6800MandXCL_REQUIRE_GPU=1, used an isolated Cargo target with incremental compilation and test debug info disabled, and ran the following once withXCL_DIRECT_DXIL=0and once withXCL_DIRECT_DXIL=1.6800Mselector.Not tested
The full workspace suite, retail smoke, other adapters, and a matching run on main were outside this run.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the focused tests, inspected the selector and logs, and drafted this report.
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.