Skip to content

Recompiler: range-check UMA memory windows and propagate 64-bit carry/borrow - #792

Merged
theaustinayers merged 1 commit into
xcl-dev:mainfrom
gsucristo:recomp/uma-window-bounds-and-carry
Nov 24, 2026
Merged

theaustinayers merged 1 commit into
xcl-dev:mainfrom
gsucristo:recomp/uma-window-bounds-and-carry

Conversation

@gsucristo

Copy link
Copy Markdown
Contributor

Range-check multi-window UMA address selection and compute 64-bit effective addresses before selecting xcl_w, so out-of-UMA high dwords cannot alias live windows via hi & 3u and 32-bit offsets carry/borrow across 4 GiB window boundaries. Part of #105.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs, runner.rs, crates/xcl/src/hle/d3d12x/bind.rs, console_list.rs: pass Uma::base() >> 32 via IO_UMA_BASE_HI (io slot 112).
  • crates/xcl/src/gpu/recomp/emit.rs: load xcl_uma_base from io, compute 64-bit effective addresses across SMEM, MUBUF/MTBUF, FLAT/GLOBAL (including _addtid, atomics, and BVH) when mem_windows > 1, split window_read (hi == 0 maps to window 0 for 32-bit descriptor tables) vs window_write (drops hi == 0 and out-of-range high dwords), and make mem_accessors default arms return 0 / drop stores and atomics instead of aliasing mem.
  • crates/xcl/src/gpu/recomp/tests.rs: add gpu_memory_windows_reject_out_of_uma_aliasing covering out-of-UMA reads/writes/atomics, hi == 0 read vs write, strided V# high-dword masking, 64-bit carry across window 0→1, and signed borrow below window 0; populate IO_UMA_BASE_HI in gpu_sparse_vram_descriptors_buffers_and_xmem.

Tested

  • NVIDIA GeForce RTX 4090 (driver 610.57.04), AMD Ryzen 9 7950X3D, Linux + Proton Experimental / vkd3d-proton (relaxed vtable check), rustc 1.98.1 (x86_64-pc-windows-msvc cross-compile), debug.
  • cargo test --workspace --no-fail-fast --target x86_64-pc-windows-msvc -- --test-threads=4 --skip a_freed_block_is_decommitted_before_its_address_is_reused: 700 passed, 4 failed (pre-existing Wine-only failures: hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime, test_title_runs_and_game_folder_is_untouched, disk_free_space_ex_reports_pls_quota, set_predication_buffer_state_and_kickoff), 41 ignored, 1 filtered (a_freed_block_is_decommitted_before_its_address_is_reused, aborts under Wine MEM_DECOMMIT stress).
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64).
  • New/related GPU tests passed: gpu_memory_windows_reject_out_of_uma_aliasing, gpu_memory_windows_above_4_gib, gpu_mesh_mode_reads_memory_windows, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing, gpu_sparse_vram_descriptors_buffers_and_xmem.

Regression run

  • Pending native Windows scripts/smoke.ps1 runs on a retail title (Linux/Proton environment only).

Not tested

  • Native Windows 10/11, AMD RDNA (native wave64), Intel GPUs, scripts/smoke.ps1 retail regression run.

AI use

  • Antigravity (Google DeepMind; exact model version not exposed to the agent) — assisted with code, tests, and PR description; reviewed, built, and run on hardware by the author.

…/borrow

When a translated shader uses multiple 4 GiB UMA windows (`mem_windows > 1`),
`window()` previously selected `xcl_w = hi & 3u`, silently wrapping any
out-of-UMA high dword onto live windows 0..3, and address arithmetic dropped
32-bit carry/borrow across 4 GiB window boundaries (part of xcl-dev#105).

Pass `Uma::base() >> 32` through `IO_UMA_BASE_HI` (`io` slot 112) into
`xcl_uma_base`, compute 64-bit effective addresses before selecting `xcl_w`,
map `hi == 0` to window 0 for reads only (32-bit console descriptor table
pointers), and make the `default` arm in `mem_accessors` return 0 for reads
and drop stores/atomics with zeroed `out` values instead of aliasing `mem`.
@eizispark

Copy link
Copy Markdown

Hardware check of f9e5ee986081c83ec594f60f56b0ae4ade6b9210 (verified clean merge with main e50836b): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 705 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none; all tests including a_freed_block_is_decommitted_before_its_address_is_reused and e2e ran unfiltered)
  • gpu_memory_windows_reject_out_of_uma_aliasing, gpu_memory_windows_above_4_gib, gpu_mesh_mode_reads_memory_windows, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing, gpu_sparse_vram_descriptors_buffers_and_xmem: all passed on native RDNA4 wave64

Regression run
main (f4ce27c):

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1667 (PresentX 1667)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14847 MB

PR (f9e5ee9):

xcl-smoke v1
commit: f9e5ee986081c83ec594f60f56b0ae4ade6b9210
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1662 (PresentX 1662)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14914 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of f9e5ee986081c83ec594f60f56b0ae4ade6b9210 on AMD RDNA4. I merged it onto current main e50836b locally (clean merge).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200 (native Windows, not Wine), Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 705 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 664 passed, 0 failed, 21 ignored
  • 0 SKIPPED; gpu_memory_windows_reject_out_of_uma_aliasing, gpu_memory_windows_above_4_gib and gpu_mesh_mode_reads_memory_windows pass.

Review: Computing the 64-bit effective address before selecting the window, and range-checking it against the UMA base, stops an out-of-UMA high dword from aliasing a live window through hi & 3u and lets 32-bit offsets carry across a 4 GiB boundary. I reviewed the emitter change, not every caller of the new io slot.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@theaustinayers
theaustinayers merged commit aaa00b2 into xcl-dev:main Nov 24, 2026
1 of 2 checks passed
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.

4 participants