Recompiler: image_get_resinfo on a 1D array gives the layers in y #1266

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

@⁠emirduran707 on GitHub · 2026-11-24 13:59 UTC · original
emirduran707:recomp-resinfo-1d-array-layers → main · +45 −1 · 3 files · 1 commits · merged 2026-11-25 01:05 UTC

image_get_resinfo on a 1D array (DIM 4) returned (width, 1, layers, mips): the layer count went to z and y was 1. On RDNA the layer count of a 1D array is in y. Mesa's AMD driver code shows it: visit_image_size in ac_nir_to_llvm.c moves z into y only for GFX9 (chip_class == GFX9 && dim == 1D && is_array). GFX9 is the one chip that maps 1D arrays to ac_image_2darray (ac_get_sampler_dim in ac_shader_util.c). From GFX10 on, the dim is ac_image_1darray and the hardware's x and y are used as they are. Read in Mesa 21.3.9. So a shader reading the element count of a Texture1DArray got 1.

The layer count now goes to y. z keeps the value it had (the layer count), since no source says what z holds for a 1D array, so only y changes.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: the DIM 4 arm of image_get_resinfo.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • image_get_resinfo_1d_array_layers_in_y, which needs no GPU and checks that the element count is written into y;
    • gpu_image_get_resinfo_1d_array, with a 4-wide, 3-layer 1D array: x 4, y 3, mips 1.
  • crates/xcl/src/gpu/recomp/runner.rs: TexDim::D1Array for that GPU test (a TEXTURE1D resource with TEXTURE1DARRAY views).

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on cafda82: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU tests (the new GPU test ran and passed on this adapter)
  • the translation test without the change fails (GetDimensions(v3, t1_w, t1_d, t1_n) must write the elements into _h); with it it passes
  • the GPU test was run only with the change

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: cafda82ea1029f4f5aade5de7ca0a9da2a95a340
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1481 (PresentX 1482)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19735 MB

Not tested

  • What z holds for a 1D array on the console.
  • NVIDIA and Intel GPUs, and wave32-only adapters.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the tests and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 13:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1266) `emirduran707:recomp-resinfo-1d-array-layers` → `main` · +45 −1 · 3 files · 1 commits · merged 2026-11-25 01:05 UTC `image_get_resinfo` on a 1D array (DIM 4) returned (width, 1, layers, mips): the layer count went to z and y was 1. On RDNA the layer count of a 1D array is in y. Mesa's AMD driver code shows it: `visit_image_size` in `ac_nir_to_llvm.c` moves z into y only for GFX9 (`chip_class == GFX9 && dim == 1D && is_array`). GFX9 is the one chip that maps 1D arrays to `ac_image_2darray` (`ac_get_sampler_dim` in `ac_shader_util.c`). From GFX10 on, the dim is `ac_image_1darray` and the hardware's x and y are used as they are. Read in Mesa 21.3.9. So a shader reading the element count of a `Texture1DArray` got 1. The layer count now goes to y. z keeps the value it had (the layer count), since no source says what z holds for a 1D array, so only y changes. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: the DIM 4 arm of `image_get_resinfo`. - `crates/xcl/src/gpu/recomp/tests.rs`: - `image_get_resinfo_1d_array_layers_in_y`, which needs no GPU and checks that the element count is written into y; - `gpu_image_get_resinfo_1d_array`, with a 4-wide, 3-layer 1D array: x 4, y 3, mips 1. - `crates/xcl/src/gpu/recomp/runner.rs`: `TexDim::D1Array` for that GPU test (a TEXTURE1D resource with TEXTURE1DARRAY views). **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on cafda82: 743 passed, 0 failed, 41 ignored; no SKIPPED GPU tests (the new GPU test ran and passed on this adapter) - the translation test without the change fails (`GetDimensions(v3, t1_w, t1_d, t1_n) must write the elements into _h`); with it it passes - the GPU test was run only with the change **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: cafda82ea1029f4f5aade5de7ca0a9da2a95a340 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1481 (PresentX 1482) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19735 MB ``` **Not tested** - What z holds for a 1D array on the console. - NVIDIA and Intel GPUs, and wave32-only adapters. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the tests and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
image_get_resinfo with DIM = 1D_ARRAY wrote the layer count into z and
1 into y, so a 1D array read back (width, 1, layers, mips). On RDNA
(GFX10+) the hardware returns the layers in y.

Mesa's AMD backend (ac_nir_to_llvm.c, read in Mesa 21.3.9) uses the
hardware result's .xy directly for textureSize(sampler1DArray) and only
moves z into y on GFX9: visit_image_size and the txs path both guard
the move with `chip_class == GFX9 && dim == GLSL_SAMPLER_DIM_1D &&
is_array`, because ac_get_sampler_dim (ac_shader_util.c) maps a 1D
array to ac_image_2darray on GFX9 alone and to ac_image_1darray on
the others.

GetDimensions now writes the element count into y; z keeps the layer
count it had before (no source found for z on a 1D array), so only y
changes.

Tests: a translation test of the HLSL (fails before the change), and a
GPU test with a 4-wide, 3-layer 1D array expecting (4, 3, _, 1); the
test runner gains a TexDim::D1Array for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:56 +00:00
github manually merged commit cafda82ea1 into gh-pr/1266/base 2026-11-26 04:48:57 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:05 UTC · original

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

  • cargo test -p xcl lib recomp: 191 passed, 18 ignored, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1266#issuecomment-7133825270) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl lib recomp: 191 passed, 18 ignored, 0 failed. Thanks!
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 14:06 UTC · original

Independent RTX 3080 Ti check on cafda82, Windows 11 build 26300, driver 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug.

I ran image_get_resinfo on a synthetic 16-wide, seven-layer 1D array with three partial component masks. On the PR, the layer-only mask (0x2) returned 7, mip-only (0x8) returned 1, and width/layers/mips (0xb) returned packed (16, 7, 1). All 64 lanes matched in each case, including registers seeded to detect unintended writes. Restoring only the parent emitter returned 1 instead of 7 on all 64 lanes for both masks that ask for layers. The mip-only control still passed.

Both stock 1D array tests and the added GPU check passed on the PR with no skips. Synthetic workload only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 14:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1266#issuecomment-7133860131) Independent RTX 3080 Ti check on [`cafda82`](https://github.com/ivall/xcl/commit/cafda82ea1029f4f5aade5de7ca0a9da2a95a340), Windows 11 build 26300, driver 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug. I ran `image_get_resinfo` on a synthetic 16-wide, seven-layer 1D array with three partial component masks. On the PR, the layer-only mask (`0x2`) returned 7, mip-only (`0x8`) returned 1, and width/layers/mips (`0xb`) returned packed `(16, 7, 1)`. All 64 lanes matched in each case, including registers seeded to detect unintended writes. Restoring only the parent emitter returned 1 instead of 7 on all 64 lanes for both masks that ask for layers. The mip-only control still passed. Both stock 1D array tests and the added GPU check passed on the PR with no skips. Synthetic workload only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:40 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 04:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1266#issuecomment-7182808367) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This discussion has been locked. Commenting is limited to contributors.
No description provided.