Recompiler: D16 image loads of 32-bit integer texels saturate to 16 bits #2042
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!2042
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2042"
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:44 UTC · original
upipibi:fix/image-d16-int-saturate→main· +632 −28 · 5 files · 6 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. This PR is stacked on #2030 and gets it the same way.Stacked on #2030 (itself on #2027): only the last commit (
Recompiler: D16 image loads of 32-bit integer texels saturate to 16 bits) belongs to this PR. It edits the same image D16 packing as #2030. Part of #2026; XCL-BT-028 in #1489.image_loadwithD16=1kept the low 16 bits of a 32-bit UINT / SINT texel, so 70000 loaded as0x1170. RDNA2 saturates instead: UINT to0xFFFF, SINT to-32768..32767(boykopovar/AnyPS5#22750, gfx1036). A second native gfx1036 measurement (through HIP, by andrewpozdnakov7-jpg in Marvisak/VIctory#2125) agrees: D16 loads of R32 and R32G32 UINT/SINT saturate, including values where saturation and keeping the low 16 bits differ, onimage_loadandimage_load_mip(mip 0) for 1D, 2D, 2D array and 3D. This is the image counterpart of #1977's buffer change.Overlap with #1565 (#1607 group D94): both saturate integer channels in the HLSL emitter's image-load D16 packing, and those hunks conflict (
emit.rs,tests.rs), so whichever lands second needs a rebase there. #1565 also keeps the destination register's high half when the last channel is odd (mainand this PR write 0 there); I haven't measured which one RDNA2 does. This PR also covers the direct DXIL backend (dxil/lower_image.rs,lower_mem.rs) and, with #2030 under it, the buffer, sample and gather D16 paths, which #1565 doesn't touch.What is in it
recomp/emit.rs: the image-load D16halfclosure saturates integer channels by class (min(e, 0xFFFF)for UINT, a clamp for SINT) instead of& 0xFFFF.dxil/lower_image.rs:Lw::d16_int, used at the load and MSAA-load D16 sites.recomp/tests.rs:gpu_image_d16_loads_saturate_32_bit_integerscovers R32_UINT and R32_SINT textures with values in range and past both ends.8- and 16-bit integer formats never leave that range, so they're unchanged.
c4ed6aewith this PR's commit on top (it used to sit in the middle, under copies of #2030's later commits). So it also carries #2030'sc4ed6ae(the D16 rule in #1951's directgather4_landUNORM=1sample paths).Tested
9dd6a33(this commit on #2030'sc4ed6ae,main426a5a74), RTX 3070 (616.56):d16tests 11 of 11 andgpu_suite (--skip gpu_sparse_vram) 150 passed, 0 failed, 1 ignored, withXCL_DIRECT_DXIL=0and with=1.270774b(rebased ontomain426a5a74, the firstmainwith green CI after5478c4a7, whose two failing tests main fixed in0d13b071), RTX 3070 (616.56):gpu_suite (--skip gpu_sparse_vram) 148 passed, 0 failed withXCL_DIRECT_DXIL=0and with=1.main426a5a74gives 143 passed on both.4bfb5f4, RTX 3070 (616.56):d16tests 9 of 9 on both paths;gpu_suite: 137 passed withXCL_DIRECT_DXIL=0; with1, 136 passed and 1 failed:gpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046). CI Build and test: passing.main5ce558f(rebased; #1947 now keys the translated cache on thegpu/dxilsources, so there is noTRANSLATOR_VERSIONbump):32_UINT 0x11170:0x1170, want0xffff). With it, it 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
9dd6a33againstmain1a0bbe3, 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
4bfb5f4, before the rebase ontomain5478c4a7..Not tested
AI use
🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-25 01:49 UTC · original
Tested
Independent Windows/D3D12 check on exact head
86e9cef31fd6cc7294f70f7a90d649e61a0dd62b. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon(TM) Graphics (32.0.21042.62, native wave64) and 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.cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_image_d16_loads_saturate_32_bit_integers -- --exact --test-threads=1 --nocapturepassed on both GPUs withXCL_DIRECT_DXIL=0and1(1 passed, 0 failed, 0 ignored, 0 skipped per run).cargo test --locked -p xcl --lib gpu::dxil::msaa_tests -- --test-threads=1 --nocapturepassed on both GPUs (5 passed, 0 failed, 0 ignored, 0 skipped per run).cargo test --locked -p xcl --test d16_integer_msaa_gpu_probe -- --exact d16_msaa_integer_reads_saturate_each_sample --test-threads=1 --nocaptureused a temporary Direct DXIL probe with 4× MSAA R32_UINT and R32_SINT textures. It checked D16IMAGE_LOADandIMAGE_MSAA_LOADagainst CPU saturation, including both signed limits and zero for slots past the sample count. Each GPU checked 64 single-sample and 256 packed-sample values per format. The probe also ran on parent2d941f0c62772661a3c844f5f7767122ee31f39e, where it explicitly expected the old low-16-bit behavior. All four probe runs passed their assertions (1 passed, 0 failed, 0 ignored, 0 skipped per run).Not tested
Real-title smoke runs, the full workspace suite, and other multisample counts. The extra multisample probe covered Direct DXIL.
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:51 UTC · original
Diff audit on
86e9ceflooks clean (Lw::d16_intinlower_image.rs+ matchingemit.rsUINT/SINT clamp +gpu_image_d16_loads_saturate_32_bit_integers, already verified across RTX 3070, RTX 5090, and AMD iGPU).Remaining before merge:
#2027and#2030rebase ontomain(dropping the manualTRANSLATOR_VERSIONbump inkernel.rs, since#1947now auto-hashesgpu/dxilsources viaXCL_DIRECT_DXIL_SOURCE_ID).xcl-smoke v1blocks (mainand PR) forPR description.@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.7add2e7as it is (merge base withmain5ce558f), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_image_d16_loads_saturate_32_bit_integers: ok, not skippedNot tested
AI use
@JJAutoCompare on GitHub · 2026-11-25 02:22 UTC · original
Tested
Independent Windows/D3D12 check on clean PR #2042 head
7add2e7250844bec3c130835417ce3a33a6d498a, stacked on #2030 at7009727951604107093a31e9bdc8775a0979a7d8. The PR head matched before and after execution.x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5, unoptimized test profile.cargo test --locked -p xcl --lib -j 2 --no-runsucceeded outside the Arc lock.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 DXC 1.9.2609 x64 directory under%LOCALAPPDATA%, I ran this command underL:/XclTooling/Invoke-ArcTest.ps1 -WaitMinutes 60 -Test { … }once per backend.XCL_DIRECT_DXIL=0)XCL_DIRECT_DXIL=1, no fallback in this test)Each run checked 64 lane results per format.
R32_UINTsaturated to0xFFFFandR32_SINTsaturated at both-32768and32767. In-range texels produced their expected values. This covers the signed and unsigned integerIMAGE_LOADcases. The prior #2030 result covers normalized image conversion, and #1977 covers D16 bufferFormatLoad.Not tested
MSAA and mip image loads, odd-channel high-half preservation, the full workspace suite, retail-title smoke runs, and other GPU adapters. The #2030 and #1977 tests were outside this run.
AI use
T3 Code / Codex (
gpt-6.2-sol) ran the checked-in test on both backends, verified the logs, and drafted this report.@DavidM1911 on GitHub · 2026-11-25 04:28 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!
@Toons29 on GitHub · 2026-11-25 10:16 UTC · original
Regression run of
4bfb5f41on 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:32 UTC · original
Here is the requested
scripts/smoke.ps1pair from clean release builds of main 1a0bbe3 and PR head 9dd6a33.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_image_d16_ -- --nocapture --test-threads=1reported 5 passed, 0 failed, 0 ignored with each ofXCL_DIRECT_DXIL=0and=1. The unnormalized-coordinate case runs only in direct DXIL and returns early in HLSL, so four fixtures executed GPU work under HLSL and five under direct DXIL. The UINT/SINT saturation fixture ran in both modes.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:18 UTC · original
Two contributors checked independently and found that #1565 solves the same problem (for #1489) in a different way: #1607, group D94. 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.
@upipibi on GitHub · 2026-11-25 22:58 UTC · original
@CalvyPZ could you reopen this one? It isn't a duplicate by #1607's own checks: group D94 (#1565, #2042) has two checks, by oni-swr (7167979724) and NWProgramming00 (7170477355), and both read "different approaches". The table row says: "1565 saturates integer d16 loads and keeps the odd high half in the hlsl; 2042 saturates too but also rounds unorm / snorm d16 once, is sampler-aware, and changes the direct dxil" path.
What this PR covers that #1565 doesn't: the direct DXIL backend (
dxil/lower_image.rs,lower_mem.rs), and, with #2030 under it, the buffer, sample and gather D16 paths. #1565 changes only the HLSL image-load packing. #1565 was closed at the same time; with both closed I found no other open PR for #1489's XCL-BT-028 on images (searched PR titles and bodies).The two do conflict in
emit.rs/tests.rs, so whichever lands second needs a rebase; I'm happy to do that on this side. I can't reopen it myself (GitHub refuses the reopen for the author here).AI-assisted (Claude Code, Claude Opus 5.5).
@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.