Repository navigation
Conversation
A translated program caps its loops with one per-lane counter, 65,536 iterations shared by the whole program. A program whose own spin-wait gives up after 0x10000 tries uses all of it, and every loop after that spin then leaves at its first guard. A retail FSR pass (CS a8de35e47f36d28c) polls flags written by an earlier pass with a cap of exactly 0x10000 tries, inside an outer loop. When the spin ran out, its main loop never ran. A spilled SGPR then held a weight from an earlier load where the constant buffer's 0 should have been, and the flags it publishes read that weight with bit 0 set instead of 1. The pass waiting on those flags (5f29d7e51b2c6230) spun to its own cap every frame: about 260 ms of GPU time a frame on an RTX 5070 Ti. Measured with a local probe: the flags, cb[0xa8] = 0, and the weight dword the flags carry. The outermost ranges of loop_ranges are the program's loop regions. Control only moves forward between them: a jump back would make them one range. In a program with two or more regions, each region starts with two budgets. Two, so that a 0x10000 spin inside an outer loop fits, because the outer loop's head spends from the same count. All regions together have at most four budgets (xcl_btotal / VAR_BUDGET_TOTAL), so a program that really runs away stops within four budgets. Before, it stopped within one. This is done in all three emitters: the HLSL structured and pc forms (loop_guard), the direct DXIL plain form (kernel.rs) and the compact form. In the compact form, a loop head's class now includes its region. Programs with fewer than two regions keep their exact HLSL text and cached translations. Of the title's 2,682 compute programs, 1,916 have two or more regions, so those are translated and compiled again once. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows GPU check of the global cap in direct DXIL on The test requests three consecutive finite loops of 98,304 iterations each and records their counters and completed-region count. On the PR, both direct DXIL forms (plain and compact) returned Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop GPU (12 GB, driver 621.24), Rust 1.97.1 MSVC debug, DXC 1.8.2502.11. With PR plus local test: 5 passed, 0 failed, 0 ignored, no reported skips. The control ran only the new test. Native wave64, the full workspace suite, and a retail title were outside this check. OpenAI Codex assisted with the synthetic test and verification. The exact model identifier was unavailable in this session. |
|
Independent Ada Lovelace (RTX 4060 Laptop 8 GB) full-suite verification and diff review of Tested
Code Review Notes (
|
|
AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: the 3 new GPU tests pass on both cards, on both paths, and nothing else changes in the GPU suite. Head
The counts are the same on both paths. On both cards and both paths, the only result changes against I did not check which wave width each new test runs on the RX 9070 XT, so I don't claim native wave64 coverage for them. Not tested: a title, Intel. |
|
Verified native-wave64 / Wine coverage on RX 9070, including the direct global-cap case discussed above. Tested
Test-only changes All runtime translator files remain exact for each revision. In the test files, I added native-wave64 assertions and readback logging to the three new tests, plus local width/global-cap fixtures. Main receives the same new tests and Native width A separate Region results Each fixture below was repeated in three fresh processes per revision. The head returned these scalar registers in both HLSL forms and both direct forms:
Main stops at the first assertion in these tests: HLSL returns The HLSL six-region total-budget fixture returned The local direct fixture requests three finite loops of 98,304 iterations, recording their counters and completed-region count:
Both forms are run before the fixture asserts, so the main control covers both. The head's three counters sum to 262,144. Direct fixtures invoke Existing controls
Not tested Native Windows, split Wave32, AI use OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, prepared the test-only controls, ran and verified the paired GPU tests, and drafted this report. Publication authorized by the account owner. |
|
With #1284 (XCL_LOOP_BUDGET, AI-assisted (Claude Code, Claude Opus 5.5): read both diffs and wrote this. |
|
@upipibi agreed, thanks: with both merged the switch should scale the region budgets too, and deriving them from One thing to cover in it: #1284 changes the HLSL prelude only, so the direct DXIL translator keeps AI use: Claude Code (Claude Opus 5.5) wrote this reply. |
|
Ran the per-region loop-budget tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
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>
|
Pushed AI use: Claude Code (Claude Opus 5.5). |
A translated program caps its loops with one per-lane counter: 65,536 iterations, shared by the whole program. When a program's own spin-wait gives up after exactly 0x10000 tries, it spends all of them, and every later loop leaves at its first guard. Each outermost loop region now gets its own budget. The program stays capped at four budgets in all.
Part of #505.
Found on a retail FSR pass. CS
a8de35e47f36d28cpolls flags from an earlier pass, inside an outer loop, and gives up after 0x10000 tries.0should have been.1.5f29d7e51b2c6230, the one in my Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 GPU profile) spun to its own cap every frame. That took about 260 ms of GPU time a frame, two thirds of the console code's GPU time.These values were measured with a local probe that reads the buffers at bind time: the flags,
cb[0xa8] = 0, and the weight dword the flags carry.What is in it (two commits)
gpu/recomp/mod.rs:budget_regions(the outermost ranges ofloop_ranges),budget_regionandloop_guard.LOOP_BUDGETS_PER_REGION(2) budgets and countsxcl_btotaldown fromLOOP_BUDGETS_IN_ALL(4) budgets. Both forms are covered: structuredfor (;;)and thepcform'swhile.gpu/dxil/kernel.rs,compact.rs,lower.rs: the same in the direct translator's plain and compact forms. It adds two variables,VAR_BUDGET + 7and+ 24, which are free onmain. A loop head's compact class now includes its region.main. On AMD, multi-region mesh loop headers crashed the driver's compiler. On this RTX 5070 Ti, a 900 s run with region budgets in every stage hung (0x887a0006) 580 s into the world, and the same run with this scope ran to the end (one run each).recomp::tests::gpu_a_loop_after_a_spin_to_the_budget_still_runs: a spin of 0x10000, of 0xFFF0, and of 0x10000 inside an outer loop, each followed by a loop. Both HLSL forms.recomp::tests::gpu_endless_loops_in_many_regions_stop_after_four_budgets.dxil::compact_tests::gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms: direct plain and compact.Cost: the guard text changes in every program with two or more loop regions: 1,512 of the title's 2,682 compute programs (counted in an export with this change), and graphics programs too. My precompile after the change rebuilt 1,032 compute, 9,282 mesh, 3,133 pixel and 145 vertex programs. Those programs are translated and compiled once more, so the first run after this change rebuilds most pipelines; I needed a precompile plus two runs before the world was warm again. The worst case for a program that really runs away is four budgets instead of one.
(The commit message says 1,916; that was a brace count of
[loop]s. The exact count is 1,512.)Tested
cargo test --workspace -- --test-threads=4on this head (22c5f68): 1439 passed, 0 failed, 47 ignored, 37 test binaries (per_region_loop_budgets_are_compute_onlyadded).lower/lower_dxilcomparisons,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).0xc0000005ingamesave::tests::blob_enumeration_sees_one_submitted_update(XGameRuntime: blob_enumeration_sees_one_submitted_update fails on Windows NTFS (DirEntry::metadata cache) #2421). The next two runs passed.main0829441+ about 40 open PRs, D3D12.X: newer list layout #139 Reset goes through title_list::reset #929 among them), with the same change. Settings:XCL_DIRECT_DXIL=1, UMA shadow, the RT resolve programs refused, warm caches.The producer's flags read 1,013 ones and no other value.
5f29…fell out of the profile's top 15; it had been at about 260 ms a call.World frame rate, same settings throughout, measured over the same spans after the world's first frame:
0x887a0006), and so did the run without the change. With warm caches, all three hung after 565–602 presents in the world, so the hang follows how far the world gets, not the change, which only gets there sooner. An older run of my tree went past 1,072 world presents with no hang. Today, that tree without this change and without the probe hung after 222. So the hang comes from something else that changed on this machine since then (my guess is the much larger driver-blob cache after two precompiles, so pipelines that used to be skipped while building now run); I have not found it.Regression run
scripts/smoke.ps1 -Game <the retail title>, 60 s, onmainand on this head (the default length does not reach the FSR passes):Tested by others
main:[65536, 0, 0, 0]).main1435 / 0 / 47), and a review of the diff.gpu::tests on both paths: only the three new tests differ frommain, all pass.Not tested
mainin the retail title's world: the game runs above were on my integration tree. The smoke runs only reach the menus.XCL_PER_LANE=1: it has no loop budget at all yet (Recompiler: enforce LOOP_BUDGET at loop headers in per-lane lowering #2769).a8de…ran its HLSL translation in every run, even withXCL_DIRECT_DXIL=1; the direct plain and compact forms are covered by the GPU tests only.HANDOFF.md(around line 1660) describes one per-laneLOOP_GUARDbudget per shader, and its "4 M iterations" was already out of date. With this change, a program with two or more loop regions has a budget per region and four in all.AI use
🤖 Generated with Claude Code