Skip to content

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

Open
real-alponzo wants to merge 1 commit into
xcl-dev:amd-devfrom
real-alponzo:fix/2874-amd-compute-single-loop-budget
Open

real-alponzo wants to merge 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.

@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.

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.

5 participants