Recompiler: track non-sequential MIMG address VGPRs #2277

Closed
mokkamokacaffe wants to merge 1 commit from upstream-pr/2287 into main
mokkamokacaffe commented 2026-11-25 12:26:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-25T12:26:34Z.


Fixes #885.

rdna2::vgpr_uses treated an MIMG instruction's VADDR as one consecutive register range even when NSA extension words encoded independent address VGPRs. That omitted high non-sequential registers from max_vgpr and falsely included adjacent low registers, which can under-bound relative VGPR moves and swaps.

What is in it

  • crates/xcl/src/gpu/rdna2.rs: for NSA MIMG instructions, count the base VADDR once and read every VADDRA… field from the selected MIMG_NSA1/2/3 encoding.
  • Preserve the existing consecutive range for ordinary NSA=0 MIMG instructions.
  • Add a regression covering all three NSA extension lengths and a sequential control.

Tested

  • Linux x86-64, Rust 1.100.0, debug; standalone harness importing the production decoder and generated instruction tables.
  • Failing-first, without the implementation: mimg_nsa_vgpr_uses_follow_encoded_registers failed for NSA1, reporting [4, 5, 6, 7, 8, 9, 10, 11, 12] instead of [4, 100, 101, 102, 103].
  • With the implementation:
    • cargo test mimg_nsa_vgpr_uses_follow_encoded_registers -- --nocapture: 1 passed, 0 failed, 0 ignored.
    • cargo test image_operands_and_modifiers -- --nocapture: 1 passed, 0 failed, 0 ignored.
    • cargo test vgpr_in_nine_bit_field -- --nocapture: 1 passed, 0 failed, 0 ignored.
  • git diff --check: passed.

Regression run

main:

Pending: requires Windows, a D3D12 GPU and a real-title installation.

this PR:

Pending on clean head e165370: requires Windows, a D3D12 GPU and the same title and duration as the main run.

Not tested

  • Full Windows workspace build and test suite. A Linux workspace build was attempted but stopped in Windows-only dependencies.
  • GPU execution on AMD or NVIDIA hardware.
  • A shader-pack survey measuring how many programs' computed max_vgpr changes.
  • Paired scripts/smoke.ps1 retail-title runs.

AI use

  • OpenAI Codex (GPT-5) reviewed issue #885 and current decoder/emitter behavior, implemented the narrow tracking fix and regression, ran the failing-first and passing standalone checks, reviewed the diff, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:6604447033 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287). Originally posted by [mokkamokacaffe](https://github.com/mokkamokacaffe) on 2026-11-25T12:26:34Z. --- Fixes #885. `rdna2::vgpr_uses` treated an MIMG instruction's `VADDR` as one consecutive register range even when NSA extension words encoded independent address VGPRs. That omitted high non-sequential registers from `max_vgpr` and falsely included adjacent low registers, which can under-bound relative VGPR moves and swaps. **What is in it** - `crates/xcl/src/gpu/rdna2.rs`: for NSA MIMG instructions, count the base `VADDR` once and read every `VADDRA`… field from the selected `MIMG_NSA1/2/3` encoding. - Preserve the existing consecutive range for ordinary `NSA=0` MIMG instructions. - Add a regression covering all three NSA extension lengths and a sequential control. **Tested** - Linux x86-64, Rust 1.100.0, debug; standalone harness importing the production decoder and generated instruction tables. - Failing-first, without the implementation: `mimg_nsa_vgpr_uses_follow_encoded_registers` failed for NSA1, reporting `[4, 5, 6, 7, 8, 9, 10, 11, 12]` instead of `[4, 100, 101, 102, 103]`. - With the implementation: - `cargo test mimg_nsa_vgpr_uses_follow_encoded_registers -- --nocapture`: 1 passed, 0 failed, 0 ignored. - `cargo test image_operands_and_modifiers -- --nocapture`: 1 passed, 0 failed, 0 ignored. - `cargo test vgpr_in_nine_bit_field -- --nocapture`: 1 passed, 0 failed, 0 ignored. - `git diff --check`: passed. **Regression run** main: Pending: requires Windows, a D3D12 GPU and a real-title installation. this PR: Pending on clean head `e165370`: requires Windows, a D3D12 GPU and the same title and duration as the main run. **Not tested** - Full Windows workspace build and test suite. A Linux workspace build was attempted but stopped in Windows-only dependencies. - GPU execution on AMD or NVIDIA hardware. - A shader-pack survey measuring how many programs' computed `max_vgpr` changes. - Paired `scripts/smoke.ps1` retail-title runs. **AI use** - OpenAI Codex (GPT-5) reviewed issue #885 and current decoder/emitter behavior, implemented the narrow tracking fix and regression, ran the failing-first and passing standalone checks, reviewed the diff, and drafted this description.
Lum7nt commented 2026-11-25 13:05:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-25T13:01:54Z.


Windows targeted checks on clean head e16537082d8e678ee53a1b64f63783529ba48be2 (release): Windows 11 build 26300, rustc 1.100.0 MSVC. For each filter below I ran cargo test --offline --locked --release -p xcl --lib <filter> -- --nocapture --test-threads=1:

  • mimg_nsa_vgpr_uses_follow_encoded_registers: 1 passed, 0 failed, 0 ignored.
  • image_operands_and_modifiers: 1 passed, 0 failed, 0 ignored.
  • vgpr_in_nine_bit_field: 1 passed, 0 failed, 0 ignored.

No SKIPPED messages. These are CPU decoder tests; the machine has an RX 9070 XT (driver 32.0.32029.2010), but these checks do not exercise the GPU. Full workspace, shader-pack survey, retail title and paired smoke runs were not tested here.

AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the checks and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7163193417 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287#issuecomment-7163193417). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-25T13:01:54Z. --- **Windows targeted checks** on clean head `e16537082d8e678ee53a1b64f63783529ba48be2` (release): Windows 11 build 26300, rustc 1.100.0 MSVC. For each filter below I ran `cargo test --offline --locked --release -p xcl --lib <filter> -- --nocapture --test-threads=1`: - `mimg_nsa_vgpr_uses_follow_encoded_registers`: 1 passed, 0 failed, 0 ignored. - `image_operands_and_modifiers`: 1 passed, 0 failed, 0 ignored. - `vgpr_in_nine_bit_field`: 1 passed, 0 failed, 0 ignored. No SKIPPED messages. These are CPU decoder tests; the machine has an RX 9070 XT (driver 32.0.32029.2010), but these checks do not exercise the GPU. Full workspace, shader-pack survey, retail title and paired smoke runs were not tested here. AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the checks and drafted this report.
upipibi commented 2026-11-25 14:10:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T13:59:49Z.


First GPU run, as far as I can see in this thread (NVIDIA). Exact head e165370, as-is on its base 1a0bbe3a: RTX 3070 8 GB, driver 616.56, Windows 11, debug.

run XCL_DIRECT_DXIL=0 XCL_DIRECT_DXIL=1
mimg_nsa_vgpr_uses_follow_encoded_registers passes passes
gpu_ suite (--skip gpu_sparse_vram, single-threaded) 144 passed, 0 failed, 1 ignored 144 passed, 0 failed, 1 ignored
same suite on main 1a0bbe3a 144 passed, 0 failed, 1 ignored 144 passed, 0 failed, 1 ignored

So nothing in the gpu_ suite changes on this card with the PR.

Not tested: AMD, a title, the whole workspace.

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

<!-- greyfinch-sync:ivall/xcl:comment:7164596544 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287#issuecomment-7164596544). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T13:59:49Z. --- First GPU run, as far as I can see in this thread (NVIDIA). Exact head `e165370`, as-is on its base `1a0bbe3a`: RTX 3070 8 GB, driver 616.56, Windows 11, debug. | run | `XCL_DIRECT_DXIL=0` | `XCL_DIRECT_DXIL=1` | |---|---|---| | `mimg_nsa_vgpr_uses_follow_encoded_registers` | passes | passes | | `gpu_` suite (`--skip gpu_sparse_vram`, single-threaded) | 144 passed, 0 failed, 1 ignored | 144 passed, 0 failed, 1 ignored | | same suite on `main` `1a0bbe3a` | 144 passed, 0 failed, 1 ignored | 144 passed, 0 failed, 1 ignored | So nothing in the `gpu_` suite changes on this card with the PR. **Not tested:** AMD, a title, the whole workspace. AI-assisted (Claude Code). Synthetic tests only.
throny commented 2026-11-25 16:12:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T15:33:29Z.


Two contributors checked independently and found that #886 #1797 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.

<!-- greyfinch-sync:ivall/xcl:comment:7167027660 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287#issuecomment-7167027660). Originally posted by [throny](https://github.com/throny) on 2026-11-25T15:33:29Z. --- <!-- xcl-1607-hint:D81 --> Two contributors checked independently and found that #886 #1797 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.
DavidM1911 commented 2026-11-25 18:04:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T17:17:35Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7169289044 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287#issuecomment-7169289044). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T17:17:35Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
upstream-sync closed this pull request 2026-11-25 23:08:12 +00:00
CalvyPZ commented 2026-11-25 23:09:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:37:41Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7176596413 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2287#issuecomment-7176596413). Originally posted by [CalvyPZ](https://github.com/CalvyPZ) on 2026-11-25T22:37:41Z. --- 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.

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