Recompiler: image instructions name the registers they use #1787
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1797"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by MiguelMachado-dev on 2026-11-24T20:52:26Z.
rdna2::vgpr_usestook an image instruction's registers from the operand tables, which give the largest case: a 3-D address with every modifier, and four data registers. That gets several things wrong:VDATA + 1);It now counts what
recomp::emitanddxil::lower_imageread. Fixes #885. Part of #1269.On
main, these callers act on the registers:dxil/kernel.rs→setup_vertex).max_vgpr, as #885 describes).xcl shadersreports a program's inputs from them.The per-lane form in #1745 passes exactly these registers to #1426's lowering, so without this it refuses every image instruction with NSA addresses. The per-lane tests are a follow-up on top of #1745.
This overlaps draft #886 (also
Fixes #885), which counts every encoded NSA byte, padding included, and leaves the data registers as they are. This PR counts the address dwords and the data registers exactly, and its tests cover NSA1, NSA2, NSA3 and the v255 bound.What is in it
Recompiler: image instructions name the registers they usecrates/xcl/src/gpu/rdna2.rs:mimg_vgpr_usesandmimg_address_dwords, and the testsimage_register_usesandimage_address_counts_reach_the_operand_tables.crates/xcl/src/gpu/dxil/lower_image.rs: an atomic readsVDATA + 1for a compare-swap only.Tested
Setup:
cargo build --workspace && cargo test --workspace -- --test-threads=4:8ec49c0: 893 passed, 0 failed, 42 ignored (lib: 844 / 0 / 22);main4178e88: 891 passed, 0 failed, 42 ignored (lib: 842 / 0 / 22).SKIPPED GPU tests, the same 4 on both runs:
gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsshaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)image_register_usesfails without the change. For a 2-D load with DMASK 0x5, it gets([3, 4, 5, 6], [14, 15, 16, 17])where([3, 4], [14, 15])is expected.image_address_counts_reach_the_operand_tableschecks the address count of every image instruction against the operand tables.On #1745's per-lane form (at 3ca3633), a sweep sent every
IMAGE_*instruction through the per-lane compute lowering, over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses:The follow-up's GPU tests compare loads and samples with NSA and sequential addresses, D16, a store, a gather, resinfo, GLC atomics and BVH with NSA addresses against the HLSL path.
Regression run
scripts/smoke.ps1with-Xclpointing at that worktree'sxcl.exemain's frames and 103.8 % of its peak commit, with no device removal or crash.main4178e88:This PR's head
8ec49c0:XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PRESS_A_AT=20, network offmain's frames and 102.9 % of its peak commit.main4178e88, 180 s:This PR's head
8ec49c0, 180 s:Not tested
main's world-load stall (#1833).main-side effects listed above come from reading the code, not from a run. I have no title with a VS that reads its inputs only as NSA addresses, or with a movrel past them.vgpr_usesfollows the translators, andimage_address_counts_reach_the_operand_tablespins the difference.AI use
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-24T21:06:49Z.
@MiguelMachado-dev the paired
xcl-smokeblocks you asked for, same title and same time (60 s) on both commits.Tested
cargo build --release -p xcl), andscripts/smoke.ps1was run from that worktree. On Windows PowerShell 5.1 the script's default-Xclpath fails ($PSScriptRootis empty inside theparamblock), so I passed-Xclwith the worktree'starget\release\xcl.exe; nothing else was changed.main4178e88:#1797
8ec49c0:The PR's run has 97.9 % of
main's frames and 103.8 % of its peak commit, with no device removal or crash. 60 s on this title is the intro and menus, before the world load, so it does not reach the direct-DXIL VS path or the per-lane form this PR feeds.Not tested: AMD, native wave64, heap windows, a longer run into the world load.
AI use: Claude Code (Claude Opus 5.5) built both commits, ran the smoke script and wrote this comment.
Imported from ivall/xcl. Originally posted by alexmircea1299 on 2026-11-24T21:30:05Z.
Test report on NVIDIA GeForce RTX 5070 (12 GB)
8ec49c0)621.35), 32 GB DDR5 6000MT/s26300),rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK10.0.26100.0(debug build).\scripts\test.ps1(cargo test --workspace -- --test-threads=4)852 passed; 0 failed; 34 ignored(includingxcl --liband integration tests).gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask&gpu_wave32_program_in_wave64_hardware(no wave64)shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(requires Windows Developer Mode for driver cache)no heap windows).Imported from ivall/xcl. Originally posted by Raghav314 on 2026-11-24T22:13:48Z.
A paired run that reaches the direct DXIL path, for the gap noted in the Regression run section (the 60 s runs end in the menus). RTX 4090 24 GB (driver 617.14, 32-lane waves), Windows 11, release,
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PRESS_A_AT=20, 180 s, network off, the same retail title for both.Both runs go through the menus into the world load. On each, about 13 300–13 600 draws ran with translated pipelines (none skipped) and around 400 compute pipelines were built on the direct path. Presents stop at ~70 s on both, which is
main's known world-load stall (#1833), not this PR. No fallback, device removal or crash on either.main4178e88:This PR's head
8ec49c0:101.5 % of
main's frames, 102.9 % of its peak commit.Not tested: whether any of the changed register counts decided a translation in these runs (the log does not say which programs took the changed path), AMD.
AI use: Claude Code (Claude Opus 5.5) ran both builds and runs and wrote this comment for @Raghav314.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T00:04:57Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.Thanks!
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T15:33:28Z.
Two contributors checked independently and found that #886 #2287 solves the same problem (for #885) in a different way: #1607, group D81. 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.
Imported from ivall/xcl. Originally posted by Chrysana on 2026-11-25T19:53:29Z.
AMD results for this change, for "AMD, wave64, heap windows" under Not tested. They come from my run of #1825 (comment), whose head carries this PR's commit (
c2b0c00, the same patch as8ec49c0:git patch-id --stablematches). I didn't run8ec49c0on its own base. On an RX 9070 XT (RDNA4, wave64) and an RDNA2 iGPU, both new tests pass, the per-lane image tests that depend on this change pass on both GPUs, and nothing fails in the full suite.Setup: AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008; Ryzen 7 9800X3D with its RDNA2 Radeon iGPU (
XCL_ADAPTER=1); Windows 11 26200.9974, rustc 1.100.0 MSVC, debug. #1825's head434f428onc4d37be, and that base alone, each in its own checkout and target folder.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(RX 9070 XT): 965 passed, 0 failed, 43 ignored with this commit and #1825's tests, against 959 / 0 / 43 onc4d37be. The difference is the six tests: two here, four in #1825.gpu::rdna2::tests::image_register_usesandimage_address_counts_reach_the_operand_tables: ok on both GPUs (gpu::rdna2::11 passed on each).gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardwareboth pass. Neither is changed by this PR, so that only shows the wave64 side of the base is fine here.per_lane_image_instructions_agree_with_the_hlsl_path_on_the_gpuanda_per_lane_bvh_with_nsa_addresses_runs_on_the_gpu(NSA and sequential addresses, D16, compare-swap, BVH with NSA), pass on both GPUs. They run their programs as wave32, so they don't cover wave64 image instructions.heap_window_out_of_memory_falls_back_to_the_switch_formis SKIPPED here too (no heap windows).Not tested
8ec49c0on its own base4178e88, or merged onto currentmain.AI use
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:25:47Z.
Review: COMMENTED
No confirmed source blocker. Image VGPR-use tracking aligns with HLSL/Direct-DXIL operands including NSA/compare-swap; focused and later AMD/wave64 evidence is strong. This dirty/non-mergeable head needs rebase/current Windows CI and resolution/consolidation with overlapping #886/#2287 before merge. Residual gaps: Direct-DXIL graphics execution and heap-window/native-wave64 title validation; retain documented G16 packing limitation.
Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:37:34Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T11:25:51Z.
I prepared a local rebase of #1797 head
8ec49c0onto currentmain623d02e4, then placed the unchanged #1825 test commit on top. This is an unpublished local candidate, not a new PR head. The compact conflict-resolution diff below preserves main's newer 64-bit and floating-point image atomic handling while adding #1797's exact register accounting. It also makes the existing D16 RESINFO sentinel test explicitly read its trailing VGPRs; no assertion is relaxed.The corrected
image_register_usestest is red on clean main (0 passed, 1 failed; the 2D DMASK 0x5 case counts four inputs/outputs where two are expected) and green on the rebased stack. Astra independently traced the 32/64-bit atomic and D16 paths and found the scoped resolution consistent with their callers.Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, DXC 1.8.2502.11, isolated writable DXIL cache per revision.
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: clean main 1,458 passed / 0 failed / 47 ignored; local #1797 + #1825 stack 1,464 passed / 0 failed / 47 ignored. Both runs logged 25 GPU skips (21 no wave64, three existing per-lane f16/packed refusals, one no heap windows); the stock #1825 GPU image and BVH tests ran and passed. The extra six passes are the two parent and four child tests. A clean-head retail smoke pair and CI on an updated PR head remain to be done after the author pushes a rebase; these local counts do not satisfy that PR gate.Compact rebase resolution diff against the cherry-pick conflict
The child tests in #1825 only need placement after this parent; I will leave that short note there. AI use: Codex (GPT-6.2 Sol) resolved the integration and ran the builds and tests; Codex (GPT-6.2 Astra) reviewed the image register and D16 behavior.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:49:11Z.
Triage (#1607) – head
8ec49c0Update (rechecked against main
6bfb5c51): withdrawn from the close list; recommendation: keep open. Main'smimg_vgpr_uses(43c56dce) counts atomic data as always written, givesIMAGE_MSAA_LOADDMASK registers and has no TFE/LWE register; this PR handles all three. Not superseded.Main now has
mimg_vgpr_usesandmimg_address_dwordsinrdna2.rs, from #3502 (43c56dce). They count image address registers (NSA one per byte, A16 packing, BVH 11/12) and data registers (DMASK, D16, gather 4, store reads, atomic reads), which is what this PR adds. Thelower_image.rspart (no read ofvdata+1for atomics other than compare-swap) is in open #2077. What is left here are refinements to main's version: atomics write back only with GLC, the TFE/LWE extra register, and 4 forIMAGE_MSAA_LOAD. They could go in a short PR rebased on main. #1825 is stacked on this PR (same first commit). #886 adds NSA registers only, which main also covers now.Recommendation: close (superseded by #3502; the lower_image fix is in #2077).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run.
Pull request closed