Recompiler: reject image_gather4h/8h instead of translating as 2x2 Gather #437

Manually merged
github merged 1 commit from gh-pr/437/head into gh-pr/437/base 2026-11-26 04:21:48 +00:00
Owner

@⁠sennecools on GitHub · 2026-11-24 00:16 UTC · original
sennecools:recomp-mimg-gather4h → main · +17 −0 · 2 files · 1 commits · merged 2026-11-25 01:06 UTC

image_gather4h, image_gather4h_pck and image_gather8h_pck fetch a horizontal row of texels. mimg() matched them by the gather4 prefix, ignored the leftover h / h_pck as modifiers and emitted a 2x2 Gather, which reads the wrong texels. They are now reported as unsupported (image_gather4h) until the row's position and rounding are measured on hardware. Plain gather4* is unchanged.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: an early Err("image_gather4h") in mimg() for gather4h* / gather8h*
  • crates/xcl/src/gpu/recomp/tests.rs: image_gather4h_is_unsupported checks that all three opcodes leave the translation incomplete, with that reason

Tested

  • AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.98.1, release build
  • cargo test --workspace -- --test-threads=4: 667 passed, 0 failed, 41 ignored; no SKIPPED tests
  • With only the emit.rs change reverted, image_gather4h_is_unsupported fails (0 passed, 1 failed)
  • The retail title shader pack (xcl shaders, 26,503 shaders, 44.4 M instructions) uses none of the three opcodes, so this title never reaches the change.

Regression run
The retail title, 120 s, offline. The gpu: line shows a virtual display adapter that smoke.ps1 picked up. The GPU is the RX 9070 XT above; which adapter XCL used was not checked.

main:

xcl-smoke v1
commit: db1ddb25f3ff0c1686eed8200d238ad35f895926
gpu: Meta Virtual Monitor
title: 2c508222
seconds: 120
exit: 0x0
frames shown: 2748 (PresentX 2748)
presents per 2 s (last 3): 53 52 52
device removals: 0
crashes: 0
peak commit: 15544 MB

this PR:

xcl-smoke v1
commit: 1130bc55d1abe860139315ce43630486f8e2affd
gpu: Meta Virtual Monitor
title: 2c508222
seconds: 120
exit: 0x0
frames shown: 2597 (PresentX 2597)
presents per 2 s (last 3): 43 43 44
device removals: 0
crashes: 0
peak commit: 15533 MB

That is 94.5 % of main's frames. An earlier main run on the same commit showed 2571 frames.

Not tested

  • Any title that uses these opcodes. The retail title does not, so the smoke run only checks for regressions.
  • The correct gather4h/8h behaviour. It is not implemented, so there is no GPU test against expected texels.
  • NVIDIA, Intel, other AMD GPUs.

AI use

  • Claude Code, Claude Opus 5.5 (wrote the change and the test; a person reviewed and opens the PR)
**@⁠sennecools** on GitHub · 2026-11-24 00:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/437) `sennecools:recomp-mimg-gather4h` → `main` · +17 −0 · 2 files · 1 commits · merged 2026-11-25 01:06 UTC `image_gather4h`, `image_gather4h_pck` and `image_gather8h_pck` fetch a horizontal row of texels. `mimg()` matched them by the `gather4` prefix, ignored the leftover `h` / `h_pck` as modifiers and emitted a 2x2 `Gather`, which reads the wrong texels. They are now reported as unsupported (`image_gather4h`) until the row's position and rounding are measured on hardware. Plain `gather4*` is unchanged. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: an early `Err("image_gather4h")` in `mimg()` for `gather4h*` / `gather8h*` - `crates/xcl/src/gpu/recomp/tests.rs`: `image_gather4h_is_unsupported` checks that all three opcodes leave the translation incomplete, with that reason **Tested** - AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.98.1, release build - `cargo test --workspace -- --test-threads=4`: 667 passed, 0 failed, 41 ignored; no `SKIPPED` tests - With only the `emit.rs` change reverted, `image_gather4h_is_unsupported` fails (0 passed, 1 failed) - The retail title shader pack (`xcl shaders`, 26,503 shaders, 44.4 M instructions) uses none of the three opcodes, so this title never reaches the change. **Regression run** The retail title, 120 s, offline. The `gpu:` line shows a virtual display adapter that `smoke.ps1` picked up. The GPU is the RX 9070 XT above; which adapter XCL used was not checked. main: ``` xcl-smoke v1 commit: db1ddb25f3ff0c1686eed8200d238ad35f895926 gpu: Meta Virtual Monitor title: 2c508222 seconds: 120 exit: 0x0 frames shown: 2748 (PresentX 2748) presents per 2 s (last 3): 53 52 52 device removals: 0 crashes: 0 peak commit: 15544 MB ``` this PR: ``` xcl-smoke v1 commit: 1130bc55d1abe860139315ce43630486f8e2affd gpu: Meta Virtual Monitor title: 2c508222 seconds: 120 exit: 0x0 frames shown: 2597 (PresentX 2597) presents per 2 s (last 3): 43 43 44 device removals: 0 crashes: 0 peak commit: 15533 MB ``` That is 94.5 % of main's frames. An earlier main run on the same commit showed 2571 frames. **Not tested** - Any title that uses these opcodes. The retail title does not, so the smoke run only checks for regressions. - The correct gather4h/8h behaviour. It is not implemented, so there is no GPU test against expected texels. - NVIDIA, Intel, other AMD GPUs. **AI use** - Claude Code, Claude Opus 5.5 (wrote the change and the test; a person reviewed and opens the PR)
gather4h, gather4h_pck and gather8h_pck fetch a horizontal row of texels,
but the prefix match on "gather4" sent them down the Gather path and
returned a 2x2 footprint. Report them as unsupported until the row's
position and rounding are measured.

AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:21:47 +00:00
github manually merged commit 1130bc55d1 into gh-pr/437/base 2026-11-26 04:21:48 +00:00
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-24 00:30 UTC · original

Code audit + NVIDIA RTX 5080 test run on 1130bc55d1abe860139315ce43630486f8e2affd:

Review

Looks clean:

  • Catching base.starts_with("gather4h") || base.starts_with("gather8h") right before base.starts_with("gather4") (emit.rs:2007) cleanly stops horizontal row gathers (IMAGE_GATHER4H, IMAGE_GATHER4H_PCK, IMAGE_GATHER8H_PCK) from silently miscompiling as 2x2 Gather, and records them under image_gather4h.

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), rustc 1.100.0 (MSVC), debug build.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 667 passed, 0 failed, 41 ignored.
  • New test gpu::recomp::tests::image_gather4h_is_unsupported: passed.
  • SKIPPED GPU tests (2, wave32-only adapter): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.

Not tested

  • Retail title / scripts/smoke.ps1 run (test suite only).
  • AMD / Intel GPUs.

AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.

**@⁠mastrr9** on GitHub · 2026-11-24 00:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/437#issuecomment-7118144119) Code audit + NVIDIA RTX 5080 test run on `1130bc55d1abe860139315ce43630486f8e2affd`: ### Review Looks clean: - Catching `base.starts_with("gather4h") || base.starts_with("gather8h")` right before `base.starts_with("gather4")` (`emit.rs:2007`) cleanly stops horizontal row gathers (`IMAGE_GATHER4H`, `IMAGE_GATHER4H_PCK`, `IMAGE_GATHER8H_PCK`) from silently miscompiling as 2x2 `Gather`, and records them under `image_gather4h`. ### Tested - Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), `rustc 1.100.0` (MSVC), debug build. - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: **667 passed, 0 failed, 41 ignored**. - New test `gpu::recomp::tests::image_gather4h_is_unsupported`: **passed**. - `SKIPPED` GPU tests (2, wave32-only adapter): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64`. ### Not tested - Retail title / `scripts/smoke.ps1` run (test suite only). - AMD / Intel GPUs. *AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.*
Author
Owner

@⁠AC-Storm-YT on GitHub · 2026-11-24 00:35 UTC · original

Test run on AMD RDNA4 – commit 1130bc5 (this PR's head, as is), clean tree

Tested

  • AMD Radeon RX 9070 XT (RDNA4, wave64), driver 32.0.32029.2010 – the tests ran on it (backend 'real' – AMD Radeon RX 9070 XT); AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11
  • cargo build --workspace: ok
  • cargo test --workspace -- --test-threads=4: 667 passed, 0 failed, 41 ignored. No SKIPPED tests.
  • The new test passes: image_gather4h_is_unsupported

Not tested

  • No retail title or smoke.ps1 run
  • Release build; this commit merged with current main

Run and report: Claude Code (Claude Opus 5.5).

**@⁠AC-Storm-YT** on GitHub · 2026-11-24 00:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/437#issuecomment-7118230595) Test run on AMD RDNA4 – commit `1130bc5` (this PR's head, as is), clean tree **Tested** - AMD Radeon RX 9070 XT (RDNA4, wave64), driver 32.0.32029.2010 – the tests ran on it (`backend 'real' – AMD Radeon RX 9070 XT`); AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug; DXC 1.8.2502.11 - `cargo build --workspace`: ok - `cargo test --workspace -- --test-threads=4`: 667 passed, 0 failed, 41 ignored. No SKIPPED tests. - The new test passes: `image_gather4h_is_unsupported` **Not tested** - No retail title or `smoke.ps1` run - Release build; this commit merged with current `main` Run and report: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠TheHoracio on GitHub · 2026-11-24 00:36 UTC · original

Test report on AMD RDNA3: RX 7800 XT (16 GB), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used.

Tested: the PR head 1130bc5 as it is (on its base db1ddb2, not merged onto current main).

  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 667 passed, 0 failed, 41 ignored, no SKIPPED tests.
  • The new image_gather4h_is_unsupported passes.

Not tested: a regression run on a title, a release build, and the head merged onto current main.

AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above.

**@⁠TheHoracio** on GitHub · 2026-11-24 00:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/437#issuecomment-7118249413) Test report on **AMD RDNA3**: RX 7800 XT (16 GB), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. **Tested:** the PR head `1130bc5` as it is (on its base `db1ddb2`, not merged onto current main). - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **667 passed, 0 failed, 41 ignored**, no SKIPPED tests. - The new `image_gather4h_is_unsupported` passes. **Not tested:** a regression run on a title, a release build, and the head merged onto current `main`. AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above.
Author
Owner

@⁠4usphs on GitHub · 2026-11-24 00:38 UTC · original

Test run of this PR merged onto current main a6f5f7a (local merge, no conflicts): cargo test --workspace -- --test-threads=4 gives 677 passed, 0 failed, 41 ignored, 0 SKIPPED (676 on main plus the new test). The PR's head 1130bc5 on its own: 667 / 0 / 41.

RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0, debug build. This is the same hardware as the PR's own run.

On which opcodes were miscompiled before (the description and the review above say all three): a note from the tool, which I could not review myself. With emit.rs set back to main, gather4h and gather4h_pck translate without a reject. gather8h_pck was already refused (image_gather8h_pck: MIMG), because it does not start with gather4. So for that opcode the PR only changes the reason. The change itself is fine either way.

Not tested: smoke or a retail title, a release build, other GPUs.

AI use: Claude Code (Claude Opus 5.5) ran the tests on my PC and wrote this comment. I have not reviewed the code.

**@⁠4usphs** on GitHub · 2026-11-24 00:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/437#issuecomment-7118272569) Test run of this PR merged onto current `main` `a6f5f7a` (local merge, no conflicts): `cargo test --workspace -- --test-threads=4` gives **677 passed, 0 failed, 41 ignored**, 0 `SKIPPED` (676 on `main` plus the new test). The PR's head `1130bc5` on its own: 667 / 0 / 41. RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0, debug build. This is the same hardware as the PR's own run. On which opcodes were miscompiled before (the description and the review above say all three): a note from the tool, which I could not review myself. With `emit.rs` set back to `main`, `gather4h` and `gather4h_pck` translate without a reject. `gather8h_pck` was already refused (`image_gather8h_pck: MIMG`), because it does not start with `gather4`. So for that opcode the PR only changes the reason. The change itself is fine either way. **Not tested:** smoke or a retail title, a release build, other GPUs. **AI use:** Claude Code (Claude Opus 5.5) ran the tests on my PC and wrote this comment. I have not reviewed the code.
This discussion has been locked. Commenting is limited to contributors.
No description provided.