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

Open
github-bot wants to merge 1 commit from github-bot/gh-1565 into main AGit
Owner

@⁠hajduzsolt on GitHub · 2026-11-24 17:43 UTC · original
hajduzsolt:recompiler/image-load-d16-saturate → main · +91 −3 · 2 files · 1 commits · open

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.
**@⁠hajduzsolt** on GitHub · 2026-11-24 17:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1565) `hajduzsolt:recompiler/image-load-d16-saturate` → `main` · +91 −3 · 2 files · 1 commits · open 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 #1489

Assisted-by: Antigravity (Gemini 4 Hydrogen, high)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:42 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:41 UTC · original

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

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

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 19:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7142451988) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 02:32 UTC · original

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.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 02:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7150857989) **Tested** Independent Windows/D3D12 verification of [PR #1565](https://git.gtahub.st/github/xcl-dev--xcl/pulls/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`. ```powershell & $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](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2042). **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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1565/head:github-bot/gh-1565'
git switch 'github-bot/gh-1565'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1565'
git switch 'github-bot/gh-1565'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1565'
git switch 'github-bot/gh-1565'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1565'
git switch 'main'
git merge --squash 'github-bot/gh-1565'
git switch 'main'
git merge --ff-only 'github-bot/gh-1565'
git switch 'main'
git merge 'github-bot/gh-1565'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.