Skip to content

Recompiler: track non-sequential image address registers - #886

Draft
nova-aryan wants to merge 1 commit into
xcl-dev:mainfrom
nova-aryan:contrib/mimg-nsa-register-uses
Draft

nova-aryan wants to merge 1 commit into
xcl-dev:mainfrom
nova-aryan:contrib/mimg-nsa-register-uses

Conversation

@nova-aryan

@nova-aryan nova-aryan commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

MIMG instructions with NSA addresses read VGPRs from extension words. Register-use tracking instead reported a contiguous range starting at VADDR, so it could omit a high address register and underestimate max_vgpr, which bounds relative VGPR move/swap switches. Fixes #885.

What is in it

  • Reuse the existing MIMG_NSA1/2/3 fields to include encoded address registers conservatively.
  • Preserve sequential-address behavior and data-register tracking.
  • Test all three extension lengths, including v255, and an NSA=0 control. Document the register-bound behavior.

Tested

  • Actual decoder/spec source modules imported by a standalone rustc --test harness under WSL Kali Linux, Rust 1.100.0.
  • Before the fix: the NSA regression failed (v100 missing), sequential control passed.
  • After the fix: 11 decoder tests passed, 0 failed, 0 ignored. Includes the existing LLVM corpus test (23,812 entries, 23,405 decoded with matching names and lengths; known RDNA1-only instructions excluded by the existing test).
  • git diff --check passed. Synthetic inputs only.

Independent test reports

  • ettehn's Windows check, RTX 5070 Ti Laptop, driver 621.24, DXC 1.8.2502.11, exact unmodified head. A local synthetic relative-VGPR/image test matched all 64 lanes; disabling this change produced a wrong texel. Build passed. Four-thread workspace run reported 673 passed, 3 failed, 21 ignored, starting with the cubemap reuse flake. A full one-thread rerun reported 717 passed, 0 failed, 41 ignored; two native-wave64 checks were SKIPPED. Two four-thread passes with Tests: check cubemap tile reuse independently of idle page reclamation #447's test changes used a combined tree, rather than the unmodified head.
  • SlopTart's Linux/Proton check, RX 7900 XT/RADV, head merged onto main 077ce40. Reported 707 passed, 11 failed, 41 ignored; the image-register tests passed. The tester attributes the failures to Wine and existing texture-test flakes. This report supplies neither retail coverage nor a passing full suite.

Regression run
Pending Windows main/head retail smoke runs.

Not tested
Main/head retail smoke runs are still missing. Windows and Linux results above are attributed independent reports. Native wave64 coverage was skipped in the Windows report; AMD RDNA4 and additional titles remain unverified. Local execution is stopped at the user's request.
All encoded NSA address slots, including padding, conservatively count as reads. Exact per-opcode/DIM/A16 address counts remain outside this change. This PR remains a public draft pending the required retail regression runs.
AI use
Codex with GPT-6.1-sol investigated the bug, wrote the code/tests and ran the standalone checks.

MIMG NSA address sources live in extension fields. Counting them as a contiguous VADDR range can underestimate max_vgpr for relative register accesses. Conservatively include all encoded addresses and retain the NSA=0 behavior. Fixes xcl-dev#885.
@ettehn

ettehn commented Nov 24, 2026 •

Copy link
Copy Markdown

Verified the relative VGPR path on Windows x64 at 0d88bf8 (RTX 5070 Ti Laptop, driver 621.24, Windows SDK DXC 1.8.2502.11). I adapted gpu_image_sample_offset locally: set M0 to 32, used V_MOVRELD_B32 with base v16 to write the Y coordinate into v48, then sampled the 4脳4 texture with IMAGE_SAMPLE_LZ_O and NSA1 extension bytes [1, 48, 0, 0]. The resulting two-component texels matched on all 64 lanes after DXC compilation and GPU dispatch. Disabling only the new MIMG register-tracking branch made lane 8 read [1, 0] instead of [1, 1].

Unmodified PR head: cargo build --workspace passed. The four-thread workspace run stopped in the library (673 passed, 3 failed, 21 ignored). The first assertion was cubemap extra_pages reuse in placed_title_textures_share_vram_and_preserve_pixels; transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory then reported PoisonError. The full one-thread rerun on the same head passed (717 passed, 0 failed, 41 ignored). Two native-wave64 checks reported SKIPPED inside those counts. Optional samples were unset; no retail smoke run.

OpenAI Codex (GPT-6.2 Astra) assisted with verification.

Follow-up on the four-thread failure: the page counts fell from 17,170,432 to 2,555,904 bytes, exactly the pair reported in #447. I applied only the test changes from #447 (48e7434) on top of 0d88bf8 and reran the entire workspace twice with four threads. Both runs passed: 717 passed, 0 failed, 41 ignored each. The cubemap reuse check passed both times. These two runs used the combined tree.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 0d88bf8 onto main 077ce40, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 707 passed, 11 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). non-sequential image-address tracking green; mirror-upload flake hit.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

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

@guinpereira

Copy link
Copy Markdown

Test report: NVIDIA RTX 5060 Ti (wave32), head 0d88bf8: 719 passed, 0 failed, 41 ignored; both new tests pass

Tested

  • NVIDIA GeForce RTX 5060 Ti 16 GB, driver 32.0.16.1714, 32-lane waves only. Ryzen 7 5700X, 32 GB RAM. Windows 11 Pro 25H2 (26200.9974), Rust 1.99.1 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0). Debug build, no XCL_SAMPLE_*.
  • PR head 0d88bf8 as is (base 1ec4c98, not rebased on current main), clean tree.
  • cargo build --workspace: ok.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 719 passed, 0 failed, 41 ignored (lib: 676 passed, 21 ignored). SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the same as on main.
  • New tests: image_nsa_address_registers_are_not_a_contiguous_range and image_sequential_address_registers_keep_the_operand_range pass. They are CPU-only decoder tests, so the GPU does not matter for them.

Not tested

  • A retail title / scripts/smoke.ps1 (no title on this machine).
  • The PR rebased on current main.

AI use: Claude Code (Claude Opus 5.5) ran the commands above and wrote this report. No code changes.

@MiguelMachado-dev

Copy link
Copy Markdown
Contributor

#1797 also fixes #885, so it overlaps this PR. It changes the same part of rdna2::vgpr_uses, and the two conflict textually.

The difference is that #1797 counts an image instruction's registers exactly instead of conservatively:

  • Addresses: the dword count comes from the opcode's modifiers, DIM and A16, in the order recomp::emit and dxil::lower_image read them. With NSA, VADDR is followed by only that many NSA bytes, so padding bytes are not counted.
  • Data: the count comes from DMASK, D16 and TFE/LWE. A compare-swap's second register (the compare value) is included. An atomic's data counts as read, and as written back only with GLC. dxil::lower_image now reads VDATA + 1 for a compare-swap only.

The tests in #1797:

  • cover NSA1, NSA2 and NSA3, sequential addresses, BVH and BVH64, A16, D16, the atomics and the v255 bound;
  • check the address count of every image instruction against the operand tables.

On an RTX 5080, the suite gives 893 passed, 0 failed, 42 ignored, against 891 / 0 / 42 on main 4178e88. The smoke runs there are still missing.

The exact counts matter for the per-lane form in #1745. That form passes only the registers vgpr_uses lists, and refuses an instruction that reads any other.

Thanks for finding and writing up #885. I'm posting this so the two don't get merged without the other in view. Happy to coordinate on which one goes in.

(Written with Claude Code, Claude Opus 5.5, xhigh.)

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

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

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 0d88bf8ba7adb7722103fa81bf72b4c24adfc4e0
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1613)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

Against the limits in CONTRIBUTING.md: 100 % 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; I checked the blocks before posting.

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.

Recompiler: VGPR tracking misses non-sequential MIMG address registers

6 participants