Skip to content

Recompiler: saturate image_load D16 ints and keep odd high half - #1565

Open
hajduzsolt wants to merge 1 commit into
xcl-dev:mainfrom
hajduzsolt:recompiler/image-load-d16-saturate
Open

hajduzsolt wants to merge 1 commit into
xcl-dev:mainfrom
hajduzsolt:recompiler/image-load-d16-saturate

Conversation

@hajduzsolt

@hajduzsolt hajduzsolt commented Nov 24, 2026 •

Copy link
Copy Markdown

Saturates 32-bit integer texels in image_load / image_load_mip when D16=1 and preserves vdst[31:16] on odd dmask channel counts in mimg D16 writeback. Part of #1489.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: add img_d16(uint e, uint cls) to clamp UINT texels to 65535 and SINT texels to [-32768, 32767] before 16-bit packing in image_load / image_load_mip, and preserve existing vdst[31:16] on trailing odd d16 channels in write_result.
  • crates/xcl/src/gpu/recomp/tests.rs: add image_load_d16_translation_uses_saturating_helper_and_preserves_high_half and gpu_image_load_d16_saturates_and_keeps_high_half testing IMAGE_LOAD (dmask

Tested

  • AMD Radeon RX 9070 XT, Windows 11 x64, cargo test --workspace -- --test-threads=2 passed.

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 49 48 14
device removals: 0
crashes: 0
peak commit: 20195 MB

PR:

xcl-smoke v1
commit: baa02bef9b8d3de44847663ebe15045b51a2a0f9
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1646 (PresentX 1646)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14713 MB

Not tested

  • NVIDIA / Intel GPUs, wave32-only adapters, and gameplay beyond title menus.

AI use

  • Antigravity (Gemini 4 Hydrogen, High): automated PR verification runner.

image_load / image_load_mip with D16=1 truncated 32-bit UINT/SINT texels with & 0xFFFFu instead of clamping to [0, 65535] / [-32768, 32767], and MIMG D16 writeback zeroed vdst[31:16] on odd channel counts instead of preserving the existing high 16 bits.

Add img_d16() clamping and preserve (vdst & 0xFFFF0000u) when writing the trailing odd channel in write_result.

Part of xcl-dev#1489

Assisted-by: Antigravity (Gemini 4 Hydrogen, high)
@hajduzsolt
hajduzsolt force-pushed the recompiler/image-load-d16-saturate branch from 960ffb7 to baa02be Compare November 24, 2026 18:54
@hajduzsolt
hajduzsolt marked this pull request as ready for review November 24, 2026 19:19
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent Windows/D3D12 verification of PR #1565 at clean head baa02bef9b8d3de44847663ebe15045b51a2a0f9. The PR was open at that SHA before and after the run.

  • Intel Arc A770 (driver 32.0.101.9175), AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5.
  • cargo test --locked -p xcl --lib -j 2 --no-run completed outside the Arc lock with CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, and CARGO_PROFILE_TEST_DEBUG=0.
  • I ran the two exact filters below on that test binary. For the GPU run I set XCL_ADAPTER=A770, XCL_DIRECT_DXIL=0, XCL_REQUIRE_GPU=wave64, and XCL_DXC_DIR to the DXC 1.9.2609 x64 directory under %LOCALAPPDATA%. The GPU test ran under L:/XclTooling/Invoke-ArcTest.ps1 -WaitMinutes 30.
& $testExe gpu::recomp::tests::image_load_d16_translation_uses_saturating_helper_and_preserves_high_half --exact --nocapture --test-threads=1
& $testExe gpu::recomp::tests::gpu_image_load_d16_saturates_and_keeps_high_half --exact --nocapture --test-threads=1
Test Passed Failed Ignored Skipped Filtered out
HLSL translation 1 0 0 0 832
Arc A770, HLSL/DXC 1 0 0 0 832

The translation test checked the upper-half masks for a one-channel IMAGE_LOAD and a three-channel IMAGE_LOAD_MIP. On the GPU, all 64 lanes kept 0xCAFE and 0xABCD for the one-channel UINT and FLOAT IMAGE_LOAD results, and 0xBEEF in the trailing register for the three-channel SINT load. The one-channel SINT IMAGE_LOAD_MIP at mip 0 returned 0xDEAD8000 on all 64 lanes, preserving 0xDEAD while writing the expected low half. Ordinary integer saturation on both backends was already covered in the #2042 Arc report.

Not tested

Nonzero mip levels, direct DXIL on this head, the workspace suite, retail-title smoke runs, and other GPU adapters.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in tests, verified the logs, and wrote this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants