Repository navigation
Recompiler: limit per-region loop budgets to compute and kernel shaders - #2865
Saksukella wants to merge 1 commit into
Conversation
|
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 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. |
|
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
On both cards the only result change is
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. |
|
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 (
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. |
Taken from @Saksukella's xcl-dev#2865. The spin-wait the region budgets are for is in a compute program. Graphics and mesh stages keep the single budget: - On AMD (RX 9070 XT), the extra loop-carried values in multi-region mesh loop headers crashed the driver's compiler in CreatePipelineState (xcl-dev#2865). - On NVIDIA (RTX 5070 Ti, retail title), a 900 s run with region budgets in every stage hung (0x887a0006) 580 s into the world; the same run with this scope ran to the end. One run each. A pixel shader loop that runs away got up to four budgets instead of one. Pixel, vertex, geometry and mesh programs emit exactly the HLSL of main again, so their cached translations stay valid. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
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.