Direct DXIL: reject image_gather4h/8h instead of translating as 2x2 Gather #2060

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

@⁠Decodere on GitHub · 2026-11-25 02:22 UTC · original
Decodere:fix-1269-dxil-reject-gather4h → main · +30 −0 · 1 files · 1 commits · open

Brings direct DXIL Lw::mimg (crates/xcl/src/gpu/dxil/lower_image.rs) into parity with merged PR #437 (recomp/emit.rs) by rejecting IMAGE_GATHER4H, IMAGE_GATHER4H_PCK, and IMAGE_GATHER8H_PCK with image_gather4h instead of silently miscompiling them as 2x2 dx.op.textureGather or falling through to non-sampling MIMG. Part of #1269.

image_gather4h, image_gather4h_pck, and image_gather8h_pck fetch a horizontal row of texels rather than a 2x2 Gather footprint. Previously, Lw::mimg matched base.starts_with("gather4"), causing IMAGE_GATHER4H and IMAGE_GATHER4H_PCK to emit 2x2 dx.op.textureGather calls (while IMAGE_GATHER8H_PCK fell through to non-sampling MIMG).

What is in it

  • crates/xcl/src/gpu/dxil/lower_image.rs:
    • Reject base.starts_with("gather4h") || base.starts_with("gather8h") at the top of Lw::mimg with err(d, "image_gather4h"), matching recomp/emit.rs (#437).
    • Add direct_image_gather4h_and_8h_are_rejected verifying all three instructions are rejected with image_gather4h across wave32 compute, wave64 compute, and pixel shaders, while standard IMAGE_GATHER4 still translates and passes DXIL validation.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (0ef1bc386), DXC 1.9.2609.5 (01b62ad4), release build.
  • Pre-fix reproduction: confirmed direct_image_gather4h_and_8h_are_rejected fails before the fix (IMAGE_GATHER4H wave64=false must be rejected: silently translated to DXBC).
  • Targeted post-fix runs (0 failures, 0 skipped):
    • cargo test --release -p xcl --lib gpu::dxil::lower_image::heap_bounds_tests -- --nocapture: 3 passed, 0 failed, 0 ignored.
    • cargo test --release -p xcl --lib image_gather4h_is_unsupported -- --nocapture: 1 passed, 0 failed, 0 ignored.
  • cargo build --release --workspace + cargo test --release --workspace -- --test-threads=4: 1147 passed, 0 failed, 46 ignored across 20 test binaries.
  • SKIPPED GPU/runtime tests on this adapter (25 lines):
    • 20 no wave64 subcases across gpu::recomp::lower::tests (4), gpu::recomp::lower_dxil::tests (14), and gpu::recomp::tests (2)
    • 3 intentional per-lane #1426 refusals (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32) in gpu::recomp::lower_dxil::tests
    • shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)
    • heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows

Regression run
scripts/smoke.ps1 on main (5ce558f82a48c51d527f6035234dacbd29db3f05) and on this PR's head commit (1933324629a73931a2a52dbf4fff5bf3472a1412):

xcl-smoke v1
commit: 5ce558f82a48c51d527f6035234dacbd29db3f05
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14517 MB
xcl-smoke v1
commit: 1933324629a73931a2a52dbf4fff5bf3472a1412
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1590 (PresentX 1590)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14518 MB

Not tested

  • Emulating image_gather4h / image_gather8h horizontal row fetches (this PR rejects them in direct DXIL for parity with HLSL #437).
  • AMD/Intel GPUs, native wave64 hardware, and debug-profile full workspace test run (the full suite ran in --release).

AI use

  • Google Antigravity (Gemini 4 Neon) — audited Lw::mimg against HLSL #437, implemented the rejection check, unit test, and PR description; all tests and paired 60s smoke runs were executed and verified locally on RTX 4060 hardware.
**@⁠Decodere** on GitHub · 2026-11-25 02:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2060) `Decodere:fix-1269-dxil-reject-gather4h` → `main` · +30 −0 · 1 files · 1 commits · open Brings direct DXIL `Lw::mimg` (`crates/xcl/src/gpu/dxil/lower_image.rs`) into parity with merged PR #437 (`recomp/emit.rs`) by rejecting `IMAGE_GATHER4H`, `IMAGE_GATHER4H_PCK`, and `IMAGE_GATHER8H_PCK` with `image_gather4h` instead of silently miscompiling them as 2x2 `dx.op.textureGather` or falling through to non-sampling MIMG. Part of #1269. `image_gather4h`, `image_gather4h_pck`, and `image_gather8h_pck` fetch a horizontal row of texels rather than a 2x2 `Gather` footprint. Previously, `Lw::mimg` matched `base.starts_with("gather4")`, causing `IMAGE_GATHER4H` and `IMAGE_GATHER4H_PCK` to emit 2x2 `dx.op.textureGather` calls (while `IMAGE_GATHER8H_PCK` fell through to non-sampling MIMG). **What is in it** - `crates/xcl/src/gpu/dxil/lower_image.rs`: - Reject `base.starts_with("gather4h") || base.starts_with("gather8h")` at the top of `Lw::mimg` with `err(d, "image_gather4h")`, matching `recomp/emit.rs` (#437). - Add `direct_image_gather4h_and_8h_are_rejected` verifying all three instructions are rejected with `image_gather4h` across wave32 compute, wave64 compute, and pixel shaders, while standard `IMAGE_GATHER4` still translates and passes DXIL validation. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (`0ef1bc386`), DXC 1.9.2609.5 (`01b62ad4`), release build. - Pre-fix reproduction: confirmed `direct_image_gather4h_and_8h_are_rejected` fails before the fix (`IMAGE_GATHER4H wave64=false must be rejected`: silently translated to DXBC). - Targeted post-fix runs (0 failures, 0 skipped): - `cargo test --release -p xcl --lib gpu::dxil::lower_image::heap_bounds_tests -- --nocapture`: 3 passed, 0 failed, 0 ignored. - `cargo test --release -p xcl --lib image_gather4h_is_unsupported -- --nocapture`: 1 passed, 0 failed, 0 ignored. - `cargo build --release --workspace` + `cargo test --release --workspace -- --test-threads=4`: 1147 passed, 0 failed, 46 ignored across 20 test binaries. - `SKIPPED` GPU/runtime tests on this adapter (25 lines): - 20 `no wave64` subcases across `gpu::recomp::lower::tests` (4), `gpu::recomp::lower_dxil::tests` (14), and `gpu::recomp::tests` (2) - 3 intentional per-lane `#1426` refusals (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`) in `gpu::recomp::lower_dxil::tests` - `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)` - `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows` **Regression run** `scripts/smoke.ps1` on `main` (`5ce558f82a48c51d527f6035234dacbd29db3f05`) and on this PR's head commit (`1933324629a73931a2a52dbf4fff5bf3472a1412`): ``` xcl-smoke v1 commit: 5ce558f82a48c51d527f6035234dacbd29db3f05 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14517 MB ``` ``` xcl-smoke v1 commit: 1933324629a73931a2a52dbf4fff5bf3472a1412 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1590 (PresentX 1590) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14518 MB ``` **Not tested** - Emulating `image_gather4h` / `image_gather8h` horizontal row fetches (this PR rejects them in direct DXIL for parity with HLSL `#437`). - AMD/Intel GPUs, native wave64 hardware, and debug-profile full workspace test run (the full suite ran in `--release`). **AI use** - Google Antigravity (Gemini 4 Neon) — audited `Lw::mimg` against HLSL `#437`, implemented the rejection check, unit test, and PR description; all tests and paired 60s smoke runs were executed and verified locally on RTX 4060 hardware.
Merged PR #437 rejected `IMAGE_GATHER4H`, `IMAGE_GATHER4H_PCK`, and
`IMAGE_GATHER8H_PCK` in the HLSL emitter (`recomp/emit.rs`), because
they fetch a horizontal row of texels rather than a 2x2 `Gather`
footprint. Direct DXIL (`dxil/lower_image.rs`) still matched
`base.starts_with("gather4")`, silently miscompiling `IMAGE_GATHER4H`
and `IMAGE_GATHER4H_PCK` as 2x2 `dx.op.textureGather` while letting
`IMAGE_GATHER8H_PCK` fall through to non-sampling MIMG.

Reject `gather4h*` and `gather8h*` at the top of `Lw::mimg` with
`err(d, "image_gather4h")` (matching HLSL `#437`), and add a unit test
verifying rejection across wave32, wave64, and pixel shaders while
standard `IMAGE_GATHER4` still translates and passes DXIL validation.

Part of #1269

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:02 +00:00
Author
Owner

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

PR #2060 ordinary compatibility verification

Verified the open head 1933324629a73931a2a52dbf4fff5bf3472a1412 before and after testing. The assigned detached checkout was clean. GitHub showed zero conversation comments, submitted reviews, and inline review threads. PR #2060

Tested

Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 with driver 32.0.101.9175, Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), DXC and DXIL 1.9.2609.5. These tests execute on the CPU.

The unoptimized Cargo test profile used two build jobs, CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, and CARGO_PROFILE_TEST_DEBUG=0. The run set CARGO_TARGET_DIR=L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target, TEMP=TMP=L:/XclTooling/pr2060, XCL_ADAPTER=A770, and XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64 for the test process.

cargo test -j 2 -p xcl --lib --no-run
cargo test -j 2 -p xcl --lib gpu::dxil::lower_image::heap_bounds_tests::direct_image_gather4h_and_8h_are_rejected -- --exact --nocapture
cargo test -j 2 -p xcl --lib gpu::recomp::tests::image_gather4h_is_unsupported -- --exact --nocapture
  • Prebuild completed in 57.847 s wall time with exit code 0.
  • Direct DXIL passed in 4.043 s wall time (0.02 s in the test harness). All nine rejection assertions passed for IMAGE_GATHER4H, IMAGE_GATHER4H_PCK, and IMAGE_GATHER8H_PCK across wave32 compute, wave64 compute, and pixel translation. Each error contained image_gather4h. The standard IMAGE_GATHER4 control translated and passed the DXC validator. The log confirmed DXC and DXIL 1.9.2609.5 and recorded zero validation skips.
  • HLSL passed in 0.177 s wall time (0.00 s in the test harness). Translation was incomplete for all three horizontal instructions and included the expected <lowercase opcode>: image_gather4h diagnostic keys.
  • Total: 2 passed, 0 failed, 0 ignored, 0 skipped. Each exact command selected one test and filtered out 1,119. Raw logs are prebuild.log, direct.log, and hlsl.log alongside this report.

Not tested

GPU execution, retail title smoke testing, the full workspace suite, and the pre-fix revision.

AI use

T3 Code / Codex (gpt-6.2-sol) verified the PR head, ran the two CPU tests, and wrote this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 02:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/2060#issuecomment-7151101612) # PR #2060 ordinary compatibility verification Verified the open head `1933324629a73931a2a52dbf4fff5bf3472a1412` before and after testing. The assigned detached checkout was clean. GitHub showed zero conversation comments, submitted reviews, and inline review threads. [PR #2060](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2060) **Tested** Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 with driver 32.0.101.9175, Rust 1.100.0 (`0ef1bc386`, `x86_64-pc-windows-msvc`), DXC and DXIL 1.9.2609.5. These tests execute on the CPU. The unoptimized Cargo test profile used two build jobs, `CARGO_INCREMENTAL=0`, `CARGO_PROFILE_DEV_DEBUG=0`, and `CARGO_PROFILE_TEST_DEBUG=0`. The run set `CARGO_TARGET_DIR=L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target`, `TEMP=TMP=L:/XclTooling/pr2060`, `XCL_ADAPTER=A770`, and `XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64` for the test process. ```text cargo test -j 2 -p xcl --lib --no-run cargo test -j 2 -p xcl --lib gpu::dxil::lower_image::heap_bounds_tests::direct_image_gather4h_and_8h_are_rejected -- --exact --nocapture cargo test -j 2 -p xcl --lib gpu::recomp::tests::image_gather4h_is_unsupported -- --exact --nocapture ``` - Prebuild completed in 57.847 s wall time with exit code 0. - Direct DXIL passed in 4.043 s wall time (0.02 s in the test harness). All nine rejection assertions passed for `IMAGE_GATHER4H`, `IMAGE_GATHER4H_PCK`, and `IMAGE_GATHER8H_PCK` across wave32 compute, wave64 compute, and pixel translation. Each error contained `image_gather4h`. The standard `IMAGE_GATHER4` control translated and passed the DXC validator. The log confirmed DXC and DXIL 1.9.2609.5 and recorded zero validation skips. - HLSL passed in 0.177 s wall time (0.00 s in the test harness). Translation was incomplete for all three horizontal instructions and included the expected `<lowercase opcode>: image_gather4h` diagnostic keys. - Total: 2 passed, 0 failed, 0 ignored, 0 skipped. Each exact command selected one test and filtered out 1,119. Raw logs are `prebuild.log`, `direct.log`, and `hlsl.log` alongside this report. **Not tested** GPU execution, retail title smoke testing, the full workspace suite, and the pre-fix revision. **AI use** T3 Code / Codex (gpt-6.2-sol) verified the PR head, ran the two CPU tests, and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 04:55 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!

**@⁠DavidM1911** on GitHub · 2026-11-25 04:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2060#issuecomment-7153282508) 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!
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 14:49 UTC · original

amd-win test report for head 1933324629a73931a2a52dbf4fff5bf3472a1412

Setup

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke
  • Tested as a local merge of the PR head onto main 06c9f5505f63f10c5ec49ef932d75b2c28177324 (merge commit db1626790d66bce3423abe19951332eea4beaecc; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit.

Tests

  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 1265 passed, 1 failed, 46 ignored, 7 SKIPPED lines (f16/f32 per-lane form, no heap windows)
  • The 1 failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] GPU 0x1 vs CPU 0x7fffffff). It fails the same way on main (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR.
  • The PR's new test gpu::dxil::lower_image::heap_bounds_tests::direct_image_gather4h_and_8h_are_rejected passes.

Regression run (60 s, same title, networking off; main first, then the merge)

xcl-smoke v1  main 06c9f5505f63f10c5ec49ef932d75b2c28177324
frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB
xcl-smoke v1  merge db1626790d66bce3423abe19951332eea4beaecc
frames shown: 1492, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16313 MB

Exit code 0x0 on both. The full xcl-smoke blocks are not pasted because of the merge-commit caveat above.

Not tested

  • The title was not checked to reach image_gather4h/8h, so the smoke run only shows no regression on the code paths it does reach.
  • NVIDIA, wave32-only GPUs.

AI use: this run and report were done by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2060#issuecomment-7165870436) **amd-win test report** for head `1933324629a73931a2a52dbf4fff5bf3472a1412` **Setup** - AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke - Tested as a local merge of the PR head onto `main` `06c9f5505f63f10c5ec49ef932d75b2c28177324` (merge commit `db1626790d66bce3423abe19951332eea4beaecc`; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit. **Tests** - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **1265 passed, 1 failed, 46 ignored**, 7 `SKIPPED` lines (f16/f32 per-lane form, no heap windows) - The 1 failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722: `res[30]` GPU 0x1 vs CPU 0x7fffffff). It fails the same way on `main` (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR. - The PR's new test `gpu::dxil::lower_image::heap_bounds_tests::direct_image_gather4h_and_8h_are_rejected` passes. **Regression run** (60 s, same title, networking off; `main` first, then the merge) ``` xcl-smoke v1 main 06c9f5505f63f10c5ec49ef932d75b2c28177324 frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB xcl-smoke v1 merge db1626790d66bce3423abe19951332eea4beaecc frames shown: 1492, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16313 MB ``` Exit code 0x0 on both. The full `xcl-smoke` blocks are not pasted because of the merge-commit caveat above. **Not tested** - The title was not checked to reach `image_gather4h/8h`, so the smoke run only shows no regression on the code paths it does reach. - NVIDIA, wave32-only GPUs. **AI use:** this run and report were done by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 17:26 UTC · original

NVIDIA test report for 1933324 (head as is, base 5ce558f), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after cargo build --workspace:

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1138 passed, 0 failed, 46 ignored. The end-to-end title tests pass.
  • main 0829441 on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).
  • Skipped hle::xaudio2, because its tests fail or hang on this machine on main too. The PR doesn't touch it.
  • SKIPPED lines: 25: 20 no wave64 on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off.

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.

**@⁠upipibi** on GitHub · 2026-11-25 17:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2060#issuecomment-7169506148) NVIDIA test report for `1933324` (head as is, base `5ce558f`), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after `cargo build --workspace`: - `cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2`: **1138 passed, 0 failed, 46 ignored**. The end-to-end title tests pass. - `main` `0829441` on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests). - Skipped `hle::xaudio2`, because its tests fail or hang on this machine on `main` too. The PR doesn't touch it. - SKIPPED lines: 25: 20 `no wave64` on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off. AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
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/2060/head:github-bot/gh-2060'
git switch 'github-bot/gh-2060'

Merge

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