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 (
|
|
Update for head 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. |
|
Updated RX 9070 / RADV / Wine verification for scoped head Tested
Through Wine, run the three original GPU tests, the new stage-scope test and an owned physical-width probe: Repeat with
The updated head/integration finish the following loop with Owned controls, three fresh processes per source: This selects the width probe and the existing finite three-loop total-cap fixture. Head/integration: 2 passed, 0 failed each time. Main: 1 passed, 1 failed each time. Three loops requesting 98,304 iterations give Across all 15 harnesses: 91 GPU dispatches, all with native wave64 metadata, and 10,688 captured SGPR/width words, independently checked including untouched registers, SCC and EXEC. All 15 physical-width probes returned 64 on every lane. Captures repeat byte-for-byte within each source; exact head and current-main integration captures match. 0 ignored, 0 skipped. Inherited Not tested The RDNA2 Windows AI use OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the head change, added local test-only captures, ran comparisons, independently verified source/executable provenance, stage scope and captured values, and drafted this update. 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. Update 21:41Z, at |
|
@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). |
|
Re-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. |
|
Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2793 at head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1339 filtered out × 3 (0.29s, 0.22s, 0.22s, 0 skipped; live on RTX 4060) |
cargo test --release -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs -- --nocapture (3 consecutive runs; executes both gpu_a_loop_after_a_spin_to_the_budget_still_runs and gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms) |
2 passed; 0 failed; 0 ignored; 1338 filtered out × 3 (0.38s, 0.32s, 0.32s, 0 skipped; live on RTX 4060) |
cargo test --release -p xcl --lib gpu_endless_loops_in_many_regions_stop_after_four_budgets -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1339 filtered out × 3 (0.24s, 0.21s, 0.21s, 0 skipped; live on RTX 4060) |
cargo test --release -p xcl --lib per_region_loop_budgets_are_compute_only -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1339 filtered out × 3 (0.01s × 3) |
cargo test --release -p xcl --lib gpu::dxil::compact_tests:: (3 consecutive runs) |
14 passed; 0 failed; 0 ignored; 1326 filtered out × 3 (1.06s, 1.07s, 1.06s, 0 skipped) |
cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4 (3 consecutive runs) |
185 passed; 0 failed; 3 ignored; 1152 filtered out × 3 (3.72s, 3.61s, 3.60s; 184 executed + 1 expected Wave32-only skip dispatch_chain_native_wave64_builds_whole: no wave64) |
cargo build --release -p xcl |
Clean build (1m 09s, exit 0, 0 new warnings) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact merge-base (b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):
xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB
PR #2793 (22c5f68cda9ecfa0d651357c79302eba83c8d21e):
xcl-smoke v1
commit: 22c5f68cda9ecfa0d651357c79302eba83c8d21e
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13994 MB
Runtime log observations (xcl.log)
9220log lines,0[ERROR]/ device-removal / panic lines.- Final draw/memory telemetry in log:
19654 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample13994 MB committed by the process; video memory 6114 MB local, 4650 MB non-local.
Limits of coverage
- All 3 new on-GPU loop-region budget tests (
gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms,gpu_a_loop_after_a_spin_to_the_budget_still_runs,gpu_endless_loops_in_many_regions_stop_after_four_budgets) plusper_region_loop_budgets_are_compute_onlyexecuted live with0skips (3/3each) on desktop RTX 4060, alongsidegpu::dxil::compact_tests::(14/14× 3) andgpu::dxil::(184executed +1expectedno wave64skip × 3). - Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on
title: 29640639confirms zero runtime regression rather than triggering a spin-to-budget retail compute shader (frame-count delta vs. cached merge-base reflects single-run startup variance, not this PR).
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
|
@jessenic sorry for the slow answer. I can't push it myself: xcl's rules don't let an unattended agent open PRs or push to someone else's branch, and #1284 is marked ready, so I'm not adding commits there. That leaves it with whoever lands second. If that's this PR, the scaling fits here. If #2793 lands first, it would have to come in with #1284 later, and I can't add it there, so it would wait for someone who can. On your direct-DXIL point: agreed. For AI-assisted (Claude Code, Claude Opus 5.5). |
|
@real-alponzo's #2947 (against That matters for this PR as it stands, so before it is merged:
I have not pushed anything for this yet. Not tested: AMD of any generation. AI use: Claude Code (Claude Fable 5.2) read #2947 and wrote this. |
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