Recompiler: limit per-region loop budgets to compute and kernel shaders #2865
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2865
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2865"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Saksukella on GitHub · 2026-11-26 19:50 UTC · original
Saksukella:fix/compute-only-loop-budget→amd-dev· +46 −2 · 3 files · 1 commits · closed without mergingSummary
budget_regions->VAR_BUDGET_OWNER/VAR_BUDGET_TOTALin direct DXILcrates/xcl/src/gpu/dxil/kernel.rsandxcl_bown/xcl_btotalin HLSLcrates/xcl/src/gpu/recomp/mod.rs) strictly to compute and kernel shaders (Entry::Compute/Mode::Compute/Mode::Kernel).Entry::Mesh,Mode::Mesh,Mode::Pixel,Mode::Vertex,Mode::Geometry) keep the single program-wide loop budget and avoid injecting extra loop-carried PHI/select chains into every loop header.per_region_loop_budgets_are_compute_onlyincrates/xcl/src/gpu/recomp/tests.rs.Motivation / Root Cause
Commit
287a931b(per-region loop budgets) fixes compute spin-wait passes whose initial spin-wait otherwise exhausts a single shared65,536loop budget before the main loop runs, but appliedbudget_regionsunconditionally to all shader stages.On AMD RDNA 4 (RX 9070 XT,
amdxc64.dll), injectingVAR_BUDGET_OWNER/VAR_BUDGET_TOTALinto non-compute stages grew multi-regionEntry::Mesh/Stage::Pixelshaders by +3-11 KiB and caused a deterministic0xc0000005null-dereference insideamdxc64.dll+0xe3d80a(read at 0x4/0x4bfee,vtable amdxc64.dll+0x598bfb0) duringCreatePipelineStateon a 331,416 B two-passMS PSOat world entry (3 of 3 runs crashed at t=46-69 s onamd-dev71b8e6e0).Limiting per-region loop budgets to compute/kernel shaders preserves 100% of the compute spin-wait fix while restoring crash-free compilation on graphics/mesh pipelines (the same
MS PSOcompiles in 60-93 ms with 0 crashes across 3 consecutive 180 s world-load runs).Tested
cargo test -p xcl --lib gpu::dxil::compact: 13 passed; 0 failed (includinggpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms)cargo test -p xcl --lib per_region_loop_budgets_are_compute_only: 1 passed; 0 failedcargo test -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs: 2 passed; 0 failedxcl shaders <pack> --direct --sample 50 --validate, DXC/DXIL 1.9.2609.5): 38/38 (100%) translated & validated (CS 3/3,GS 2/2,MS 11/11,PS 15/15,VS 7/7, 0 validator errors).XCL_RT_GATE=miss,XCL_DIRECT_DXIL=1,XCL_PER_LANE=1): 0amdxc64.dll+0xe3d80acrashes and 00x887adevice removals across three 180 s runs (exit 0x0).Not tested
Regression run
Baseline (
mainb49be183):This PR (
2f4b4082):AI use
AI-assisted using Gemini 2.5 Pro for forensic log/diff analysis, implementation of the compute-only guard and regression test, and local verification on Windows (RX 9070 XT). All code changes, unit tests, offline DXIL validation, and smoke runs were executed and verified locally.
@jessenic on GitHub · 2026-11-26 19:58 UTC · original
Thanks, @Saksukella. I agree with the scope. The case #2793 fixes is a compute spin-wait, and I know of no graphics or mesh program that needs region budgets. Limiting them to compute and kernel programs also keeps every pixel, vertex, geometry and mesh program's HLSL exactly as on
main, so their cached translations and driver blobs stay valid. On the retail title, the guard changed 1,512 of the 2,682 compute programs, and the graphics programs on top of that, which is a large recompile.If the maintainer prefers one change, I can fold this into #2793 with your test, credited to you; otherwise this one stacks cleanly on it. Either is fine with me.
AI use: Claude Code (Claude Opus 5.5) wrote this comment.
@DarkPanda69 on GitHub · 2026-11-26 20:10 UTC · original
NVIDIA run (listed as untested), with the RX 9070 XT from the same PC: the new test passes on both, and the PR changes no other result.
Tested: head
2f4b408applied on its baseamd-dev71b8e6e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17, card picked withXCL_ADAPTER.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: per_region_loop_budgets --test-threads=4 --nocapture, base and PR one after the other on each card:On both cards the only result change is
per_region_loop_budgets_are_compute_only, ok. The failures are the same with and without the PR, so they come fromamd-devat71b8e6e, not from this change:dispatch_chain_native_wave64_builds_whole,a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier,f32_programs_on_the_gpugpu_fract_f32_edgesgpu_f32_compares_with_nan,gpu_float_compares_random, and the AMD fuzz seedfuzz_validate_and_gpu_1(#2115)Not tested: a non-compute shader with more than one spin-wait loop, a title, release, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@jessenic on GitHub · 2026-11-26 20:26 UTC · original
A second reason for this scope, from NVIDIA. On the RTX 5070 Ti (driver 610.88, retail title, my integration tree with #2793), the world often ended in a TDR (
0x887a0006) with region budgets in every stage. Two 900 s runs that differ only in this PR's scope:One run each, so read it as a direction. My guess at the mechanism: a graphics loop that really runs away gets up to four budgets instead of one, and on a pixel shader across a full screen that is long enough for the 2 s timeout. A compute spin-wait is the case #2793 was meant for, so I would take this scope into #2793 itself.
AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this comment.
@vibryxcx on GitHub · 2026-11-26 23:09 UTC · original
RDNA2 data for this scope, with a retail title: on an RX 6800 (driver 32.0.21045.5002), head
2f4b408still crashes inamdxc64.dll+0xd2a0f1(read at0x138), at 210 s and 163 s in 2 of 2 runs. That is the same crash as its base71b8e6e0(3 of 3 runs). Reverting287a931bon71b8e6e0removes it (600 s, clean exit). On this card the crashing pipelines are compute (driver-crashes.txtonbf7c82eelists 15cs-entries), and this PR keeps region budgets in compute. Details and thebf7c82eeretest are in #2874 (comment). This does not change your RDNA4 result for mesh shaders.Suite on head, debug,
cargo test -p xcl --lib -- --test-threads=1 --skip placed_title_textures_share_vram_and_preserve_pixels --skip d32s8_targets_take_their_own_size_of_video_memory: 1640 passed, 12 failed, 27 ignored. The 12 are the same as on71b8e6e0run the same way.per_region_loop_budgets_are_compute_only, bothgpu_a_loop_after_a_spin_to_the_budget_still_runstests andgpu_endless_loops_in_many_regions_stop_after_four_budgetspass. SKIPPED:f16_programs_on_the_gpuonly.AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and title runs and wrote this comment.
@JJAutoCompare on GitHub · 2026-11-27 00:17 UTC · original
Tested: Clean
2f4b4082882f2bff2f5932d2a6d45c44bfbc71e0, Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, debug.cargo test -j 2 -p xcl --lib --no-runthen ran six exact tests with--test-threads=1 --nocaptureon Arc. 6 passed, 0 failed, 0 ignored, 0 skips. Covered post-spin continuation in HLSL and direct DXIL, the four-budget cap in the HLSL fixture, mixed graphics-stage linking, split mesh pixel parity, and the primitive-edge loop. The edge fixture reported 0 mismatches in 1,024 pixels.Not tested: Retail and paired smoke, workspace suite, release profile, or direct-DXIL multi-region mesh execution.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.@Saksukella on GitHub · 2026-11-27 06:31 UTC · original
Ported into \md-dev\ via \
Pull request closed