Skip to content

Recompiler: image_get_resinfo gives depth 0 for 1D, 2D and 2D MSAA - #2054

Merged
raylitebull merged 3 commits into
xcl-dev:mainfrom
upipibi:fix/resinfo-depth-zero
Nov 25, 2026
Merged

raylitebull merged 3 commits into
xcl-dev:mainfrom
upipibi:fix/resinfo-depth-zero

Conversation

@upipibi

@upipibi upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

image_get_resinfo reported a depth (third component) of 1 for a DIM without layers: DIM 1D and 2D on both paths, and the direct translator's 2D MSAA query. RDNA2 reports 0 there. The sources are boykopovar/AnyPS5's measurements, recorded in their docs/dev/debt/shader.md:

  • thuanquang's gfx1031 measurement (AnyPS5 #7550): the third component is 0 for every DIM without layers (1D, 2D, 2D MSAA).
  • gfx1036 with their hardware oracle: a 2D MSAA T# with 2, 4, 8 or 16 fragments returns (width, height, 0, 1) under DIM 1D, 2D and 2D_MSAA, in wave32 and wave64 (AnyPS5 #25723).

What is in it

  • recomp/emit.rs: DIM 1D and 2D set {t}_d = 0u instead of 1u.

  • dxil/lower_image.rs: the same for DIM 1D and 2D, and the 2D MSAA query's depth is 0 (the MSAA array keeps its slice count).

  • Tests: the three assertions that encoded depth 1 now expect the measured 0: gpu_images_sample_load_store_atomic (2D), and in msaa_tests.rs, gpu_direct_msaa_image_loads (2D MSAA) and gpu_direct_image_get_resinfo_d16. A new gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp covers DIM 2D on a 4-sample T#. On main it gives [4, 2, 1, 1] on both paths.

  • a334936: DIM 1D / 2D image_get_resinfo on an MSAA T# (TYPE 14 / 15) is queried through Texture2DMS / Texture2DMSArray, giving (w, h, 0, 1) on every host. A Texture2D handle on the multisampled view left the level count to the host (RADV gave 3; reported by SlopTart). The test also covers DIM 1D and a 4-sample array T#.

  • 9fb040d: a new gpu_image_get_resinfo_past_last_level queries single-level 2D, 2D array, 3D and cube T#s at mips 0, 1, 2, 15 and 0xffffffff. Past the last level, RDNA2 gives (0, 0, 0, levels) (AnyPS5#22724, measured on gfx1036). D3D12 zeroes the sizes there too, so only the channels a translator fills in itself can differ. The 1D array case is left to Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046, which fixes its direct-path query.

Tested

  • At 9fb040d, AMD Radeon RX 7900 XT (RDNA3, RADV / Mesa 26.2.5 under Proton with the pinned vkd3d-proton 3.1), run by SlopTart (comment): the resinfo GPU tests give 5 passed, 0 failed by default and 4 passed, 0 failed with XCL_SPLIT_WAVE64=1. With XCL_DIRECT_DXIL=1 (with or without split wave64) the only failure is gpu_image_get_resinfo_1d_array (Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046). gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp now gives 1 level there too, where it gave 3 before a334936.
  • At 9fb040d, RTX 3070 (616.56): the new test passes with XCL_DIRECT_DXIL=0 and 1. With this PR's emit.rs and lower_image.rs reverted to the base, it fails on both paths (2D at mip 1: [0, 0, 1, 1]). The resinfo GPU tests: 3 passed with XCL_DIRECT_DXIL=0; with 1, 2 passed and 1 failed, gpu_image_get_resinfo_1d_array (Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046).
  • At a334936, RTX 3070 (616.56): gpu_ suite 133 passed with XCL_DIRECT_DXIL=0; with 1, 132 passed and 1 failed: gpu_image_get_resinfo_1d_array, which fails on main too (Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046); dxil:: units 123 passed. CI Build and test: passing. Not tested on AMD at this head.
  • On an RTX 3070 (Ampere, driver 616.56), Windows 11, debug, on main 5ce558f:
  • gpu_ tests (--skip gpu_sparse_vram): 133 passed with XCL_DIRECT_DXIL=0; with 1, 132 passed and 1 failed, gpu_image_get_resinfo_1d_array, which fails the same way on main (Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046 fixes it; the two PRs merge cleanly).
  • dxil::, resinfo and msaa units: 140 passed.

Regression run
Run by Toons29 on an AMD Radeon RX 9070 (comment), main and this head, pasted unedited:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 9fb040d30af141fe50a0d3ce68f4500d1c9328f1
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1635 (PresentX 1636)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14624 MB

Not tested

  • AMD, titles.

AI use

  • AI-assisted (Claude Code, Claude Opus 5.5): wrote the change, the tests and this description, and ran the tests above. Synthetic tests only; no game files.

🤖 Generated with Claude Code

A DIM without layers reported depth 1: DIM 1D and 2D on both paths, and
the direct translator's 2D MSAA query. RDNA2 reports 0 there: AnyPS5's
measurements (gfx1031 #7550: the third component is 0 for every DIM
without layers; gfx1036: a 2D MSAA T# under DIM 1D, 2D and 2D_MSAA gives
(width, height, 0, 1)). The tests that encoded depth 1 now expect 0, and
a test of DIM 2D on a 4-sample T# is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJAutoCompare

Copy link
Copy Markdown

Independent Intel Arc A770 compatibility check for PR #2054 at 71d94e713bb799dbea2bf9e755c02b9bb69e3c7a. The checkout was clean before and after execution, and the PR was open at this exact head on both checks.

Tested

  • Intel Arc A770 (driver 32.0.101.9175), AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 26200.9974, Rust 1.100.0 (x86_64-pc-windows-msvc), DXC and DXIL 1.9.2609.5, unoptimized test profile.
  • Prebuilt outside the Arc lock with cargo test --locked -p xcl --lib -j 2 --no-run --message-format=json. Set CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0, CARGO_TARGET_DIR=L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target, and TEMP and TMP to L:/XclTooling/pr2054.
  • Ran the Cargo-emitted library test executable from crates/xcl with XCL_ADAPTER=A770, XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64, and XCL_REQUIRE_GPU=wave64. The GPU lock wrapped the following test commands.
$testExe = 'L:/XclTooling/pr1844-71f2ceb-t3-737e5ee5/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe'
$common = @(
    'gpu::recomp::tests::gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp',
    'gpu::recomp::tests::gpu_images_sample_load_store_atomic'
)
$expectedTests = $common + @(
    'gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads',
    'gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16'
)
& 'L:/XclTooling/Invoke-ArcTest.ps1' -WaitMinutes 60 -Test {
    $env:XCL_DIRECT_DXIL = '0'
    & $testExe @common --exact --nocapture --test-threads=1
    $hlslExit = $LASTEXITCODE
    $env:XCL_DIRECT_DXIL = '1'
    & $testExe @expectedTests --exact --nocapture --test-threads=1
    $directExit = $LASTEXITCODE
    $global:LASTEXITCODE = if ($hlslExit -ne 0) { $hlslExit } else { $directExit }
}
Backend Passed Failed Ignored GPU skips Filtered out
HLSL/DXC (XCL_DIRECT_DXIL=0) 2 0 0 0 1118
Direct DXIL (XCL_DIRECT_DXIL=1) 4 0 0 0 1116
  • Both backends returned (4, 2, 0, 1) for the DIM 2D query of a 4-sample MSAA texture and (4, 4, 0, 1) for the ordinary 2D image query.
  • The direct-only MSAA fixture returned (4, 4, 0, 1) for the non-array texture and (4, 4, 3, 1) for the array. The packed D16 query preserved mip count 1, returned depth 0 for 2D and three layers for the MSAA array, and preserved the sentinel VGPRs.

Not tested

DIM 1D, the separate DIM 4 array case from #2046, the main baseline, other adapters and MSAA sample counts beyond the checked fixtures, the full workspace suite, and retail-title smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in tests, verified the logs, and wrote this report.

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's new test passes.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 71d94e7 as it is (merge base with main 5ce558f), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp: ok, not skipped

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@SlopTart

Copy link
Copy Markdown

Heads up: this PR's new tsharp test fails deterministically on RDNA3 under Linux/Wine, but not on the depth field the PR fixes. The mip count is what differs.

Rig: RX 7900 XT (RDNA3, RADV NAVI31, Mesa 26.2.5), Proton Experimental (wine-11.0) + the xcl-pinned vkd3d-proton 3.1 build, DXC 1.9.2609.5, release build, tree main cbc296ab + this PR's head merged. Pipeline cache removed before each run. No Mesa/RADV run of this PR was posted before this one.

gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp fails 4/4 runs (2 native, 2 under XCL_SPLIT_WAVE64=1, 2 of them solo with --nocapture):

assertion `left == right` failed: resinfo (w, h, d, mips) of DIM 2D on a 4-sample T#
  left: [4, 2, 0, 3]
 right: [4, 2, 0, 1]

Notes:

  • width, height and depth all match the new expectation: depth 0 on RDNA3 too, so the get_resinfo depth fix itself holds on this generation and stack.
  • the 4th component (mips) comes back 3 where the test wants 1. A full mip chain of a 4x2 texture is 3 levels, so the value looks like a real chain length rather than noise. If the RDNA2 reference (AnyPS5#25723) says 1 for this T#, either the test fixture's texture creation gives different mip counts across stacks, or the mips field is another generation/stack difference worth pinning in the same test.

The PR's other new resinfo/MSAA tests all pass here: gpu_direct_image_get_resinfo_d16, gpu_direct_msaa_image_loads, gpu_images_sample_load_store_atomic (including its changed get_resinfo assert with depth 0) are green on native and split.

Counts only, no game data.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

DIM 1D and 2D queries declared a Texture1D / Texture2D handle over the
multisampled view an MSAA T# (TYPE 14 / 15) binds, so the level count was
the host's: 1 on native D3D12, 3 for 4 samples on RADV through vkd3d-proton
(log2(samples) + 1), which failed gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp
on an RX 7900 XT. Both paths now branch on the T#'s TYPE and query an MSAA
T# through Texture2DMS / Texture2DMSArray, giving (width, height, 0, 1), as
RDNA2 does (AnyPS5 docs/dev/debt/shader.md, gfx1036: DIM 1D, 2D and 2D_MSAA
on 2D MSAA and MSAA-array T#s). DIM 1D now reports the height there too.
The test covers DIM 1D and 2D on a 4-sample T# and a 4-sample array T#.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, this was a real bug, not a host difference in the test. A DIM 2D image_get_resinfo on an MSAA T# was translated as Texture2D.GetDimensions on the Texture2DMS view that T# binds. D3D12 leaves that mismatch undefined, so the level count came from the host: NVIDIA gives 1, and your 3 probably comes from RADV deriving it from the MSAA image's sample count (log2(4) + 1; I haven't checked the Mesa source). The test's 1 is right: the T# has LAST_LEVEL 0, and RDNA2 returns 1 level for MSAA T#s (boykopovar/AnyPS5's gfx1036 measurement, 2 to 16 fragments).

a334936 queries an MSAA T# (TYPE 14 or 15) through Texture2DMS / Texture2DMSArray for DIM 1D and 2D on both paths, which gives (w, h, 0, 1) on every host. The test now also covers DIM 1D and a 4-sample array T#. On an RTX 3070 the gpu_ suite is unchanged: 133 passed with XCL_DIRECT_DXIL=0; with 1, 132 passed and only gpu_image_get_resinfo_1d_array failed, as on main. Could you re-run gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp on the 7900 XT?

AI-assisted (Claude Code).

RDNA2 returns (0, 0, 0, levels) for a mip at or past the level count
(AnyPS5#22724, gfx1036). D3D12 GetDimensions zeroes the sizes past the
view's levels, so only the channels a translator fills in itself can
differ: 2D's depth was 1 on both paths before this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@upipibi
upipibi force-pushed the fix/resinfo-depth-zero branch from 9fb040d to a334936 Compare November 25, 2026 07:01
@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 9fb040d3 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 9fb040d30af141fe50a0d3ce68f4500d1c9328f1
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1635 (PresentX 1636)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14624 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

@SlopTart

Copy link
Copy Markdown

Re-run done on the 7900 XT against head 9fb040d3. The fix holds on RDNA3 under Mesa: gpu_image_get_resinfo_dim_2d_of_an_msaa_tsharp now passes, including its new DIM 1D and 4-sample array variants.

Rig and stack unchanged from the failing run: RX 7900 XT (RDNA3, RADV NAVI31, Mesa 26.2.5), Proton Experimental (wine-11.0) + the xcl-pinned vkd3d-proton 3.1 build, DXC 1.9.2609.5, release build, tree cbc296ab + head 9fb040d3 merged, pipeline cache removed before each run.

resinfo set by mode:

  • default backend: 5 passed, 0 failed
  • XCL_SPLIT_WAVE64=1: 4 passed, 0 failed (tsharp included)
  • XCL_DIRECT_DXIL=1: 4 passed, 1 failed, and the one failure is gpu_image_get_resinfo_1d_array, matching your RTX 3070 note that this one fails on main with the direct backend too; it is tracked in Direct DXIL: image_get_resinfo of a 1D array gives the layers in y #2046 and is not introduced here
  • XCL_DIRECT_DXIL=1 plus XCL_SPLIT_WAVE64=1: same, only gpu_image_get_resinfo_1d_array fails

So the mip count now comes back 1 on this stack too, which fits your reading that RADV was deriving the level count from the Texture2DMS view rather than the T# (log2(sample_count) + 1 = 3 for 4 samples is consistent with what we saw).

Counts only, no game data.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @SlopTart for the re-run on RDNA3 / RADV. I've added it to the description's Tested section. The direct-DXIL gpu_image_get_resinfo_1d_array failure is #2046's, as you say.

@Diskuss

Diskuss commented Nov 25, 2026 •

Copy link
Copy Markdown

gpu_image_get_resinfo_past_last_level (9fb040d) fails on native Windows AMD: RX 9070 XT (RDNA4), driver 32.0.32015.7029, main 5478c4a, debug, default (HLSL) path. Single-level T#s, what the test prints:

mip 0x1:        2D [4, 2, 0, 1]   2D array [4, 2, 3, 1]   3D [4, 2, 1, 1]   cube [2, 2, 12, 1]
mip 0x2:        2D [2, 1, 0, 1]   2D array [2, 1, 3, 1]   3D [2, 1, 1, 1]   cube [1, 1, 12, 1]
mip 0xf:        2D [1, 1, 0, 1]   2D array [1, 1, 3, 1]   3D [1, 1, 1, 1]   cube [1, 1, 12, 1]
mip 0xffffffff: 2D [0, 0, 0, 1]   2D array [0, 0, 3, 1]   3D [0, 0, 0, 1]   cube [0, 0, 12, 1]

Cause: AMD's D3D12 driver answers GetDimensions(mip, ...) past the view's last level with max(1, size >> mip) and the unchanged array size; only mip 0xffffffff gives width/height 0, and the array size stays even then. The translators pass that through. The SM4/5 resinfo spec says an out-of-range srcMipLevel returns xyz as for an unbound resource, i.e. 0, array size included (resinfo). So this is AMD driver behaviour against the spec, not the test. The RTX 3070 and RADV runs in the description pass with the same translators.

Fix (local branch, not pushed): both translators zero the sizes themselves when mip >= levels. In recomp/emit.rs, {t}_r = {mipv} >= {t}_n ? uint4(0u, 0u, 0u, {t}_n) : uint4(...). In dxil/lower_image.rs, cmp(UGe, mipv, n) and a sel to 0 for w/h/d. It costs one compare per query. Hosts that follow the spec get the same values as before.

Tested on the fix (5478c4a + 1 commit):

Not tested: retail title / scripts/smoke.ps1, release build.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this comment.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@Diskuss Thanks. That reading of the AMD driver matches what the test was written to catch: the SM4/5 resinfo past the last level gives 0 for the sizes, and our NVIDIA driver already does that, so the test passed here. Since this PR is merged, main now fails the test on AMD, so your fix (zeroing the sizes in both translators when mip >= levels) would be worth its own PR. I'll run it on the RTX 3070 with XCL_DIRECT_DXIL=0 and =1 once it's up, to check it doesn't change anything on NVIDIA.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@Diskuss Closing my offer from above. ivall fixed it in main (ea088a58, both translators). On the RTX 3070, main 1a0bbe3a passes gpu_image_get_resinfo_past_last_level and the other four resinfo tests in a full lib run (default path), so the fix changes nothing on NVIDIA here.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants