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

Open
hajduzsolt wants to merge 1 commit from upstream-pr/1565 into main
hajduzsolt commented 2026-11-24 17:43:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T17:43:33Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5477330989 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1565). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T17:43:33Z. --- 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.
DavidM1911 commented 2026-11-24 21:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:41:25Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7142451988 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7142451988). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:41:25Z. --- 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 commented 2026-11-25 03:05:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:32:36Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7150857989 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7150857989). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T02:32:36Z. --- **Tested** Independent Windows/D3D12 verification of [PR #1565](https://github.com/xcl-dev/xcl/pull/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://github.com/xcl-dev/xcl/pull/2042#issuecomment-7150635724). **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.
github-actions[bot] commented 2026-11-29 20:44:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:22Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262319332 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7262319332). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:22Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:08:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:08:30Z.


Triage (#1607) – head baa02be

Overlaps #2042 (D94): both saturate 32-bit UINT/SINT texels to 16 bits in D16 image_load. #2042 also rounds D16 UNORM/SNORM once and changes the direct-DXIL path (lower_image.rs). This PR instead keeps the odd last high half in write_result, which #2042 does not do. #1977 makes the same two changes for buffer FormatLoad, not MIMG.
Note that the write_result change applies to every D16 MIMG result with an odd component count (samples too), not only image_load. That matches the title but deserves a GPU run on a sampled D16 path. No problems found in the diff.
The branch conflicts with main and needs a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302528297 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1565#issuecomment-7302528297). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:08:30Z. --- **Triage (#1607)** – head baa02be Overlaps #2042 (D94): both saturate 32-bit UINT/SINT texels to 16 bits in D16 `image_load`. #2042 also rounds D16 UNORM/SNORM once and changes the direct-DXIL path (`lower_image.rs`). This PR instead keeps the odd last high half in `write_result`, which #2042 does not do. #1977 makes the same two changes for buffer FormatLoad, not MIMG. Note that the `write_result` change applies to every D16 MIMG result with an odd component count (samples too), not only `image_load`. That matches the title but deserves a GPU run on a sampled D16 path. No problems found in the diff. The branch conflicts with main and needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1565:upstream-pr/1565'
git switch 'upstream-pr/1565'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1565'
git switch 'upstream-pr/1565'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1565'
git switch 'upstream-pr/1565'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1565'
git switch 'main'
git merge --squash 'upstream-pr/1565'
git switch 'main'
git merge --ff-only 'upstream-pr/1565'
git switch 'main'
git merge 'upstream-pr/1565'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1555
No description provided.