Skip to content

Recompiler: keep compute shaders on single loop budget to avoid AMD LLPC crash - #2947

Merged
ivall merged 1 commit into
xcl-dev:amd-devfrom
real-alponzo:fix/2874-amd-compute-single-loop-budget
Nov 27, 2026
Merged

ivall merged 1 commit into
xcl-dev:amd-devfrom
real-alponzo:fix/2874-amd-compute-single-loop-budget

Conversation

@real-alponzo

Copy link
Copy Markdown
Contributor

Keep real compute shaders (Mode::Compute in recomp/mod.rs and compute in dxil/kernel.rs) on the single-budget loop counter instead of per-region multi-PHI loop budgets (xcl_bown / xcl_btotal), fixing the amdxc64.dll+0xd2a411 (null dereference read at 0x138) crash on AMD RDNA2 drivers during retail world load.

Fixes #2874.

Why

  • 00fe5aec (Recompiler: limit per-region loop budgets to compute and kernel shaders #2865) disabled per-region loop budgets on graphics/mesh stages to avoid AMD LLPC crashing on multi-PHI loop headers, but kept them enabled on Mode::Compute.
  • On amd-dev@bf7c82ee with an AMD Radeon RX 6800 (RDNA2, driver 32.0.21045.29003), three retail compute shaders (cs-2e0055c25f49848a / 03f8856c87ce1c90, cs-6e148dbd563de205 / 5b2e76933254ac96, and cs-62b584e061c05fc5 / 4db60c607c5af7fb) still crashed amdxc64.dll+0xd2a411 (read at address 0x138) during world load (~157 s).
  • Keeping real compute shaders on the single-budget CFG (while keeping Mode::Kernel enabled for unit tests) eliminated all amdxc64.dll+0xd2a411 crashes completely: with driver-crashes.txt cleared, the retail title ran for 1454 s (~24.2 min) into the open world with 0 driver compiler crashes (driver-crashes.txt remained empty).

What is in it

  • Updated crates/xcl/src/gpu/recomp/mod.rs and crates/xcl/src/gpu/dxil/kernel.rs to enable budget_regions(&loops) only for Mode::Kernel / kernel.
  • Updated gpu::recomp::tests::per_region_loop_budgets_are_compute_only in crates/xcl/src/gpu/recomp/tests.rs to assert Mode::Kernel emits xcl_bown/xcl_btotal while Mode::Compute, Mode::Pixel, and Mode::Mesh keep the single-budget CFG.

Regression run

Base (main):

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1525 (PresentX 1525)
presents per 2 s (last 3): 60 61 59
device removals: 0
crashes: 0
peak commit: 14867 MB

PR head (bfb40311):

xcl-smoke v1
commit: bfb40311710ab82b54c043a3e447830dcd63e112
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1527 (PresentX 1528)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15373 MB

Tested

  • Hardware: Windows 11 Pro for Workstations x64 (Build 26300), Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (Driver 32.0.21045.29003), rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib per_region_loop_budgets_are_compute_only -- --nocapture: 1 passed; 0 failed; 0 ignored; 1693 filtered out.
  • .\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60 on 8b957bec and bfb40311 (blocks above).
  • Live retail world-load soak (XCL_PREPARE=0, XCL_DEVICE_TYPE=lockhart, clean driver-crashes.txt): ran 1454 s (~24.2 min) with 0 amdxc64.dll+0xd2a411 crashes (previously crashed at ~157 s on 3 compute shaders).

Not tested

AI use

  • Antigravity (Gemini 4 Neon) diagnosed the remaining HLSL/DXIL compute amdxc64.dll+0xd2a411 crash from live RX 6800 logs, implemented the fix and test update, ran the test and paired smoke runs, and drafted this PR description.

…LPC crash

Keep real compute shaders (Mode::Compute in recomp/mod.rs and compute in dxil/kernel.rs) on the single-budget loop counter instead of per-region multi-PHI budgets (VAR_BUDGET_OWNER / VAR_BUDGET_TOTAL), preventing amdxc64.dll+0xd2a411 null-deref crashes on RDNA2 (xcl-dev#2874) while preserving Mode::Kernel for unit tests.

Verified live on RX 6800 (driver 32.0.21045.29003): 0 driver crashes past 279 s (previously crashed at ~157 s on cs-2e0055c25f49848a, cs-6e148dbd563de205, cs-62b584e061c05fc5).

Assisted-by: Antigravity (Gemini 4 Neon)
@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

NVIDIA correctness check for the behavior #2793 added. I built the exact amd-dev parent bf7c82ee and PR head bfb40311 and ran the same synthetic Mode::Compute program on Windows 11 (26200), RTX 5070 Ti Laptop / 621.24, Rust 1.97.1 MSVC debug, SDK DXC 1.8.2502.11. One wave32 group runs two independent scalar loops and writes each count to a separate word per lane. The second loop should run four times. Five fresh processes per revision ran both HLSL and plain direct DXIL (XCL_DIRECT_COMPACT=0).

Iterations in loop 1 Parent, loop 2 PR HLSL, loop 2 PR direct DXIL, loop 2
32 4 on both paths 4 4
65,535 4 on both paths 1 output word untouched
65,536 4 on both paths 0 output word untouched

The first count was correct in every case, and all 32 lane outputs matched. On direct DXIL the untouched word retained the initial 0xDEADBEEF, so the final store was never reached. This quantifies the trade-off if the AMD workaround is considered for other driver branches. It is a synthetic dispatch of translated compute, with no AMD crash reproduction or retail-title run.

OpenAI Codex assisted with verification.

@vibryxcx

vibryxcx commented Nov 27, 2026 •

Copy link
Copy Markdown

RDNA2 data and one test-coverage point, adding to @ettehn's measurement above.

1. The spin-wait tests stay green because they run in Mode::Kernel. gpu::recomp::tests::gpu_a_loop_after_a_spin_to_the_budget_still_runs builds with runner::options(Mode::Kernel) (tests.rs:1465), and the compact-form test in dxil/compact_tests.rs goes through the kernel runner too. This PR keeps region budgets only for Mode::Kernel / kernel, so those tests still pass. Real Mode::Compute loses the #2793 behaviour, which is exactly what ettehn's table shows (the second loop runs 0-1 times, or the final store is never reached). Nothing in the suite now covers the spin-wait case for real compute. If this trade-off is accepted, a test that runs the same program as Mode::Compute and asserts the current (single-budget) behaviour would at least document it, and would catch it if it changes.

2. RDNA2 title data on this question (RX 6800, driver 32.0.21045.5002, so a different driver from the description's 29003; same retail title; the details are in my #2874 comment):

tree compiler crash amdxc64.dll+0xd2a0f1 other
71b8e6e0 (region budgets everywhere) yes, 3 of 3 runs at 152-1191 s 3 of 8 preparation workers died
71b8e6e0 with 287a931b reverted no, 600 s clean exit, 0 workers died
bf7c82ee with region budgets off in every stage (local patch, the same effect on compute as this PR) no, 0 workers died, driver-crashes.txt stayed empty device removed (0x887a0006) 730 s into the title

The device loss is not clearly caused by the change, because bf7c82ee itself lost the device in 3 of 3 600 s runs on this card. But it is the failure mode one would expect from a compute spin-wait that runs out a single budget, so a longer run of this head would be worth watching for a TDR as well as for the compiler crash.

3. Lib suite on this head (bfb40311, debug, cargo test -p xcl --lib -- --test-threads=1 with the tests skipped that hang or abort only inside the full amd-dev run, xgameruntime::gamesave::tests run on their own; see #42): main run 1642 passed, 11 failed, 27 ignored, and gamesave 11 passed, 0 failed. The 11 failures are all ones base bf7c82ee has. The base's 12th, gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, passed here, and it is the known flaky one. per_region_loop_budgets_are_compute_only (as changed here) and the budget tests pass.

Title runs of this exact head: see the update below.

AI use: Claude Code (Claude Opus 5.5) read the diff and tests, ran the suite through a local runner, and wrote this comment. The title numbers come from the runs referenced in #2874.


Update: title runs of this exact head on the RX 6800 (driver 32.0.21045.5002, release, driver-crashes.txt moved aside so no pipeline was skipped, A pressed every 10 s; XCL_RUN_SECONDS=600, preparation included; the list was restored afterwards).

run amdxc64.dll compiler crash driver-crashes.txt written end first / last present fps while presenting (avg / peak)
head, run 1 (cold: compute prep 44 s, graphics 46 s) no no device reset 0x887a0007 at 493 s 157 s / 492 s 8.8 / 33
head, run 2 (warm) no no device reset 0x887a0007 at 344 s 27 s / 341 s 8.4 / 32
base bf7c82ee (soak run 1, same settings, list in place) (crashes were already listed and skipped) – device removed 0x887a0006 at 226 s 25 s / 223 s 13.3 / 32
  • The compiler crash is gone on this card. On bf7c82ee, every long run with an empty list crashed the compiler or wrote new cs- entries (amd-dev f84a949: AMD driver crashes (amdxc64.dll+0xd2a411) compiling the title's native DXIL compute shader ca7beffb8d3a8f28 (RX 6750 XT) #2874), and with this head neither run did.
  • The device loss remains. Both runs ended in a device reset (0x887a0007) after 6-8 minutes. That is no earlier than the base's own losses (226-407 s), but not fixed either. I cannot tell from these runs whether it comes from the Mode::Compute spin-wait trade-off (point 1 above) or from whatever already takes the base's device down.
  • Regression run (60 s, scripts/smoke.ps1, same title, warm; blocks copied unchanged from the script output):
xcl-smoke v1
commit: bf7c82ee1b2685bb40417e09c4128177aa68d719
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1317 (PresentX 1317)
presents per 2 s (last 3): 61 62 60
device removals: 0
crashes: 0
peak commit: 13365 MB
xcl-smoke v1
commit: bfb40311710ab82b54c043a3e447830dcd63e112
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1284 (PresentX 1285)
presents per 2 s (last 3): 60 63 61
device removals: 0
crashes: 0
peak commit: 13368 MB

Frames are 97 % of the base and peak commit is the same, within the limits.


After the merge: amd-dev 5fbd90f9 on the RX 6800, for the open point about compact.rs in the merge comment. 2 runs of 600 s, driver-crashes.txt moved aside, A every 10 s:

  • No amdxc64.dll compiler crash, and no driver-crashes.txt written, in either run. So in these runs no compute program crashed the compiler through the compact form. That does not rule it out for a later scene.
  • Both runs still ended in a device reset (0x887a0007), at 343 s and 337 s. Last present was at 341 s and 335 s, with 9.4 and 8.5 fps while presenting.

@DarkPanda69

Copy link
Copy Markdown

NVIDIA run (listed as untested), with an RX 9070 XT in the same PC: the PR changes no GPU test result on either card.

Tested: head bfb4031 applied on its base amd-dev bf7c82e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, card picked with XCL_ADAPTER.
XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: per_region_loop_budgets loop --test-threads=4 --nocapture, base and PR one after the other on each card:

  • NVIDIA RTX 3060, driver 32.0.16.1088: base and PR both 771 passed, 4 failed, 20 SKIPPED.
  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: base and PR both 769 passed, 6 failed, 4 SKIPPED.

No test changes result between base and PR on either card. The failures are the same with and without the PR, so they come from amd-dev (the same set I listed on #2865):

This is RDNA4 and Ampere running the unit and GPU tests. It doesn't cover the LLPC crash on RDNA2 with retail shaders.

Not tested: RDNA2, a title run, release, Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

First RDNA3 / native-Windows data for this head: no crash on either side, so this does not show the fix.

Hardware: RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003, 64 GB RAM, Windows 11 Pro 10.0.26200, Rust 1.100.0, release builds.
Revisions: base amd-dev bf7c82ee1b2685bb40417e09c4128177aa68d719, PR head bfb40311710ab82b54c043a3e447830dcd63e112 (merges cleanly onto amd-dev).
All runs used XCL_PREPARE=0 with a warm shader cache (a fresh copy per run) and the same retail title.

Unit test: cargo test -p xcl --lib per_region_loop_budgets_are_compute_only on the head: 1 passed, 0 failed, 0 ignored. I did not rerun the recomp GPU module, since #2947 already has RDNA2 / RDNA4 results for it.

scripts/smoke.ps1, 60 s (each block from its own commit, clean tree):

frames presents per 2 s (last 3) device removals crashes peak commit
base 1387 63 60 60 0 0 12607 MB
head 1500 63 60 60 0 0 12524 MB

Longer title runs (480 s, scripted A presses every 8 s from t=16 s through the menu, 2 runs per side, alternating):

run exit amdxc64 crash device removals driver-crashes.txt frames shown peak commit
base 1 ran to 480 s no 0 none 1754 24080 MB
base 2 ran to 480 s no 0 none 1919 23639 MB
head 1 ran to 480 s no 0 none 1822 24115 MB
head 2 ran to 480 s no 0 none 1833 23403 MB
  • Presenting stops after about 2 min on all four runs, base and head alike, with no crash and no device removal. head 2 had two presents near 8 min (8011 draws in that minute).
  • Earlier bf7c82ee runs on this card crashed in amdxc64.dll with a read at 0x138, about 95 s in. That crash did not reproduce on the base in these two runs, so the head's clean runs are not evidence for the fix.
  • None of the runs got past the menu / loading phase, so there is no in-world data and no FPS claim.

Not tested: in-world play, a base build that crashes on this setup, cold-cache runs (the compiler path that crashed on RDNA2), and the Mode::Compute spin-wait trade-off from ettehn's and vibryxcx's comments above.

AI use: Claude Code (Claude Sonnet 5.5) built both revisions, ran the commands above on this machine and wrote this report.

@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

RDNA3 data for this PR: the AMD compiler crash in compute is gone with this head, 2 of 2 runs (and the same crash is deterministic on the base).

Setup: RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003, Ryzen 7 5700X3D, 64 GB, Windows 11 build 26200. Release builds, no local changes, of bf7c82ee (base) and bfb40311 (this head), the same retail title. XCL_PREPARE=0 XCL_PSO_WAIT_MS=200 XCL_NETWORK=0, A pressed every 8 s, 300 s runs, each on a fresh copy of the same warm shader cache and profile (the cache's driver-crashes.txt kept). Runs interleaved base / head / base / head.

run tree result
1 base 0xc0000005 in amdxc64.dll+0xdce035 (read at 0x18) at 233 s, compiling a compute PSO of 509,896 B DXIL
2 head no compiler crash; the title died at 216 s in its own code (a read at a wild address), with every driver compile finished
3 base same crash, same pipeline, at 214 s
4 head no crash; the same pipeline compiled (502,016 B DXIL now), clean exit at 300 s, 70-107 presents per 30 s in the last 90 s
  • That pipeline is the one the DXIL XCL saves after a driver crash shows as: 76 loops in 21 outer regions (so 21 budget resets), nesting up to three deep, about 4,700 PHIs (outer loop headers carry 100-112 loop-carried values). That is the shape the per-region budgets produce.
  • Earlier runs of an amd-dev bf7c82ee build from a previous session (same cache, same input, not rebuilt by me): 3 of 3 runs with XCL_PSO_WAIT_MS=200 crashed on this same pipeline at 204-219 s; 0 of 5 runs without it did (240-480 s). Without the limit the title sits in pipeline waits from about 90 s and never reaches this pipeline within 300-480 s. The limit's stand-ins let it get there.
  • No device removal in these four runs.

Not tested: the Mode::Compute spin-wait trade-off that ettehn measured; more than 2 runs per tree; a cold cache; the title's own-code crash in run 2 (one occurrence, not reproduced in the other head run, cause unknown).

AI use: Claude Code (Claude Sonnet 5.5) built the trees, ran the title, read the logs and wrote this comment. Every number comes from those runs.

@ivall
ivall merged commit 5fbd90f into xcl-dev:amd-dev Nov 27, 2026
1 of 2 checks passed
@ivall

ivall commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Merged into amd-dev (5fbd90f) on the maintainer's word, on the strength of the reports in #2874: the compiler crash still on bf7c82ee on an RX 6800 (two driver versions) and an RX 7800 XT, and gone with this head in the runs reported there.

Not run here before merging: no test and no title run on the maintainer's RX 9070 for this head. CI's Build and test was red on it; I did not check whether that is the tests that already fail on amd-dev.

One thing left open: gpu/dxil/compact.rs still takes budget_regions for every program (two places), so a compute program that goes to the compact form keeps per-region budgets. If the crash shows again on such a program, that is where to look.

Written with Claude Code (Claude Fable 5.2) for the maintainer.

@oni-swr

oni-swr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the merge (5fbd90f9): the CI failures I could reproduce are not new with #2947, and two 600 s runs of the merged tree on an RX 7800 XT ended in the title's own code, not in the driver compiler.

(a) CI failures. cargo test -p xcl --lib on the 9 named tests, base bf7c82ee vs 5fbd90f9, debug, -j 4 --test-threads=4, XCL_ADAPTER=warp (no hardware GPU; I do not know that this is exactly what the runner sees), Windows 11 build 26200, Ryzen 7 5700X3D:

  • both trees: 3 passed, 6 failed, the same 6, each panicking at the same file and line: dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, bitset_runs_emit_exact_contiguous_page_ranges, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, giant_driver_compiles_have_their_own_lane, title_bytes_are_used_in_place_when_all_are_readable.
  • passed on both trees here, so I cannot say anything about them: the_mirror_sync_copies_only_the_pages_the_title_wrote, gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, d32s8_targets_take_their_own_size_of_video_memory.
  • So none of the failures I could reproduce is new with Recompiler: keep compute shaders on single loop budget to avoid AMD LLPC crash #2947. Not run: the whole suite, a runner with no adapter at all.

Merged tree on RDNA3 (RX 7800 XT, driver 32.0.31035.1003, 64 GB, build 26200), XCL_PREPARE=0 XCL_PSO_WAIT_MS=200 XCL_NETWORK=0, 600 s, A every 8 s, warm cache copy; the binary is bfb40311, whose tree is identical to 5fbd90f9:

  • 2 runs: no amdxc64.dll crash in either, but neither reached 600 s. Run 1: 0xc0000005 in the title's image at 426 s, a read at a wild address. Run 2: the same kind of read, at another offset in the title's image, at 336 s. Both are in game_scarlett_master.exe (the title's own native code, not a recompiled shader); with the 216 s death in my earlier comment that is three different offsets in three runs. In both runs the last profile lines show DXC jobs still running and a driver compile in progress.
  • Run 2 also showed a separate XCL problem: after the exception the process never exited. The log ends in the flight dump, all 135 threads were suspended and stdout/stderr stayed empty; my script killed it at 780 s. Not looked into further.
  • Presents: both runs show the same ~90 s stop, then a few per 30 s from ~150 s, 70-140 per 30 s around 270-330 s, against ~500-650 per 30 s before the stop. I do not know if the title reached a controllable world.

(b) Which huge compute records take the compact form. In all 13 title runs I made today (several trees: bf7c82ee, 5fbd90f9, #2988, #2981 merged) and in 9 earlier ones, the log has exactly one direct DXIL compact form line: 20,965 blocks of 672 kinds, at 99-132 s, and nothing else. It is the record #2796's description names. I did not map the pipeline that crashed bf7c82ee to it, so I cannot say whether the crashing pipeline took the compact path. Separately, the --direct translation of the 5 largest compute records of the pack I looked at (0.26-2.0 MB of direct DXIL): one of them takes the compact form (257 KB, against 1.78 MB with XCL_DIRECT_COMPACT=0), the other four give the same size either way.

Not tested: more than 2 runs, a cold cache, other GPUs, the full test suite.

AI use: Claude Code (Claude Sonnet 5.5) built the trees, ran the tests and the title, read the logs and wrote this comment. Every number comes from those runs.

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.

6 participants