Skip to content

[upstream #942] Recompiler: keep far jumps indirect when entered after s_getpc_b64 (#863) - #153

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/942
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/942

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Fixes xcl-dev#863.

What changed

  • crates/xcl/src/gpu/rdna2.rs (resolve_far_jumps):
    • Clear any existing far_target before scanning so branch_target only inspects direct branches.
    • Collect all candidate 4-instruction far-jump sequences (S_GETPC_B64 / S_ADD_U32+S_ADDC_U32 or S_SUB_U32+S_SUBB_U32 / S_SETPC_B64) first (returning immediately with no allocation when there are none).
    • Gather all direct branch targets plus all prospective far-jump targets, and publish far_target only when none of the sequence's post-S_GETPC_B64 instructions (lo, hi, set) is targeted. Entering at S_GETPC_B64 itself still resolves as a direct far jump.
  • crates/xcl/src/gpu/recomp/tests.rs (far_jumps_stay_indirect_when_entered_after_getpc):
    • Covers direct conditional branches into get, lo, hi, and set for both add and subtract forms, verifying far_target and that translate keeps s_setpc_b64 indirect when s_getpc_b64 is bypassed.
    • Covers far-to-far edges targeting get, lo, hi, and set of a second far-jump sequence.

Tested

  • Windows 11 x64, Ryzen 7 7735HS, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug build, no game data:
    • NVIDIA GeForce RTX 4060 Laptop GPU (wave32, default adapter):
      • cargo test -p xcl --lib far_jump: 3 passed, 0 failed.
      • cargo test -p xcl --lib gpu:: -- --test-threads=4: 284 passed, 0 failed, 18 ignored (SKIPPED: no wave64 on 2 tests).
    • AMD Radeon 680M (RDNA2, native wave64, XCL_ADAPTER=radeon):
      • cargo test -p xcl --lib far_jump: 3 passed, 0 failed.
      • cargo test -p xcl --lib gpu:: -- --test-threads=4: 284 passed, 0 failed, 18 ignored (SKIPPED: no mesh shaders on 2 tests).
  • Independently verified in the comments below by @dcastell1 (RTX 5090, cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored) and @eizispark (RX 9070 XT).

Regression run

main (beaa245):

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

PR (a527eb3):

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

Not tested

  • A retail title on my machine (I have no retail files; the regression run above is @eizispark's).
  • Gameplay past the menus, Intel GPUs, Linux/Wine.

AI use

  • Antigravity (Gemini) wrote the fix and regression tests, ran the local dual-GPU tests, and drafted this PR description.

Mirror of xcl-dev#942 (auto-synced, do not edit).

@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#942 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/942 branch November 25, 2026 00:08
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: far jumps ignore incoming branches into the address calculation

2 participants