Tests: image instructions in the per-lane lowering and on the GPU #1815

Closed
MiguelMachado-dev wants to merge 2 commits from upstream-pr/1825 into main
MiguelMachado-dev commented 2026-11-24 21:28:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MiguelMachado-dev on 2026-11-24T21:28:24Z.


Stacked on #1797; only the top commit (434f428) belongs here. The commit under it, c2b0c00, is #1797's 8ec49c0 cherry-picked onto main c4d37be with the same diff. Once #1797 is in main, this PR is rebased and only the tests remain.

These are tests for image instructions in the per-lane form (#1745), the MIMG follow-up listed on #1269. They need #1797: without its vgpr_uses change, the per-lane form refuses every image instruction with NSA addresses, and the three lower_dxil tests fail. Part of #1269.

What is in it

  • Tests: image instructions in the per-lane lowering and on the GPU (434f428). Tests only, in the files' #[cfg(test)] modules, +271/−1:
    • crates/xcl/src/gpu/recomp/lower.rs:
      • helpers: decode_bytes, mimg (an image instruction with NSA dwords) and image_program;
      • image_instructions_in_coalesced_runs_and_whole_quads: image instructions join a coalesced guarded run. An implicit-LOD IMAGE_SAMPLE stays out of the run, and a PS refuses it in a block that not every lane reaches.
    • crates/xcl/src/gpu/recomp/lower_dxil.rs:
      • image_instructions_pass_every_register_they_use (CPU): every IMAGE_* instruction, over DIM, A16, D16, DMASK, GLC and sequential or 11 scattered NSA addresses, gets through the per-lane compute lowering with no register missing from the bridge.
      • per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu:
        • It covers NSA and sequential loads, NSA samples, a D16 sample, a store in a coalesced guarded run, SAMPLE_L, resinfo, GATHER4_LZ, and GLC compare-swap and add.
        • The textures and every register the instructions use, on 32 lanes, equal the HLSL path's. The test also checks the expected values.
      • a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu: a BVH ray with NSA addresses gives the same memory with four memory windows, with one window, and on the HLSL path.

Tested

  • Setup:

    • NVIDIA GeForce RTX 5080, driver 621.24 (no wave64), Intel Core i7-14700KF
    • Windows 11 build 26300, rustc 1.97.1, DXC 1.8.2502.11, debug build
  • cargo build --workspace && cargo test --workspace -- --test-threads=4:

    • at 434f428: 965 passed, 0 failed, 43 ignored (lib: 916 / 0 / 23);
    • at main c4d37be: 959 passed, 0 failed, 43 ignored (lib: 910 / 0 / 23).
    • The difference is the six tests of the two commits: two in #1797 and four here.
  • By module at 434f428, 0 failed in each:

    Module Passed Ignored
    gpu::dxil:: 84 1
    gpu::recomp::lower:: 35 0
    gpu::recomp::lower_dxil:: 15 0
    gpu::recomp::lane_masks:: 10 0
    gpu::rdna2:: 11 0
  • SKIPPED GPU tests: 23 lines, the same on both runs, and none in the new tests.

    • 18 are "no wave64".
    • 3 are per-lane refusals of V_MUL_F16, V_PK_MUL_F16 and V_CVT_F16_F32, whose #1426 semantics differ from the console's.
    • 1 is heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • 1 is shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: it cannot disable the driver cache, which needs Windows Developer Mode.
  • The three lower_dxil tests fail without #1797's change. I checked that on #1745's branch at 3ca3633, before it was merged.

Regression run

  • None yet. The commit of this PR changes tests only, but in files under crates/xcl/src that pr_check.py counts as runtime, and until #1797 is merged the diff also has #1797's commit.
  • Once #1797 is in main and this PR is rebased, the diff is test-only. It can then take the test-only label after review, or a smoke pair.

Not tested

  • Wave64, AMD and heap windows (this adapter has none).
  • Image instructions in a per-lane VS or PS: the tests are compute and kernel programs. The VS / PS DXIL half is a separate follow-up.
  • A retail sweep of the per-lane form with #1797, and a smoke run.

AI use

  • Claude Code (Claude Opus 5.5, xhigh) wrote the tests and this description, and ran the tests above.
<!-- greyfinch-sync:ivall/xcl:issue:5480637808 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825). Originally posted by [MiguelMachado-dev](https://github.com/MiguelMachado-dev) on 2026-11-24T21:28:24Z. --- Stacked on #1797; only the top commit (`434f428`) belongs here. The commit under it, `c2b0c00`, is #1797's `8ec49c0` cherry-picked onto `main` `c4d37be` with the same diff. Once #1797 is in `main`, this PR is rebased and only the tests remain. These are tests for image instructions in the per-lane form (#1745), the MIMG follow-up listed on #1269. They need #1797: without its `vgpr_uses` change, the per-lane form refuses every image instruction with NSA addresses, and the three `lower_dxil` tests fail. Part of #1269. **What is in it** - `Tests: image instructions in the per-lane lowering and on the GPU` (`434f428`). Tests only, in the files' `#[cfg(test)]` modules, +271/−1: - `crates/xcl/src/gpu/recomp/lower.rs`: - helpers: `decode_bytes`, `mimg` (an image instruction with NSA dwords) and `image_program`; - `image_instructions_in_coalesced_runs_and_whole_quads`: image instructions join a coalesced guarded run. An implicit-LOD `IMAGE_SAMPLE` stays out of the run, and a PS refuses it in a block that not every lane reaches. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: - `image_instructions_pass_every_register_they_use` (CPU): every `IMAGE_*` instruction, over DIM, A16, D16, DMASK, GLC and sequential or 11 scattered NSA addresses, gets through the per-lane compute lowering with no register missing from the bridge. - `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu`: - It covers NSA and sequential loads, NSA samples, a D16 sample, a store in a coalesced guarded run, `SAMPLE_L`, resinfo, `GATHER4_LZ`, and GLC compare-swap and add. - The textures and every register the instructions use, on 32 lanes, equal the HLSL path's. The test also checks the expected values. - `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu`: a BVH ray with NSA addresses gives the same memory with four memory windows, with one window, and on the HLSL path. **Tested** - Setup: - NVIDIA GeForce RTX 5080, driver 621.24 (no wave64), Intel Core i7-14700KF - Windows 11 build 26300, rustc 1.97.1, DXC 1.8.2502.11, debug build - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: - at `434f428`: 965 passed, 0 failed, 43 ignored (lib: 916 / 0 / 23); - at `main` `c4d37be`: 959 passed, 0 failed, 43 ignored (lib: 910 / 0 / 23). - The difference is the six tests of the two commits: two in #1797 and four here. - By module at `434f428`, 0 failed in each: | Module | Passed | Ignored | |---|---|---| | `gpu::dxil::` | 84 | 1 | | `gpu::recomp::lower::` | 35 | 0 | | `gpu::recomp::lower_dxil::` | 15 | 0 | | `gpu::recomp::lane_masks::` | 10 | 0 | | `gpu::rdna2::` | 11 | 0 | - SKIPPED GPU tests: 23 lines, the same on both runs, and none in the new tests. - 18 are "no wave64". - 3 are per-lane refusals of `V_MUL_F16`, `V_PK_MUL_F16` and `V_CVT_F16_F32`, whose #1426 semantics differ from the console's. - 1 is `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - 1 is `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record`: it cannot disable the driver cache, which needs Windows Developer Mode. - The three `lower_dxil` tests fail without #1797's change. I checked that on #1745's branch at `3ca3633`, before it was merged. **Regression run** - None yet. The commit of this PR changes tests only, but in files under `crates/xcl/src` that `pr_check.py` counts as runtime, and until #1797 is merged the diff also has #1797's commit. - Once #1797 is in `main` and this PR is rebased, the diff is test-only. It can then take the `test-only` label after review, or a smoke pair. **Not tested** - Wave64, AMD and heap windows (this adapter has none). - Image instructions in a per-lane VS or PS: the tests are compute and kernel programs. The VS / PS DXIL half is a separate follow-up. - A retail sweep of the per-lane form with #1797, and a smoke run. **AI use** - Claude Code (Claude Opus 5.5, xhigh) wrote the tests and this description, and ran the tests above.
upipibi commented 2026-11-24 22:06:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T21:37:22Z.


Same results on Ampere: RTX 3070 8 GB (32-lane waves, no wave64), driver 616.56, Windows 11, debug, 434f428 on main c4d37be:

  • The four new tests pass (image_instructions_in_coalesced_runs_and_whole_quads, image_instructions_pass_every_register_they_use, per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu, a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu).
  • gpu::dxil:: 84 passed, 1 ignored; gpu::recomp::lower:: 35 passed; gpu::recomp::lower_dxil:: 15 passed; 0 failed in each (--test-threads=4).

The whole workspace was not run.

AI-assisted (Claude Code). Synthetic tests only.

<!-- greyfinch-sync:ivall/xcl:comment:7145173406 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7145173406). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T21:37:22Z. --- Same results on Ampere: RTX 3070 8 GB (32-lane waves, no wave64), driver 616.56, Windows 11, debug, `434f428` on `main` `c4d37be`: - The four new tests pass (`image_instructions_in_coalesced_runs_and_whole_quads`, `image_instructions_pass_every_register_they_use`, `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu`, `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu`). - `gpu::dxil::` 84 passed, 1 ignored; `gpu::recomp::lower::` 35 passed; `gpu::recomp::lower_dxil::` 15 passed; 0 failed in each (`--test-threads=4`). The whole workspace was not run. AI-assisted (Claude Code). Synthetic tests only.
DavidM1911 commented 2026-11-25 01:10:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T00:50:53Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7148945864 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7148945864). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T00:50:53Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Chrysana commented 2026-11-25 20:08:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Chrysana on 2026-11-25T19:31:01Z.


AMD run of 434f428, for "Wave64, AMD and heap windows" under Not tested. The four new tests pass on an RX 9070 XT (RDNA4) and on an RDNA2 iGPU, and the suite matches your RTX 5080 counts exactly: 965 / 0 / 43 on this head, 959 / 0 / 43 on c4d37be. One limit on what this covers: both GPU tests run their programs as wave32 (kernel(&insts, false), wave64: false), and image_program is wave32 code (S_AND_SAVEEXEC_B32). So on wave64 hardware they still run 32 lanes, and wave64 stays untested by these tests on any GPU.

Setup: AMD Radeon RX 9070 XT 16 GB (RDNA4, wave64), driver 32.0.32015.2008; Ryzen 7 9800X3D, whose Radeon iGPU is RDNA2 (XCL_ADAPTER=1); Windows 11 26200.9974, rustc 1.100.0 MSVC, debug. Head as pushed (434f428, with #1797's commit under it), and its base c4d37be, each in its own checkout and target folder.

Full suite (RX 9070 XT, cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4):

passed failed ignored lib
434f428 965 0 43 916 / 0 / 23
c4d37be 959 0 43 910 / 0 / 23
  • SKIPPED: 8 lines, the same on both runs, none in the new tests. There's no "no wave64" here, so the wave64 halves of the existing GPU tests that your adapter skips (18 lines) ran on this card. 6 skips are the per-lane V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 refusals (at wave32 and at wave64). The other 2 are heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows here either) and pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode).

The new tests and your module table, on each GPU (cargo test -p xcl --lib -- --test-threads=4 <filter>):

RX 9070 XT Radeon iGPU (RDNA2)
image_instructions_in_coalesced_runs_and_whole_quads ok ok
image_instructions_pass_every_register_they_use ok ok
per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu ok ok
a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu ok ok
gpu::dxil:: 84 passed, 1 ignored 84 passed, 1 ignored
gpu::recomp::lower:: 35 passed 35 passed
gpu::recomp::lower_dxil:: 15 passed (6 SKIPPED, the f16/f32 refusals) 15 passed (same 6)
gpu::recomp::lane_masks:: 10 passed 10 passed
gpu::rdna2:: 11 passed 11 passed

0 failed everywhere. So AMD's drivers give the HLSL path's registers and textures for the NSA and sequential loads, the samples (including D16 and SAMPLE_L), resinfo, GATHER4_LZ, the GLC compare-swap and add, and the BVH ray with four memory windows and with one.

On wave64: making the GPU test cover it would take a wave64 form of image_program (S_AND_SAVEEXEC_B64, a 64-bit compare mask, EXEC high set) and 64-lane texture layouts (the 8×4 compare-swap and add targets hold 32 texels). That's more than a flag, so I didn't make a local variant. If you add one, I can run it on this card.

Not tested

  • Wave64 image instructions in the per-lane form (see above).
  • Heap windows (none on this card either).
  • This PR merged onto current main: it conflicts in crates/xcl/src/gpu/dxil/lower_image.rs, so these runs are on the head as pushed.

AI use

  • Claude Code (Claude Opus 5.5) built both trees, ran the tests on both GPUs, read the tests and drafted this comment. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7172404663 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7172404663). Originally posted by [Chrysana](https://github.com/Chrysana) on 2026-11-25T19:31:01Z. --- AMD run of `434f428`, for "Wave64, AMD and heap windows" under **Not tested**. **The four new tests pass on an RX 9070 XT (RDNA4) and on an RDNA2 iGPU, and the suite matches your RTX 5080 counts exactly: 965 / 0 / 43 on this head, 959 / 0 / 43 on `c4d37be`.** One limit on what this covers: both GPU tests run their programs as wave32 (`kernel(&insts, false)`, `wave64: false`), and `image_program` is wave32 code (`S_AND_SAVEEXEC_B32`). So on wave64 hardware they still run 32 lanes, and wave64 stays untested by these tests on any GPU. **Setup:** AMD Radeon RX 9070 XT 16 GB (RDNA4, wave64), driver 32.0.32015.2008; Ryzen 7 9800X3D, whose Radeon iGPU is RDNA2 (`XCL_ADAPTER=1`); Windows 11 26200.9974, rustc 1.100.0 MSVC, debug. Head as pushed (`434f428`, with #1797's commit under it), and its base `c4d37be`, each in its own checkout and target folder. **Full suite** (RX 9070 XT, `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`): | | passed | failed | ignored | lib | |---|---|---|---|---| | `434f428` | 965 | 0 | 43 | 916 / 0 / 23 | | `c4d37be` | 959 | 0 | 43 | 910 / 0 / 23 | - SKIPPED: 8 lines, the same on both runs, none in the new tests. There's no "no wave64" here, so the wave64 halves of the existing GPU tests that your adapter skips (18 lines) ran on this card. 6 skips are the per-lane `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` refusals (at wave32 and at wave64). The other 2 are `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows here either) and `pso_measurement_compiles_an_exact_synthetic_record` (no Developer Mode). **The new tests and your module table, on each GPU** (`cargo test -p xcl --lib -- --test-threads=4 <filter>`): | | RX 9070 XT | Radeon iGPU (RDNA2) | |---|---|---| | `image_instructions_in_coalesced_runs_and_whole_quads` | ok | ok | | `image_instructions_pass_every_register_they_use` | ok | ok | | `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu` | ok | ok | | `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu` | ok | ok | | `gpu::dxil::` | 84 passed, 1 ignored | 84 passed, 1 ignored | | `gpu::recomp::lower::` | 35 passed | 35 passed | | `gpu::recomp::lower_dxil::` | 15 passed (6 SKIPPED, the f16/f32 refusals) | 15 passed (same 6) | | `gpu::recomp::lane_masks::` | 10 passed | 10 passed | | `gpu::rdna2::` | 11 passed | 11 passed | 0 failed everywhere. So AMD's drivers give the HLSL path's registers and textures for the NSA and sequential loads, the samples (including D16 and `SAMPLE_L`), resinfo, `GATHER4_LZ`, the GLC compare-swap and add, and the BVH ray with four memory windows and with one. **On wave64:** making the GPU test cover it would take a wave64 form of `image_program` (`S_AND_SAVEEXEC_B64`, a 64-bit compare mask, EXEC high set) and 64-lane texture layouts (the 8×4 compare-swap and add targets hold 32 texels). That's more than a flag, so I didn't make a local variant. If you add one, I can run it on this card. **Not tested** - Wave64 image instructions in the per-lane form (see above). - Heap windows (none on this card either). - This PR merged onto current `main`: it conflicts in `crates/xcl/src/gpu/dxil/lower_image.rs`, so these runs are on the head as pushed. **AI use** - Claude Code (Claude Opus 5.5) built both trees, ran the tests on both GPUs, read the tests and drafted this comment. I checked it before posting.
thehollowedone commented 2026-11-27 11:04:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T11:04:44Z.


Independent RTX 3080 Ti check of #1825 head 434f4289. The stock per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu and image_instructions_pass_every_register_they_use tests each passed: 1 passed, 0 failed, 0 ignored, no GPU skip. Command for each: cargo test --offline --locked -j 4 -p xcl --lib <test-name> -- --nocapture --test-threads=1, with a writable isolated DXIL cache. Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, DXC 1.8.2502.11.

The stock GPU fixture exposes one mip, so it cannot distinguish IMAGE_SAMPLE_LZ selecting mip zero from every sample effectively selecting mip zero. I locally extended the test-only runner texture to two point-sampled mips with distinct known values. On this exact PR head plus the test patch, IMAGE_SAMPLE_LZ returned the expected mip-zero texels, while an explicit IMAGE_SAMPLE_L at LOD one returned the independent mip-one values (100 and 102). The focused command above passed 1/0/0, no skip. This is additional coverage, not a production failure; I did not run the whole workspace suite on the patch.

Two-mip synthetic test diff (test code only)
diff --git a/crates/xcl/src/gpu/dxil/ops_tests.rs b/crates/xcl/src/gpu/dxil/ops_tests.rs
index 33965aaf..a4ea51e4 100644
--- a/crates/xcl/src/gpu/dxil/ops_tests.rs
+++ b/crates/xcl/src/gpu/dxil/ops_tests.rs
@@ -531,6 +531,7 @@ fn typed_buffer_ops_run() {
         height: 1,
         depth: 1,
         texel_bytes: 4,
+        mip_levels: 1,
         data: data.iter().flat_map(|x| x.to_le_bytes()).collect(),
         uav,
     };
@@ -571,6 +572,7 @@ fn ftex(dim: runner::TexDim, w: u32, h: u32, d: u32) -> runner::TestTexture {
         height: h,
         depth: d,
         texel_bytes: 4,
+        mip_levels: 1,
         data: tex_data(w, h, d).iter().flat_map(|f| f.to_le_bytes()).collect(),
         uav: false,
     }
@@ -1015,7 +1017,7 @@ fn uav_array_3d_stores_loads_and_texture_atomics_run() {
     k.out(1, before);
     k.out(2, cx);
     let c = k.finish([32, 1, 1]);
-    let mk = |dim, format, data: Vec<u8>| runner::TestTexture { dim, format, width: 4, height: 4, depth: 2, texel_bytes: 4, data, uav: true };
+    let mk = |dim, format, data: Vec<u8>| runner::TestTexture { dim, format, width: 4, height: 4, depth: 2, texel_bytes: 4, mip_levels: 1, data, uav: true };
     let init: Vec<u32> = (0..32).map(|i| 1000 + i).collect();
     let tex = [
         ftex(runner::TexDim::D2, 1, 1, 1),
diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs
index c8631f79..c5bffeee 100644
--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -831,7 +831,7 @@ mod tests {
             (r[3], r[40], r[37], r[38]) = (x, y, x, y);
             (r[41], r[57]) = (f((x as f32 + 0.5) / 4.0), f((y as f32 + 0.5) / 4.0));
             r[6] = 10 * l;
-            (r[30], r[31], r[32], r[33], r[34]) = (f(0.5), f(0.125), f(0.0), f(0.5), f(0.5));
+            (r[30], r[31], r[32], r[33], r[34]) = (f(0.5), f(0.125), f(1.0), f(0.5), f(0.5));
             (r[60], r[63]) = (l % 8, l / 8);
             r[61] = l / 8;
             (r[20], r[21], r[22]) = (1000 + l, if l % 2 == 0 { 5 * l } else { 0xDEAD }, l);
@@ -846,11 +846,17 @@ mod tests {
                 }
             }
         }
+        // A distinct lower-resolution level makes LZ and explicit LOD one observably different.
+        for _ in 0..4 {
+            for v in [100.0f32, 101.0, 102.0, 103.0] {
+                t0.extend_from_slice(&v.to_le_bytes());
+            }
+        }
         let words = |k: u32| (0..32u32).flat_map(|i| (k * i).to_le_bytes()).collect::<Vec<u8>>();
-        let uav = |width: u32, data: Vec<u8>| TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width, height: 4, depth: 1, texel_bytes: 4, data, uav: true };
+        let uav = |width: u32, data: Vec<u8>| TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width, height: 4, depth: 1, texel_bytes: 4, mip_levels: 1, data, uav: true };
         let run = |dxil: &[u8]| {
             let tex = vec![
-                TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0.clone(), uav: false },
+                TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 2, data: t0.clone(), uav: false },
                 uav(4, vec![0xEE; 64]),
                 uav(8, words(5)),
                 uav(8, words(7)),
@@ -879,6 +885,7 @@ mod tests {
             let v = &direct.vgpr[l];
             let (x, y) = ((l % 4) as f32, (l / 4 % 4) as f32);
             let fl = |i: usize| f32::from_bits(v[i]);
+            assert_eq!([fl(24), fl(25)], [100.0, 102.0], "lane {l}: explicit LOD one uses mip one");
             if l < 16 {
                 assert_eq!([fl(10), fl(11), fl(12), fl(13)], [x, y, x + 4.0 * y, 1.0], "lane {l}: load");
                 assert_eq!([fl(14), fl(15), fl(16), fl(17)], [x, y, x + 4.0 * y, 1.0], "lane {l}: sample");
diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs
index f647dbd2..02430ae0 100644
--- a/crates/xcl/src/gpu/recomp/runner.rs
+++ b/crates/xcl/src/gpu/recomp/runner.rs
@@ -147,6 +147,7 @@ pub struct TestTexture {
     /// array slices (cube: 6 per cube) or depth
     pub depth: u32,
     pub texel_bytes: u32,
+    pub mip_levels: u16,
     /// tightly packed texels, slice after slice
     pub data: Vec<u8>,
     pub uav: bool,
@@ -219,7 +220,7 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t
                 Width: (t.width * t.texel_bytes) as u64,
                 Height: 1,
                 DepthOrArraySize: 1,
-                MipLevels: 1,
+                MipLevels: t.mip_levels,
                 SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
                 Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
                 Flags: if t.uav { D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS } else { D3D12_RESOURCE_FLAG_NONE },
@@ -230,13 +231,13 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t
             Width: t.width as u64,
             Height: t.height,
             DepthOrArraySize: depth_or_array as u16,
-            MipLevels: 1,
+            MipLevels: t.mip_levels,
             Format: t.format,
             SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
             Flags: if t.uav { D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS } else { D3D12_RESOURCE_FLAG_NONE },
             ..Default::default()
         } };
-        let subs = if t.dim == TexDim::D3 { 1 } else { t.depth };
+        let subs = if t.dim == TexDim::D3 { t.mip_levels as u32 } else { t.depth * t.mip_levels as u32 };
         let mut fps = vec![D3D12_PLACED_SUBRESOURCE_FOOTPRINT::default(); subs as usize];
         let mut size = 0u64;
         dev.GetCopyableFootprints(&rd, 0, subs, total, Some(fps.as_mut_ptr()), None, None, Some(&mut size));
@@ -250,16 +251,20 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t
         let mut p = std::ptr::null_mut();
         up.Map(0, None, Some(&mut p)).map_err(e)?;
         for (t, fps) in textures.iter().zip(&plans) {
-            let row = (t.width * t.texel_bytes) as usize;
-            let slices = t.depth as usize;
-            for z in 0..slices {
-                let fp = if t.dim == TexDim::D3 { &fps[0] } else { &fps[z] };
-                let slice_pitch = fp.Footprint.RowPitch as usize * t.height as usize;
-                let zoff = if t.dim == TexDim::D3 { z * slice_pitch } else { 0 };
-                for y in 0..t.height as usize {
-                    let src = &t.data[(z * t.height as usize + y) * row..][..row];
-                    let dst = (p as *mut u8).add(fp.Offset as usize + zoff + y * fp.Footprint.RowPitch as usize);
-                    std::ptr::copy_nonoverlapping(src.as_ptr(), dst, row);
+            let mut source = 0;
+            for (sub, fp) in fps.iter().enumerate() {
+                let mip = sub % t.mip_levels as usize;
+                let width = (t.width as usize >> mip).max(1);
+                let height = (t.height as usize >> mip).max(1);
+                let row = width * t.texel_bytes as usize;
+                let slices = if t.dim == TexDim::D3 { (t.depth as usize >> mip).max(1) } else { 1 };
+                for z in 0..slices {
+                    for y in 0..height {
+                        let src = &t.data[source..][..row];
+                        let dst = (p as *mut u8).add(fp.Offset as usize + z * fp.Footprint.RowPitch as usize * height + y * fp.Footprint.RowPitch as usize);
+                        std::ptr::copy_nonoverlapping(src.as_ptr(), dst, row);
+                        source += row;
+                    }
                 }
             }
         }
@@ -289,25 +294,25 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t
         match t.dim {
             TexDim::D2 => {
                 sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
-                sv.Anonymous.Texture2D = D3D12_TEX2D_SRV { MipLevels: 1, ..Default::default() };
+                sv.Anonymous.Texture2D = D3D12_TEX2D_SRV { MipLevels: t.mip_levels as u32, ..Default::default() };
                 uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
             }
             TexDim::D2Array => {
                 sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
-                sv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_SRV { MipLevels: 1, ArraySize: t.depth, ..Default::default() };
+                sv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_SRV { MipLevels: t.mip_levels as u32, ArraySize: t.depth, ..Default::default() };
                 uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
                 uv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_UAV { ArraySize: t.depth, ..Default::default() };
             }
             TexDim::D3 => {
                 sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
-                sv.Anonymous.Texture3D = D3D12_TEX3D_SRV { MipLevels: 1, ..Default::default() };
+                sv.Anonymous.Texture3D = D3D12_TEX3D_SRV { MipLevels: t.mip_levels as u32, ..Default::default() };
                 uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
                 uv.Anonymous.Texture3D = D3D12_TEX3D_UAV { WSize: t.depth, ..Default::default() };
             }
             TexDim::Cube => {
                 // a cube array, as translated shaders declare it (depth = 6 per cube)
                 sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
-                sv.Anonymous.TextureCubeArray = D3D12_TEXCUBE_ARRAY_SRV { MipLevels: 1, NumCubes: t.depth / 6, ..Default::default() };
+                sv.Anonymous.TextureCubeArray = D3D12_TEXCUBE_ARRAY_SRV { MipLevels: t.mip_levels as u32, NumCubes: t.depth / 6, ..Default::default() };
                 uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
                 uv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_UAV { ArraySize: t.depth, ..Default::default() };
             }
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 55ef1908..f58c651e 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -2346,7 +2346,7 @@ fn gpu_cube_array_slices() {
             }
         }
     }
-    let tex = [TestTexture { dim: TexDim::Cube, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 2, height: 2, depth: 12, texel_bytes: 16, data, uav: false }];
+    let tex = [TestTexture { dim: TexDim::Cube, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 2, height: 2, depth: 12, texel_bytes: 16, mip_levels: 1, data, uav: false }];
     let samp = [TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }];
     let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap();
     for l in 0..64 {
@@ -2418,10 +2418,10 @@ fn gpu_images_sample_load_store_atomic() {
         }
     }
     let tex = vec![
-        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false },
-        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 4, height: 4, depth: 1, texel_bytes: 4, data: vec![0xEE; 64], uav: true },
-        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, data: vec![0; 4], uav: true },
-        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, data: vec![0; 4], uav: true },
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false },
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 4, height: 4, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0xEE; 64], uav: true },
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0; 4], uav: true },
+        TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0; 4], uav: true },
     ];
     let samp = vec![
         TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None },
@@ -2495,7 +2495,7 @@ fn gpu_static_samplers_from_constants_in_code() {
             }
         }
     }
-    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }];
+    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }];
     let r = runner::run_code_with(&code, &st, &[], &tex, &[]).unwrap();
     for l in 0..64 {
         let v = &r.vgpr[l];
@@ -2536,7 +2536,7 @@ fn gpu_images_a16_d16() {
             }
         }
     }
-    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }];
+    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }];
     let samp = vec![TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }];
     let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap();
     for l in 0..64 {
@@ -3123,7 +3123,7 @@ fn gpu_image_sample_offset() {
             }
         }
     }
-    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }];
+    let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }];
     let samp = vec![TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }];
     let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap();
     for l in 0..64 {

For integration, #1797 remains open and conflicting, and #1825 is stacked on it and also conflicts with current main. The old world-load hang in #2647 is a separate runtime question; this fixture does not resolve it. AI use: Codex (GPT-6.2 Sol) wrote and ran the local test extension and checked the results; Codex (GPT-6.2 Astra) reviewed the LOD coverage boundary.

<!-- greyfinch-sync:ivall/xcl:comment:7216652078 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7216652078). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-27T11:04:44Z. --- Independent RTX 3080 Ti check of [#1825 head `434f4289`](https://github.com/xcl-dev/xcl/commit/434f4289f45b39781bb05973f38715ac55fe7f68). The stock `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu` and `image_instructions_pass_every_register_they_use` tests each passed: **1 passed, 0 failed, 0 ignored, no GPU skip**. Command for each: `cargo test --offline --locked -j 4 -p xcl --lib <test-name> -- --nocapture --test-threads=1`, with a writable isolated DXIL cache. Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, DXC 1.8.2502.11. The stock GPU fixture exposes one mip, so it cannot distinguish `IMAGE_SAMPLE_LZ` selecting mip zero from every sample effectively selecting mip zero. I locally extended the test-only runner texture to two point-sampled mips with distinct known values. On this exact PR head plus the test patch, `IMAGE_SAMPLE_LZ` returned the expected mip-zero texels, while an explicit `IMAGE_SAMPLE_L` at LOD one returned the independent mip-one values (100 and 102). The focused command above passed **1/0/0, no skip**. This is additional coverage, not a production failure; I did not run the whole workspace suite on the patch. <details><summary>Two-mip synthetic test diff (test code only)</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/ops_tests.rs b/crates/xcl/src/gpu/dxil/ops_tests.rs index 33965aaf..a4ea51e4 100644 --- a/crates/xcl/src/gpu/dxil/ops_tests.rs +++ b/crates/xcl/src/gpu/dxil/ops_tests.rs @@ -531,6 +531,7 @@ fn typed_buffer_ops_run() { height: 1, depth: 1, texel_bytes: 4, + mip_levels: 1, data: data.iter().flat_map(|x| x.to_le_bytes()).collect(), uav, }; @@ -571,6 +572,7 @@ fn ftex(dim: runner::TexDim, w: u32, h: u32, d: u32) -> runner::TestTexture { height: h, depth: d, texel_bytes: 4, + mip_levels: 1, data: tex_data(w, h, d).iter().flat_map(|f| f.to_le_bytes()).collect(), uav: false, } @@ -1015,7 +1017,7 @@ fn uav_array_3d_stores_loads_and_texture_atomics_run() { k.out(1, before); k.out(2, cx); let c = k.finish([32, 1, 1]); - let mk = |dim, format, data: Vec<u8>| runner::TestTexture { dim, format, width: 4, height: 4, depth: 2, texel_bytes: 4, data, uav: true }; + let mk = |dim, format, data: Vec<u8>| runner::TestTexture { dim, format, width: 4, height: 4, depth: 2, texel_bytes: 4, mip_levels: 1, data, uav: true }; let init: Vec<u32> = (0..32).map(|i| 1000 + i).collect(); let tex = [ ftex(runner::TexDim::D2, 1, 1, 1), diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs index c8631f79..c5bffeee 100644 --- a/crates/xcl/src/gpu/recomp/lower_dxil.rs +++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs @@ -831,7 +831,7 @@ mod tests { (r[3], r[40], r[37], r[38]) = (x, y, x, y); (r[41], r[57]) = (f((x as f32 + 0.5) / 4.0), f((y as f32 + 0.5) / 4.0)); r[6] = 10 * l; - (r[30], r[31], r[32], r[33], r[34]) = (f(0.5), f(0.125), f(0.0), f(0.5), f(0.5)); + (r[30], r[31], r[32], r[33], r[34]) = (f(0.5), f(0.125), f(1.0), f(0.5), f(0.5)); (r[60], r[63]) = (l % 8, l / 8); r[61] = l / 8; (r[20], r[21], r[22]) = (1000 + l, if l % 2 == 0 { 5 * l } else { 0xDEAD }, l); @@ -846,11 +846,17 @@ mod tests { } } } + // A distinct lower-resolution level makes LZ and explicit LOD one observably different. + for _ in 0..4 { + for v in [100.0f32, 101.0, 102.0, 103.0] { + t0.extend_from_slice(&v.to_le_bytes()); + } + } let words = |k: u32| (0..32u32).flat_map(|i| (k * i).to_le_bytes()).collect::<Vec<u8>>(); - let uav = |width: u32, data: Vec<u8>| TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width, height: 4, depth: 1, texel_bytes: 4, data, uav: true }; + let uav = |width: u32, data: Vec<u8>| TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width, height: 4, depth: 1, texel_bytes: 4, mip_levels: 1, data, uav: true }; let run = |dxil: &[u8]| { let tex = vec![ - TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0.clone(), uav: false }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 2, data: t0.clone(), uav: false }, uav(4, vec![0xEE; 64]), uav(8, words(5)), uav(8, words(7)), @@ -879,6 +885,7 @@ mod tests { let v = &direct.vgpr[l]; let (x, y) = ((l % 4) as f32, (l / 4 % 4) as f32); let fl = |i: usize| f32::from_bits(v[i]); + assert_eq!([fl(24), fl(25)], [100.0, 102.0], "lane {l}: explicit LOD one uses mip one"); if l < 16 { assert_eq!([fl(10), fl(11), fl(12), fl(13)], [x, y, x + 4.0 * y, 1.0], "lane {l}: load"); assert_eq!([fl(14), fl(15), fl(16), fl(17)], [x, y, x + 4.0 * y, 1.0], "lane {l}: sample"); diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index f647dbd2..02430ae0 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -147,6 +147,7 @@ pub struct TestTexture { /// array slices (cube: 6 per cube) or depth pub depth: u32, pub texel_bytes: u32, + pub mip_levels: u16, /// tightly packed texels, slice after slice pub data: Vec<u8>, pub uav: bool, @@ -219,7 +220,7 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t Width: (t.width * t.texel_bytes) as u64, Height: 1, DepthOrArraySize: 1, - MipLevels: 1, + MipLevels: t.mip_levels, SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR, Flags: if t.uav { D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS } else { D3D12_RESOURCE_FLAG_NONE }, @@ -230,13 +231,13 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t Width: t.width as u64, Height: t.height, DepthOrArraySize: depth_or_array as u16, - MipLevels: 1, + MipLevels: t.mip_levels, Format: t.format, SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, Flags: if t.uav { D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS } else { D3D12_RESOURCE_FLAG_NONE }, ..Default::default() } }; - let subs = if t.dim == TexDim::D3 { 1 } else { t.depth }; + let subs = if t.dim == TexDim::D3 { t.mip_levels as u32 } else { t.depth * t.mip_levels as u32 }; let mut fps = vec![D3D12_PLACED_SUBRESOURCE_FOOTPRINT::default(); subs as usize]; let mut size = 0u64; dev.GetCopyableFootprints(&rd, 0, subs, total, Some(fps.as_mut_ptr()), None, None, Some(&mut size)); @@ -250,16 +251,20 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t let mut p = std::ptr::null_mut(); up.Map(0, None, Some(&mut p)).map_err(e)?; for (t, fps) in textures.iter().zip(&plans) { - let row = (t.width * t.texel_bytes) as usize; - let slices = t.depth as usize; - for z in 0..slices { - let fp = if t.dim == TexDim::D3 { &fps[0] } else { &fps[z] }; - let slice_pitch = fp.Footprint.RowPitch as usize * t.height as usize; - let zoff = if t.dim == TexDim::D3 { z * slice_pitch } else { 0 }; - for y in 0..t.height as usize { - let src = &t.data[(z * t.height as usize + y) * row..][..row]; - let dst = (p as *mut u8).add(fp.Offset as usize + zoff + y * fp.Footprint.RowPitch as usize); - std::ptr::copy_nonoverlapping(src.as_ptr(), dst, row); + let mut source = 0; + for (sub, fp) in fps.iter().enumerate() { + let mip = sub % t.mip_levels as usize; + let width = (t.width as usize >> mip).max(1); + let height = (t.height as usize >> mip).max(1); + let row = width * t.texel_bytes as usize; + let slices = if t.dim == TexDim::D3 { (t.depth as usize >> mip).max(1) } else { 1 }; + for z in 0..slices { + for y in 0..height { + let src = &t.data[source..][..row]; + let dst = (p as *mut u8).add(fp.Offset as usize + z * fp.Footprint.RowPitch as usize * height + y * fp.Footprint.RowPitch as usize); + std::ptr::copy_nonoverlapping(src.as_ptr(), dst, row); + source += row; + } } } } @@ -289,25 +294,25 @@ unsafe fn bind_resources(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, t match t.dim { TexDim::D2 => { sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - sv.Anonymous.Texture2D = D3D12_TEX2D_SRV { MipLevels: 1, ..Default::default() }; + sv.Anonymous.Texture2D = D3D12_TEX2D_SRV { MipLevels: t.mip_levels as u32, ..Default::default() }; uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; } TexDim::D2Array => { sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - sv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_SRV { MipLevels: 1, ArraySize: t.depth, ..Default::default() }; + sv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_SRV { MipLevels: t.mip_levels as u32, ArraySize: t.depth, ..Default::default() }; uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; uv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_UAV { ArraySize: t.depth, ..Default::default() }; } TexDim::D3 => { sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; - sv.Anonymous.Texture3D = D3D12_TEX3D_SRV { MipLevels: 1, ..Default::default() }; + sv.Anonymous.Texture3D = D3D12_TEX3D_SRV { MipLevels: t.mip_levels as u32, ..Default::default() }; uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; uv.Anonymous.Texture3D = D3D12_TEX3D_UAV { WSize: t.depth, ..Default::default() }; } TexDim::Cube => { // a cube array, as translated shaders declare it (depth = 6 per cube) sv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; - sv.Anonymous.TextureCubeArray = D3D12_TEXCUBE_ARRAY_SRV { MipLevels: 1, NumCubes: t.depth / 6, ..Default::default() }; + sv.Anonymous.TextureCubeArray = D3D12_TEXCUBE_ARRAY_SRV { MipLevels: t.mip_levels as u32, NumCubes: t.depth / 6, ..Default::default() }; uv.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; uv.Anonymous.Texture2DArray = D3D12_TEX2D_ARRAY_UAV { ArraySize: t.depth, ..Default::default() }; } diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 55ef1908..f58c651e 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -2346,7 +2346,7 @@ fn gpu_cube_array_slices() { } } } - let tex = [TestTexture { dim: TexDim::Cube, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 2, height: 2, depth: 12, texel_bytes: 16, data, uav: false }]; + let tex = [TestTexture { dim: TexDim::Cube, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 2, height: 2, depth: 12, texel_bytes: 16, mip_levels: 1, data, uav: false }]; let samp = [TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }]; let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap(); for l in 0..64 { @@ -2418,10 +2418,10 @@ fn gpu_images_sample_load_store_atomic() { } } let tex = vec![ - TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }, - TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 4, height: 4, depth: 1, texel_bytes: 4, data: vec![0xEE; 64], uav: true }, - TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, data: vec![0; 4], uav: true }, - TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, data: vec![0; 4], uav: true }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 4, height: 4, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0xEE; 64], uav: true }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0; 4], uav: true }, + TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32_UINT, width: 1, height: 1, depth: 1, texel_bytes: 4, mip_levels: 1, data: vec![0; 4], uav: true }, ]; let samp = vec![ TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }, @@ -2495,7 +2495,7 @@ fn gpu_static_samplers_from_constants_in_code() { } } } - let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }]; + let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }]; let r = runner::run_code_with(&code, &st, &[], &tex, &[]).unwrap(); for l in 0..64 { let v = &r.vgpr[l]; @@ -2536,7 +2536,7 @@ fn gpu_images_a16_d16() { } } } - let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }]; + let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }]; let samp = vec![TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }]; let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap(); for l in 0..64 { @@ -3123,7 +3123,7 @@ fn gpu_image_sample_offset() { } } } - let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, data: t0, uav: false }]; + let tex = vec![TestTexture { dim: TexDim::D2, format: DXGI_FORMAT_R32G32B32A32_FLOAT, width: 4, height: 4, depth: 1, texel_bytes: 16, mip_levels: 1, data: t0, uav: false }]; let samp = vec![TestSampler { filter: D3D12_FILTER_MIN_MAG_MIP_POINT, address: D3D12_TEXTURE_ADDRESS_MODE_CLAMP, comparison: None }]; let r = runner::run_code_with(&code, &st, &[], &tex, &samp).unwrap(); for l in 0..64 { ``` </details> For integration, [#1797](https://github.com/xcl-dev/xcl/pull/1797) remains open and conflicting, and #1825 is stacked on it and also conflicts with current `main`. The old world-load hang in [#2647](https://github.com/xcl-dev/xcl/issues/2647) is a separate runtime question; this fixture does not resolve it. AI use: Codex (GPT-6.2 Sol) wrote and ran the local test extension and checked the results; Codex (GPT-6.2 Astra) reviewed the LOD coverage boundary.
thehollowedone commented 2026-11-27 11:26:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T11:26:31Z.


Integration follow-up to the #1797 rebase resolution and matched suite. I locally stacked #1825 tip 434f4289 on the rebased #1797 candidate at main 623d02e4. This is an unpublished local stack, not a change to this PR's head.

The #1825 lower.rs hunk merges directly. Its lower_dxil.rs conflict is placement at the tests module's end: keep the current destination tests, then append the three authored tests image_instructions_pass_every_register_they_use, per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu, and a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu before the module's closing brace. All 193 authored lines in that hunk retain their content and order. No production change is needed in this child.

On Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, DXC 1.8.2502.11, cargo build --workspace passed. With separate writable DXIL caches, cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1,458 passed / 0 failed / 47 ignored on clean main and 1,464 / 0 / 47 on the local stacked candidate. Both logged 25 GPU skip notices; the stock image and BVH GPU tests in this PR ran and passed. After the parent and child are pushed on clean commits, their current-head CI must run; the runtime parent needs a new clean-head smoke pair, while this test-only child needs the repository's test-only waiver if its checks require one. AI use: Codex (GPT-6.2 Sol) resolved and tested the local stack; Codex (GPT-6.2 Astra) reviewed its image and D16 paths.

<!-- greyfinch-sync:ivall/xcl:comment:7217077618 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7217077618). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-27T11:26:31Z. --- Integration follow-up to [the #1797 rebase resolution and matched suite](https://github.com/xcl-dev/xcl/pull/1797#issuecomment-7217064441). I locally stacked [#1825 tip `434f4289`](https://github.com/xcl-dev/xcl/commit/434f4289f45b39781bb05973f38715ac55fe7f68) on the rebased #1797 candidate at `main` `623d02e4`. This is an unpublished local stack, not a change to this PR's head. The #1825 `lower.rs` hunk merges directly. Its `lower_dxil.rs` conflict is placement at the tests module's end: keep the current destination tests, then append the three authored tests `image_instructions_pass_every_register_they_use`, `per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpu`, and `a_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu` before the module's closing brace. All 193 authored lines in that hunk retain their content and order. No production change is needed in this child. On Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, DXC 1.8.2502.11, `cargo build --workspace` passed. With separate writable DXIL caches, `cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture` reported **1,458 passed / 0 failed / 47 ignored** on clean `main` and **1,464 / 0 / 47** on the local stacked candidate. Both logged 25 GPU skip notices; the stock image and BVH GPU tests in this PR ran and passed. After the parent and child are pushed on clean commits, their current-head CI must run; the runtime parent needs a new clean-head smoke pair, while this test-only child needs the repository's test-only waiver if its checks require one. AI use: Codex (GPT-6.2 Sol) resolved and tested the local stack; Codex (GPT-6.2 Astra) reviewed its image and D16 paths.
throny commented 2026-11-28 23:28:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T23:28:27Z.


Two contributors checked independently and found that #886 #1797 solves the same problem (for #885) in a different way: #1607, group D138. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7247454767 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7247454767). Originally posted by [throny](https://github.com/throny) on 2026-11-28T23:28:27Z. --- <!-- xcl-1607-hint:D138 --> Two contributors checked independently and found that #886 #1797 solves the same problem (for #885) in a different way: #1607, group D138. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Foniass commented 2026-12-01 06:54:32 +00:00 (Migrated from github.com)

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


Triage (#1607) – head 434f428

Stacked on #1797. Its lower commit c2b0c00 has the same diff as #1797's 8ec49c0. Only 434f428 (tests) belongs here.
Main now has its own exact MIMG vgpr_uses (mimg_vgpr_uses, from 43c56dc), so the rdna2.rs half of the base commit conflicts with code that is already on main. Main still lacks the lower_image.rs compare-swap change from #1797 (it reads vdata + 1 for every atomic). image_instructions_pass_every_register_they_use probably still needs that change. After a rebase, the tests should be re-run against main's vgpr_uses.
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:7303422122 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1825#issuecomment-7303422122). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:54:32Z. --- **Triage (#1607)** – head 434f428 Stacked on #1797. Its lower commit `c2b0c00` has the same diff as #1797's `8ec49c0`. Only `434f428` (tests) belongs here. Main now has its own exact MIMG `vgpr_uses` (`mimg_vgpr_uses`, from `43c56dc`), so the `rdna2.rs` half of the base commit conflicts with code that is already on main. Main still lacks the `lower_image.rs` compare-swap change from #1797 (it reads `vdata + 1` for every atomic). `image_instructions_pass_every_register_they_use` probably still needs that change. After a rebase, the tests should be re-run against main's `vgpr_uses`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Pull request closed

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!1815
No description provided.