Recompiler: each loop region of a program gets its own iteration budget #2783

Open
jessenic wants to merge 3 commits from upstream-pr/2793 into main
jessenic commented 2026-11-26 13:29:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-26T13:29:26Z.


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 a8de35e47f36d28c polls flags from an earlier pass, inside an outer loop, and gives up after 0x10000 tries.

  • When that 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.
  • So every flag the pass publishes read that weight with bit 0 set, instead of 1.
  • The pass waiting on those flags (5f29d7e51b2c6230, the one in my #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 (three commits)

  • gpu/recomp/mod.rs:
    • budget_regions (the outermost ranges of loop_ranges), budget_region and loop_guard.
    • In a program with two or more regions, a loop head's guard starts a new region with LOOP_BUDGETS_PER_REGION (2) budgets and counts xcl_btotal down from LOOP_BUDGETS_IN_ALL (4) budgets. Both forms are covered: structured for (;;) and the pc form's while.
    • Why two per region: a 0x10000 spin inside an outer loop must fit, because the outer loop's head spends from the same count.
    • Control only moves forward between regions; a jump back would make them one range.
    • Programs with fewer than two regions keep their exact HLSL text.
  • 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 + 7 and + 24, which are free on main. A loop head's compact class now includes its region.
  • Second commit, from @Saksukella's #2865: the region budgets are for compute and kernel programs only. Pixel, vertex, geometry and mesh programs keep the single budget and the HLSL of 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).
  • Third commit (5dcdc52), for #2947: compute programs translated for an AMD adapter (vendor 0x1002) keep the single budget, in the HLSL path and both direct forms; kernels, the graphics stages and other vendors are unchanged. XCL_REGION_BUDGETS=1 gives AMD the region budgets too, =0 takes them from every adapter. The device's creator notes the vendor (pso::note_adapter_vendor in real.rs, shaders.rs, runner.rs); such compute shaders have their own memory key and disk identity. The HLSL budgets now come from one helper (region_budget_limits), so a configurable loop budget (#1284) has one place to pass through.
    • Tests (no GPU needed): recomp::tests::a_compute_program_without_region_budgets_keeps_the_single_budget, recomp::tests::region_budgets_are_two_and_four_loop_budgets, pso::shader_cache_tests::region_budgets_are_off_on_amd_and_change_the_compute_identity.
  • Tests, each failing without the change:
    • 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

  • RTX 5070 Ti 16 GB (driver 610.88), 32 GB RAM, Windows 11 26300, Rust stable msvc, debug (tests) and release (the game). Series S profile.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head (5dcdc52, rebased onto main 2c717a04): 1473 passed, 0 failed, 47 ignored, 25 SKIPPED lines (before the rebase, 1f106b3: 1442 / 0 / 47).
    • SKIPPED (15): 14 for "no wave64" (the per-lane lower / lower_dxil comparisons, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • One earlier run of the lib tests stopped with 0xc0000005 in gamesave::tests::blob_enumeration_sees_one_submitted_update (#2421). The next two runs passed.
  • The retail title, in a local integration tree (main 0829441 + about 40 open PRs, #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:
      run +60..+160 s +60..+275 s
      with the change 1.69 1.97
      with the change 1.79 1.99
      without it 1.43 1.55
  • Those runs ended in a TDR (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, on main and on this head, both with XCL_PREPARE=0 in the environment: since the shader preparation came to main, a run with the default prepares the title's 26,503 shaders first and shows no frame in 60 s here. (The default length does not reach the FSR passes.)
xcl-smoke v1
commit: 2c717a043c8488938179fca81da4bb9e7913a358
gpu: NVIDIA GeForce RTX 5070 Ti
title: 7cc04381
seconds: 60
exit: 0x0
frames shown: 1258 (PresentX 1258)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20825 MB
xcl-smoke v1
commit: 5dcdc521ca01842f2f75b6da52c92ae538930474
gpu: NVIDIA GeForce RTX 5070 Ti
title: 7cc04381
seconds: 60
exit: 0x0
frames shown: 1272 (PresentX 1272)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18886 MB

Tested by others

  • @ettehn: RTX 5070 Ti Laptop, a test of three 98,304-iteration loops in direct DXIL: both forms stop the third at the 262,144 total (main: [65536, 0, 0, 0]).
  • @retrope13: RTX 4060 Laptop, whole suite 1438 / 0 / 47 (main 1435 / 0 / 47), and a review of the diff.
  • @DarkPanda69: RX 9070 XT and RTX 3060, gpu:: tests on both paths: only the three new tests differ from main, all pass.
  • @SzczepanGrela: RX 9070 with native wave64 (RADV under Wine), including the direct total cap.

Not tested

  • The third commit on an AMD adapter: the gate's logic is unit-tested, but nobody has run it on AMD hardware yet, and with it AMD loses this PR's fix for compute programs (the single budget again) until the compiler crash of #2947 is understood.
  • AMD and native wave64 in a title (only the GPU tests above).
  • The change on plain main in the retail title's world: the game runs above were on my integration tree. The smoke runs only reach the menus.
  • Geometry-phase programs (the region guard in an ES + GS body); vertex, pixel and mesh programs in the game beyond what the runs above reach.
  • XCL_PER_LANE=1: it has no loop budget at all yet (#2769).
  • The title's a8de… ran its HLSL translation in every run, even with XCL_DIRECT_DXIL=1; the direct plain and compact forms are covered by the GPU tests only.

HANDOFF.md (around line 1660) describes one per-lane LOOP_GUARD budget 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

  • Claude Code (Claude Opus 5.5). It found the cause with a local probe and the program's disassembly, wrote the change and the tests, ran the tests and the game runs, and wrote this description. A review agent (same model) checked the change, and its findings led to the second budget per region and the nested-spin test.
  • Third commit and this update of the description: Claude Code (Claude Fable 5.2) wrote the gate and its tests, ran the suite and the smoke run, and wrote the text.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5510920054 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-26T13:29:26Z. --- 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 `a8de35e47f36d28c` polls flags from an earlier pass, inside an outer loop, and gives up after 0x10000 tries. - When that 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. - So every flag the pass publishes read that weight with bit 0 set, instead of `1`. - The pass waiting on those flags (`5f29d7e51b2c6230`, the one in my #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** (three commits) - `gpu/recomp/mod.rs`: - `budget_regions` (the outermost ranges of `loop_ranges`), `budget_region` and `loop_guard`. - In a program with two or more regions, a loop head's guard starts a new region with `LOOP_BUDGETS_PER_REGION` (2) budgets and counts `xcl_btotal` down from `LOOP_BUDGETS_IN_ALL` (4) budgets. Both forms are covered: structured `for (;;)` and the `pc` form's `while`. - Why two per region: a 0x10000 spin inside an outer loop must fit, because the outer loop's head spends from the same count. - Control only moves forward between regions; a jump back would make them one range. - Programs with fewer than two regions keep their exact HLSL text. - `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 + 7` and `+ 24`, which are free on `main`. A loop head's compact class now includes its region. - Second commit, from @Saksukella's #2865: the region budgets are for compute and kernel programs only. Pixel, vertex, geometry and mesh programs keep the single budget and the HLSL of `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). - Third commit (`5dcdc52`), for #2947: compute programs translated for an AMD adapter (vendor `0x1002`) keep the single budget, in the HLSL path and both direct forms; kernels, the graphics stages and other vendors are unchanged. `XCL_REGION_BUDGETS=1` gives AMD the region budgets too, `=0` takes them from every adapter. The device's creator notes the vendor (`pso::note_adapter_vendor` in `real.rs`, `shaders.rs`, `runner.rs`); such compute shaders have their own memory key and disk identity. The HLSL budgets now come from one helper (`region_budget_limits`), so a configurable loop budget (#1284) has one place to pass through. - Tests (no GPU needed): `recomp::tests::a_compute_program_without_region_budgets_keeps_the_single_budget`, `recomp::tests::region_budgets_are_two_and_four_loop_budgets`, `pso::shader_cache_tests::region_budgets_are_off_on_amd_and_change_the_compute_identity`. - Tests, each failing without the change: - `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** - RTX 5070 Ti 16 GB (driver 610.88), 32 GB RAM, Windows 11 26300, Rust stable msvc, debug (tests) and release (the game). Series S profile. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on this head (`5dcdc52`, rebased onto `main` `2c717a04`): 1473 passed, 0 failed, 47 ignored, 25 SKIPPED lines (before the rebase, `1f106b3`: 1442 / 0 / 47). - SKIPPED (15): 14 for "no wave64" (the per-lane `lower` / `lower_dxil` comparisons, `dispatch_chain_native_wave64_builds_whole`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`), and `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - One earlier run of the lib tests stopped with `0xc0000005` in `gamesave::tests::blob_enumeration_sees_one_submitted_update` (#2421). The next two runs passed. - The retail title, in a local integration tree (`main` `0829441` + about 40 open PRs, #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: | run | +60..+160 s | +60..+275 s | |---|---|---| | with the change | 1.69 | 1.97 | | with the change | 1.79 | 1.99 | | without it | 1.43 | 1.55 | - Those runs ended in a TDR (`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, on `main` and on this head, both with `XCL_PREPARE=0` in the environment: since the shader preparation came to `main`, a run with the default prepares the title's 26,503 shaders first and shows no frame in 60 s here. (The default length does not reach the FSR passes.) ``` xcl-smoke v1 commit: 2c717a043c8488938179fca81da4bb9e7913a358 gpu: NVIDIA GeForce RTX 5070 Ti title: 7cc04381 seconds: 60 exit: 0x0 frames shown: 1258 (PresentX 1258) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20825 MB ``` ``` xcl-smoke v1 commit: 5dcdc521ca01842f2f75b6da52c92ae538930474 gpu: NVIDIA GeForce RTX 5070 Ti title: 7cc04381 seconds: 60 exit: 0x0 frames shown: 1272 (PresentX 1272) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18886 MB ``` **Tested by others** - @ettehn: RTX 5070 Ti Laptop, a test of three 98,304-iteration loops in direct DXIL: both forms stop the third at the 262,144 total (`main`: `[65536, 0, 0, 0]`). - @retrope13: RTX 4060 Laptop, whole suite 1438 / 0 / 47 (`main` 1435 / 0 / 47), and a review of the diff. - @DarkPanda69: RX 9070 XT and RTX 3060, `gpu::` tests on both paths: only the three new tests differ from `main`, all pass. - @SzczepanGrela: RX 9070 with native wave64 (RADV under Wine), including the direct total cap. **Not tested** - The third commit on an AMD adapter: the gate's logic is unit-tested, but nobody has run it on AMD hardware yet, and with it AMD loses this PR's fix for compute programs (the single budget again) until the compiler crash of #2947 is understood. - AMD and native wave64 in a title (only the GPU tests above). - The change on plain `main` in the retail title's world: the game runs above were on my integration tree. The smoke runs only reach the menus. - Geometry-phase programs (the region guard in an ES + GS body); vertex, pixel and mesh programs in the game beyond what the runs above reach. - `XCL_PER_LANE=1`: it has no loop budget at all yet (#2769). - The title's `a8de…` ran its HLSL translation in every run, even with `XCL_DIRECT_DXIL=1`; the direct plain and compact forms are covered by the GPU tests only. `HANDOFF.md` (around line 1660) describes one per-lane `LOOP_GUARD` budget 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** - Claude Code (Claude Opus 5.5). It found the cause with a local probe and the program's disassembly, wrote the change and the tests, ran the tests and the game runs, and wrote this description. A review agent (same model) checked the change, and its findings led to the second budget per region and the nested-spin test. - Third commit and this update of the description: Claude Code (Claude Fable 5.2) wrote the gate and its tests, ran the suite and the smoke run, and wrote the text. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DarkPanda69 commented 2026-11-26 13:51:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T13:51:25Z.


Update for the rebased head 5dcdc52 (base main 2c717a0): same result. cargo test -p xcl --lib -- gpu:: shaders:: --test-threads=4 --nocapture: RX 9070 XT 728 → 735 passed, 2 failed (the #2115 fuzz seeds, also on the base), 7 SKIPPED; RTX 3060 730 → 737 passed, 0 failed, 25 SKIPPED. On both cards the only changes are the same seven new tests, all ok. The pipeline_cap_tests log line names the right card on both (adapter=AMD Radeon RX 9070 XT / adapter=NVIDIA GeForce RTX 3060).

Update for head 1f106b3 (the AMD gate): the diff no longer applies on main, so I tested the PR head against its merge-base b49be18. cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture, card chosen with XCL_ADAPTER:

  • RX 9070 XT: 708 → 715 passed, 2 failed (the #2115 fuzz seeds, same on the base), 6 SKIPPED. Same counts with XCL_REGION_BUDGETS=1 and with XCL_DIRECT_DXIL=1.
  • RTX 3060: 710 → 717 passed, 0 failed, 24 SKIPPED. Same with both variables.
  • On both cards, the only changes against the base are seven new tests, all ok: the three GPU tests from before, per_region_loop_budgets_are_compute_only, region_budgets_are_off_on_amd_and_change_the_compute_identity, a_compute_program_without_region_budgets_keeps_the_single_budget and region_budgets_are_two_and_four_loop_budgets.

A limit of this run: the GPU tests translate in Mode::Kernel, which the gate leaves alone, so on the RX 9070 XT they still run with region budgets and don't exercise the gate itself (that's why XCL_REGION_BUDGETS=1 changes nothing). The gate is covered by its unit tests only. This is also RDNA4; I can't reproduce #2947's RDNA2 compiler crash here.

Update for head 22c5f68: same result. Applied on main 8b957be, gpu:: on both cards, with XCL_DIRECT_DXIL=1 and with it unset: RX 9070 XT 708 → 712 passed, 2 failed both times (the #2115 fuzz seeds, same on main), 6 SKIPPED; RTX 3060 710 → 714 passed, 0 failed, 24 SKIPPED. The only changes are four ok results: the three tests from before plus the new per_region_loop_budgets_are_compute_only.


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 3cde150 applied on main b49be18, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR, once with XCL_DIRECT_DXIL=1 and once with it unset, card chosen with XCL_ADAPTER:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010) 708 passed, 2 failed, 6 SKIPPED 711 passed, 2 failed, 6 SKIPPED
RTX 3060 (32.0.16.1088) 710 passed, 0 failed, 24 SKIPPED 713 passed, 0 failed, 24 SKIPPED

The counts are the same on both paths. On both cards and both paths, the only result changes against main are the new 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 and gpu_endless_loops_in_many_regions_stop_after_four_budgets, all ok, with no new skips. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same on main.

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.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7193932453 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7193932453). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-26T13:51:25Z. --- **Update for the rebased head `5dcdc52`** (base `main` `2c717a0`): same result. `cargo test -p xcl --lib -- gpu:: shaders:: --test-threads=4 --nocapture`: RX 9070 XT 728 → 735 passed, 2 failed (the #2115 fuzz seeds, also on the base), 7 SKIPPED; RTX 3060 730 → 737 passed, 0 failed, 25 SKIPPED. On both cards the only changes are the same seven new tests, all ok. The `pipeline_cap_tests` log line names the right card on both (`adapter=AMD Radeon RX 9070 XT` / `adapter=NVIDIA GeForce RTX 3060`). **Update for head `1f106b3`** (the AMD gate): the diff no longer applies on `main`, so I tested the PR head against its merge-base `b49be18`. `cargo test -p xcl --lib -- gpu:: --test-threads=4 --nocapture`, card chosen with `XCL_ADAPTER`: - RX 9070 XT: 708 → 715 passed, 2 failed (the #2115 fuzz seeds, same on the base), 6 SKIPPED. Same counts with `XCL_REGION_BUDGETS=1` and with `XCL_DIRECT_DXIL=1`. - RTX 3060: 710 → 717 passed, 0 failed, 24 SKIPPED. Same with both variables. - On both cards, the only changes against the base are seven new tests, all ok: the three GPU tests from before, `per_region_loop_budgets_are_compute_only`, `region_budgets_are_off_on_amd_and_change_the_compute_identity`, `a_compute_program_without_region_budgets_keeps_the_single_budget` and `region_budgets_are_two_and_four_loop_budgets`. A limit of this run: the GPU tests translate in `Mode::Kernel`, which the gate leaves alone, so on the RX 9070 XT they still run with region budgets and don't exercise the gate itself (that's why `XCL_REGION_BUDGETS=1` changes nothing). The gate is covered by its unit tests only. This is also RDNA4; I can't reproduce #2947's RDNA2 compiler crash here. **Update for head `22c5f68`:** same result. Applied on `main` `8b957be`, `gpu::` on both cards, with `XCL_DIRECT_DXIL=1` and with it unset: RX 9070 XT 708 → 712 passed, 2 failed both times (the #2115 fuzz seeds, same on `main`), 6 SKIPPED; RTX 3060 710 → 714 passed, 0 failed, 24 SKIPPED. The only changes are four ok results: the three tests from before plus the new `per_region_loop_budgets_are_compute_only`. --- 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 `3cde150` applied on `main` `b49be18`, debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4` on `main` and with the PR, once with `XCL_DIRECT_DXIL=1` and once with it unset, card chosen with `XCL_ADAPTER`: | | `main` | this PR | |---|---|---| | RX 9070 XT (RDNA4, 32.0.32029.2010) | 708 passed, 2 failed, 6 SKIPPED | 711 passed, 2 failed, 6 SKIPPED | | RTX 3060 (32.0.16.1088) | 710 passed, 0 failed, 24 SKIPPED | 713 passed, 0 failed, 24 SKIPPED | The counts are the same on both paths. On both cards and both paths, the only result changes against `main` are the new `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` and `gpu_endless_loops_in_many_regions_stop_after_four_budgets`, all ok, with no new skips. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same on `main`. 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. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
ettehn commented 2026-11-26 14:03:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-26T13:35:38Z.


Independent Windows GPU check of the global cap in direct DXIL on 3cde150b3c7a869e95b8eefcb5a2379859ad77d0, with b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 as the control. The only local change on each checkout was one synthetic test.

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 [98304, 98304, 65536, 2], stopping the third loop at the global 262,144-iteration limit. The main control failed at the plain-form assertion with [65536, 0, 0, 0]. The four existing loop-budget tests also passed on the PR checkout.

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 XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64, I ran:

cargo test --locked --offline -p xcl --lib -j 2 -- gpu_direct_dxil_regions_share_the_total_loop_budget gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets gpu_compact_form_spends_the_loop_budget_as_the_plain_form --test-threads=1 --nocapture

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.

<!-- greyfinch-sync:ivall/xcl:comment:7193566312 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7193566312). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-26T13:35:38Z. --- Independent Windows GPU check of the global cap in direct DXIL on `3cde150b3c7a869e95b8eefcb5a2379859ad77d0`, with `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` as the control. The only local change on each checkout was one synthetic test. 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 `[98304, 98304, 65536, 2]`, stopping the third loop at the global 262,144-iteration limit. The main control failed at the plain-form assertion with `[65536, 0, 0, 0]`. The four existing loop-budget tests also passed on the PR checkout. 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 `XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64`, I ran: ```text cargo test --locked --offline -p xcl --lib -j 2 -- gpu_direct_dxil_regions_share_the_total_loop_budget gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets gpu_compact_form_spends_the_loop_budget_as_the_plain_form --test-threads=1 --nocapture ``` 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.
retrope13 commented 2026-11-26 14:03:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by retrope13 on 2026-11-26T13:45:35Z.


Independent Ada Lovelace (RTX 4060 Laptop 8 GB) full-suite verification and diff review of #2793 (3cde150b) against main (b49be183): full debug suite + release recompiler/DXIL tests green, 0 failures. No title was run.

Tested

  • Hardware / Env: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver 32.0.16.2140, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build 26300.9818), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0 DXC 1.9.2602.17, XCL_ADAPTER=NVIDIA.
  • New targeted tests (debug):
    • cargo test --locked -p xcl --lib -- gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms --test-threads=4 --nocapture: 3 passed, 0 failed, 0 ignored (0.49 s; all three executed on GPU, none skipped).
  • Full workspace (debug): cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4:
    • Clean main (b49be183): 1435 passed, 0 failed, 47 ignored
    • PR #2793 (3cde150b): 1438 passed, 0 failed, 47 ignored (+3 new tests, 0 failures)
  • Targeted recompiler + DXIL compact suite (--release):
    • cargo test --release --locked -p xcl --lib -- gpu::recomp::tests:: gpu::dxil::compact_tests:: --test-threads=4: 183 passed, 0 failed, 17 ignored (12.44 s).

Code Review Notes (b49be183..3cde150b)

  • Direct DXIL variable slots & initialization (lower.rs, kernel.rs, compact.rs): Verified VAR_BUDGET_OWNER (VAR_BUDGET + 7) and VAR_BUDGET_TOTAL (VAR_BUDGET + 24) do not collide with any existing VAR_* constant (+0..+5, VAR_IMG_WRITE +8..+23, VAR_TMP = 1024), and both are initialized in Init (0 and LOOP_BUDGET * 4).
  • Underflow & compact class key safety: In both kernel.rs and compact.rs, spent (total == 0) forces left = 0 before cond_br(none, end, cont), so neither left - 1 nor total - 1 can underflow in cont. In compact.rs:84, budget_region is 1-based, so head as u64 + region (0 non-head, 1 unregioned head, 2.. per region) cleanly separates heads across regions without key collisions.
  • HLSL single-region preservation & ES+GS phase_split scoping (recomp/mod.rs, emit.rs): Programs with < 2 regions produce empty regions and keep identical LOOP_GUARD HLSL text. For multi-region phase_split geometry shaders, emit::finish wraps each phase's body in its own { ... } scope, so local xcl_bown / xcl_btotal declarations do not collide across ES and GS phases (and xcl_bown = 0u resets static xcl_budget on the first region entered). Also confirmed every loop in nested_loop_ranges maps into an enclosing outermost range of budget_regions(&loops).

Not Tested

  • Live retail title runs, AMD / Intel GPUs, native wave64 hardware, Linux, and the 47 #[ignore] / SKIPPED tests.

AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, reviewed the diff, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7193797401 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7193797401). Originally posted by [retrope13](https://github.com/retrope13) on 2026-11-26T13:45:35Z. --- **Independent Ada Lovelace (RTX 4060 Laptop 8 GB) full-suite verification and diff review of `#2793` (`3cde150b`) against `main` (`b49be183`): full debug suite + release recompiler/DXIL tests green, 0 failures.** No title was run. ### Tested - **Hardware / Env:** NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver `32.0.16.2140`, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build `26300.9818`), `rustc 1.100.0` (`stable-x86_64-pc-windows-msvc`), Windows SDK `10.0.26100.0` DXC `1.9.2602.17`, `XCL_ADAPTER=NVIDIA`. - **New targeted tests (debug):** - `cargo test --locked -p xcl --lib -- gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets gpu_a_loop_after_a_spin_to_the_budget_still_runs_in_both_forms --test-threads=4 --nocapture`: **3 passed, 0 failed, 0 ignored** (`0.49 s`; all three executed on GPU, none skipped). - **Full workspace (debug):** `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: - Clean `main` (`b49be183`): **1435 passed, 0 failed, 47 ignored** - PR `#2793` (`3cde150b`): **1438 passed, 0 failed, 47 ignored** (+3 new tests, 0 failures) - **Targeted recompiler + DXIL compact suite (`--release`):** - `cargo test --release --locked -p xcl --lib -- gpu::recomp::tests:: gpu::dxil::compact_tests:: --test-threads=4`: **183 passed, 0 failed, 17 ignored** (`12.44 s`). ### Code Review Notes (`b49be183..3cde150b`) - **Direct DXIL variable slots & initialization (`lower.rs`, `kernel.rs`, `compact.rs`):** Verified `VAR_BUDGET_OWNER` (`VAR_BUDGET + 7`) and `VAR_BUDGET_TOTAL` (`VAR_BUDGET + 24`) do not collide with any existing `VAR_*` constant (`+0..+5`, `VAR_IMG_WRITE` `+8..+23`, `VAR_TMP = 1024`), and both are initialized in `Init` (`0` and `LOOP_BUDGET * 4`). - **Underflow & compact class key safety:** In both `kernel.rs` and `compact.rs`, `spent` (`total == 0`) forces `left = 0` before `cond_br(none, end, cont)`, so neither `left - 1` nor `total - 1` can underflow in `cont`. In `compact.rs:84`, `budget_region` is 1-based, so `head as u64 + region` (`0` non-head, `1` unregioned head, `2..` per region) cleanly separates heads across regions without key collisions. - **HLSL single-region preservation & ES+GS `phase_split` scoping (`recomp/mod.rs`, `emit.rs`):** Programs with `< 2` regions produce empty `regions` and keep identical `LOOP_GUARD` HLSL text. For multi-region `phase_split` geometry shaders, `emit::finish` wraps each phase's `body` in its own `{ ... }` scope, so local `xcl_bown` / `xcl_btotal` declarations do not collide across ES and GS phases (and `xcl_bown = 0u` resets `static xcl_budget` on the first region entered). Also confirmed every loop in `nested_loop_ranges` maps into an enclosing outermost range of `budget_regions(&loops)`. ### Not Tested - Live retail title runs, AMD / Intel GPUs, native wave64 hardware, Linux, and the 47 `#[ignore]` / `SKIPPED` tests. *AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, reviewed the diff, and drafted this report.*
SzczepanGrela commented 2026-11-26 14:05:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-26T14:05:04Z.


Updated RX 9070 / RADV / Wine verification for scoped head 22c5f68cda9ecfa0d651357c79302eba83c8d21e. The tested kernel loop budgets remain correct on this lane, both at exact head and after applying the six-file PR delta to current main 8b957bec6f82495aec940944c6bf47faa02db590.

Tested

  • RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1-arch3.5, Ryzen 7 7700, CachyOS 7.3.0-5-cachyos. Windows GNU release executables, Rust 1.97.1, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17.
  • Three separate source copies: current main, exact head, current main plus the PR. All six changed files on main match the PR's original base b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, so the integration applies without adaptation. Production files remain exact for each source; local observers save readbacks, code and containers before unchanged original assertions. Main carries identical test additions; the absent total-budget constant is replaced by literal 4 only in the test expectation.
  • Build each copy: cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.

Through Wine, run the three original GPU tests, the new stage-scope test and an owned physical-width probe:

<unit.exe> gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets per_region_loop_budgets_are_compute_only gpu_native_wave64_width_probe_for_loop_tests --nocapture --test-threads=1

Repeat with --test-threads=4:

Source Threads 1 Threads 4
Current main + test additions 1 passed, 4 failed 1 passed, 4 failed
Exact updated head 5 passed, 0 failed 5 passed, 0 failed
Current-main integration 5 passed, 0 failed 5 passed, 0 failed

The updated head/integration finish the following loop with [spin,n,7] for (65536,3), (65520,1000) and nested (65536,3), in both HLSL forms and direct plain/compact. Main exhausts its shared budget and fails the original assertions. HLSL's six-region control gives [262144,6] at head/integration, versus [65536,6] on main. Saved stage-scope HLSL has region counters for Kernel/Compute and single-budget text for Pixel/Mesh on the scoped head.

Owned controls, three fresh processes per source:

<unit.exe> gpu_native_wave64_ --nocapture --test-threads=1

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 [98304,98304,65536,2] in direct plain/compact at head/integration, versus [65536,0,0,0] on main. The first two regions complete; the third reaches the four-budget total cap.

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 XCL_* cleared; XCL_NETWORK=0, RX 9070 selected, XCL_REQUIRE_GPU=wave64, XCL_DXC_THREADS=1; private enabled caches per process.

Not tested

The RDNA2 Windows amdxc64.dll compiler crashes discussed in #2947, native Windows, retail shaders/title runs, the reported FSR flag behavior, hangs or FPS, full suite, graphics-stage GPU execution, or GPU execution using the guest Compute ABI. The dispatches above are owned synthetic kernel fixtures on RADV/vkd3d-proton; they do not resolve the Windows compiler report.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7194253689 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7194253689). Originally posted by [SzczepanGrela](https://github.com/SzczepanGrela) on 2026-11-26T14:05:04Z. --- Updated RX 9070 / RADV / Wine verification for scoped head `22c5f68cda9ecfa0d651357c79302eba83c8d21e`. The tested kernel loop budgets remain correct on this lane, both at exact head and after applying the six-file PR delta to current `main` `8b957bec6f82495aec940944c6bf47faa02db590`. **Tested** - RX 9070 16 GB, RADV GFX1201 / Mesa `26.3.1-arch3.5`, Ryzen 7 7700, CachyOS `7.3.0-5-cachyos`. Windows GNU release executables, Rust `1.97.1`, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton `8293130ebe370b1+` (local asserts-disabled build), DXC/DXIL `1.9.2602.17`. - Three separate source copies: current main, exact head, current main plus the PR. All six changed files on main match the PR's original base `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`, so the integration applies without adaptation. Production files remain exact for each source; local observers save readbacks, code and containers before unchanged original assertions. Main carries identical test additions; the absent total-budget constant is replaced by literal 4 only in the test expectation. - Build each copy: `cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics`. Through Wine, run the three original GPU tests, the new stage-scope test and an owned physical-width probe: ```text <unit.exe> gpu_a_loop_after_a_spin_to_the_budget_still_runs gpu_endless_loops_in_many_regions_stop_after_four_budgets per_region_loop_budgets_are_compute_only gpu_native_wave64_width_probe_for_loop_tests --nocapture --test-threads=1 ``` Repeat with `--test-threads=4`: | Source | Threads 1 | Threads 4 | |---|---|---| | Current main + test additions | 1 passed, 4 failed | 1 passed, 4 failed | | Exact updated head | 5 passed, 0 failed | 5 passed, 0 failed | | Current-main integration | 5 passed, 0 failed | 5 passed, 0 failed | The updated head/integration finish the following loop with `[spin,n,7]` for `(65536,3)`, `(65520,1000)` and nested `(65536,3)`, in both HLSL forms and direct plain/compact. Main exhausts its shared budget and fails the original assertions. HLSL's six-region control gives `[262144,6]` at head/integration, versus `[65536,6]` on main. Saved stage-scope HLSL has region counters for Kernel/Compute and single-budget text for Pixel/Mesh on the scoped head. Owned controls, three fresh processes per source: ```text <unit.exe> gpu_native_wave64_ --nocapture --test-threads=1 ``` 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 `[98304,98304,65536,2]` in direct plain/compact at head/integration, versus `[65536,0,0,0]` on main. The first two regions complete; the third reaches the four-budget total cap. 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 `XCL_*` cleared; `XCL_NETWORK=0`, RX 9070 selected, `XCL_REQUIRE_GPU=wave64`, `XCL_DXC_THREADS=1`; private enabled caches per process. **Not tested** The RDNA2 Windows `amdxc64.dll` compiler crashes discussed in #2947, native Windows, retail shaders/title runs, the reported FSR flag behavior, hangs or FPS, full suite, graphics-stage GPU execution, or GPU execution using the guest Compute ABI. The dispatches above are owned synthetic kernel fixtures on RADV/vkd3d-proton; they do not resolve the Windows compiler report. **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.
upipibi commented 2026-11-26 16:26:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:26:35Z.


With #1284 (XCL_LOOP_BUDGET, loop_budget() in recomp/mod.rs) also open: this PR's region budgets are fixed at LOOP_BUDGETS_PER_REGION << 16 (loop_guard) and LOOP_BUDGETS_IN_ALL << 16 (xcl_btotal), so with both merged XCL_LOOP_BUDGET=4096 caps a one-region program at 4096 iterations but leaves a multi-region one at 131 072 per region. Proposal: whichever lands second derives both from loop_budget() (2 and 4 budgets of it, saturating); unset, the HLSL stays byte for byte. I have that as a small change plus a test on a local branch (main + both PRs) and can push it onto whichever PR lands second.

AI-assisted (Claude Code, Claude Opus 5.5): read both diffs and wrote this.

Update 21:41Z, at 22c5f68: #1284 (f3eb053) and this head merge cleanly on main 8b957be; on the merged tree cargo test -p xcl --lib recomp -- --test-threads=4 gives 406 passed, 0 failed, 20 ignored, and dxil::compact_tests 14 passed, 0 failed (RTX 3070). One narrow interaction: with XCL_LOOP_BUDGET=N set, compute and kernel programs with two or more loop regions ignore N, because loop_guard (recomp/mod.rs:682-686) resets the budget to 2 << 16 at each region's first guard and the total starts at 4 << 16 (mod.rs:1683). Unset (the default), nothing changes; graphics, mesh and direct DXIL are unaffected. Whichever lands second could read N in those two places.

<!-- greyfinch-sync:ivall/xcl:comment:7197651730 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7197651730). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:26:35Z. --- With #1284 (XCL_LOOP_BUDGET, `loop_budget()` in recomp/mod.rs) also open: this PR's region budgets are fixed at `LOOP_BUDGETS_PER_REGION << 16` (`loop_guard`) and `LOOP_BUDGETS_IN_ALL << 16` (`xcl_btotal`), so with both merged `XCL_LOOP_BUDGET=4096` caps a one-region program at 4096 iterations but leaves a multi-region one at 131 072 per region. Proposal: whichever lands second derives both from `loop_budget()` (2 and 4 budgets of it, saturating); unset, the HLSL stays byte for byte. I have that as a small change plus a test on a local branch (main + both PRs) and can push it onto whichever PR lands second. AI-assisted (Claude Code, Claude Opus 5.5): read both diffs and wrote this. **Update 21:41Z, at `22c5f68`:** #1284 (`f3eb053`) and this head merge cleanly on `main` `8b957be`; on the merged tree `cargo test -p xcl --lib recomp -- --test-threads=4` gives 406 passed, 0 failed, 20 ignored, and `dxil::compact_tests` 14 passed, 0 failed (RTX 3070). One narrow interaction: with `XCL_LOOP_BUDGET=N` set, compute and kernel programs with two or more loop regions ignore N, because `loop_guard` (`recomp/mod.rs:682-686`) resets the budget to `2 << 16` at each region's first guard and the total starts at `4 << 16` (`mod.rs:1683`). Unset (the default), nothing changes; graphics, mesh and direct DXIL are unaffected. Whichever lands second could read N in those two places.
jessenic commented 2026-11-26 16:27:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-26T16:27:58Z.


@upipibi agreed, thanks: with both merged the switch should scale the region budgets too, and deriving them from loop_budget() (2 and 4 of it, saturating, HLSL unchanged when unset) is the right shape. Please push it onto whichever lands second.

One thing to cover in it: #1284 changes the HLSL prelude only, so the direct DXIL translator keeps dxil::lower::LOOP_BUDGET (1 << 16) for its single budget and, with this PR, for VAR_BUDGET_TOTAL and the per-region refill in kernel.rs / compact.rs. If XCL_LOOP_BUDGET is meant to hold for XCL_DIRECT_DXIL=1 as well, those would read loop_budget() too, and the switch would join the direct translator's source identity so cached kernels are not reused across values.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7197681376 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7197681376). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-26T16:27:58Z. --- @upipibi agreed, thanks: with both merged the switch should scale the region budgets too, and deriving them from `loop_budget()` (2 and 4 of it, saturating, HLSL unchanged when unset) is the right shape. Please push it onto whichever lands second. One thing to cover in it: #1284 changes the HLSL prelude only, so the direct DXIL translator keeps `dxil::lower::LOOP_BUDGET` (`1 << 16`) for its single budget and, with this PR, for `VAR_BUDGET_TOTAL` and the per-region refill in `kernel.rs` / `compact.rs`. If `XCL_LOOP_BUDGET` is meant to hold for `XCL_DIRECT_DXIL=1` as well, those would read `loop_budget()` too, and the switch would join the direct translator's source identity so cached kernels are not reused across values. AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Aniseto commented 2026-11-26 17:16:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T17:16:43Z.


Ran the per-region loop-budget tests at 3cde150b on an NVIDIA Blackwell desktop part:

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs -- --test-threads=1: 2 passed, 0 failed, 0 ignored (1337 filtered out, exit 0)
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_endless_loops_in_many_regions_stop_after_four_budgets -- --test-threads=1: 1 passed, 0 failed, 0 ignored (1338 filtered out, exit 0)
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu::dxil::compact_tests -- --test-threads=1: 14 passed, 0 failed, 0 ignored (1325 filtered out, exit 0)

What this adds
ettehn checked this head on an RTX 5070 Ti Laptop (12 GB, driver 621.24, rustc 1.97.1, DXC 1.8.2502.11), including one locally added test. This adds the desktop 16 GB part on driver 32.0.16.2124 with rustc 1.100.0 and DXC 1.9.2609.5. The first filter matched two tests (the plain and both-forms variants), the second one the four-region cap, and the third the 14 compact tests; all ran on the real adapter. I added no local test, so the exact three-loop counter measurement from that comment was not repeated here.

Not tested
The locally instrumented 98,304-iteration counter probe, a retail title, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7198760474 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7198760474). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-26T17:16:43Z. --- Ran the per-region loop-budget tests at `3cde150b` on an NVIDIA Blackwell desktop part: **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders, 16 GB), driver 32.0.16.2124 - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs -- --test-threads=1`: 2 passed, 0 failed, 0 ignored (1337 filtered out, exit 0) - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_endless_loops_in_many_regions_stop_after_four_budgets -- --test-threads=1`: 1 passed, 0 failed, 0 ignored (1338 filtered out, exit 0) - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu::dxil::compact_tests -- --test-threads=1`: 14 passed, 0 failed, 0 ignored (1325 filtered out, exit 0) **What this adds** ettehn checked this head on an RTX 5070 Ti Laptop (12 GB, driver 621.24, rustc 1.97.1, DXC 1.8.2502.11), including one locally added test. This adds the desktop 16 GB part on driver 32.0.16.2124 with rustc 1.100.0 and DXC 1.9.2609.5. The first filter matched two tests (the plain and both-forms variants), the second one the four-region cap, and the third the 14 compact tests; all ran on the real adapter. I added no local test, so the exact three-loop counter measurement from that comment was not repeated here. **Not tested** The locally instrumented 98,304-iteration counter probe, a retail title, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data. 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.
jessenic commented 2026-11-26 20:33:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-26T20:33:40Z.


Pushed 22c5f68 on top: @Saksukella's #2865 scope, region budgets for compute and kernel programs only (credited in the commit), with its test. The reasons are in the commit and the description: an AMD compiler crash on multi-region mesh loop headers, and a TDR here with region budgets in every stage that went away with this scope. Suite rerun on the new head (1439 / 0 / 47) and a new smoke block for it are in the description. The earlier test reports above are for 3cde150; the first commit is unchanged.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7202827400 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7202827400). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-26T20:33:40Z. --- Pushed `22c5f68` on top: @Saksukella's #2865 scope, region budgets for compute and kernel programs only (credited in the commit), with its test. The reasons are in the commit and the description: an AMD compiler crash on multi-region mesh loop headers, and a TDR here with region budgets in every stage that went away with this scope. Suite rerun on the new head (1439 / 0 / 47) and a new smoke block for it are in the description. The earlier test reports above are for `3cde150`; the first commit is unchanged. AI use: Claude Code (Claude Opus 5.5).
Aniseto commented 2026-11-26 21:13:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T21:13:42Z.


Re-ran the per-region loop-budget tests at 22c5f68c after the head moved from 3cde150b; this is a new response in the same thread, not an edit of my earlier report:

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs -- --test-threads=1: 2 passed, 0 failed, 0 ignored (1338 filtered out, exit 0)
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_endless_loops_in_many_regions_stop_after_four_budgets -- --test-threads=1: 1 passed, 0 failed, 0 ignored (1339 filtered out, exit 0)
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu::dxil::compact_tests -- --test-threads=1: 14 passed, 0 failed, 0 ignored (1326 filtered out, exit 0)

What this adds
The new head is titled "region loop budgets for compute and kernel programs only". The same filters still pass here on the real adapter, with the same counts as at 3cde150b. This is my second report in the thread and a new response for the changed head. I did not repeat the locally instrumented counter probe from the earlier NVIDIA report.

Not tested
The locally instrumented 98,304-iteration counter probe, a retail title, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7203516917 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7203516917). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-26T21:13:42Z. --- Re-ran the per-region loop-budget tests at `22c5f68c` after the head moved from `3cde150b`; this is a new response in the same thread, not an edit of my earlier report: **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders, 16 GB), driver 32.0.16.2124 - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_a_loop_after_a_spin_to_the_budget_still_runs -- --test-threads=1`: 2 passed, 0 failed, 0 ignored (1338 filtered out, exit 0) - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_endless_loops_in_many_regions_stop_after_four_budgets -- --test-threads=1`: 1 passed, 0 failed, 0 ignored (1339 filtered out, exit 0) - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu::dxil::compact_tests -- --test-threads=1`: 14 passed, 0 failed, 0 ignored (1326 filtered out, exit 0) **What this adds** The new head is titled "region loop budgets for compute and kernel programs only". The same filters still pass here on the real adapter, with the same counts as at `3cde150b`. This is my second report in the thread and a new response for the changed head. I did not repeat the locally instrumented counter probe from the earlier NVIDIA report. **Not tested** The locally instrumented 98,304-iteration counter probe, a retail title, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data. 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.
Decodere commented 2026-11-27 01:06:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T01:06:51Z.


Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2793 at head 22c5f68cda9ecfa0d651357c79302eba83c8d21e (2 commits 3cde150b -> 22c5f68c; exact merge-base: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (22c5f68c)

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)

  • 9220 log 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 sample 13994 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) plus per_region_loop_budgets_are_compute_only executed live with 0 skips (3/3 each) on desktop RTX 4060, alongside gpu::dxil::compact_tests:: (14/14 × 3) and gpu::dxil:: (184 executed + 1 expected no wave64 skip × 3).
  • Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on title: 29640639 confirms 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).

<!-- greyfinch-sync:ivall/xcl:comment:7207021899 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7207021899). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T01:06:51Z. --- Independent desktop NVIDIA (Wave32-only Ada) verification of **PR #2793** at head `22c5f68cda9ecfa0d651357c79302eba83c8d21e` (`2` commits `3cde150b -> 22c5f68c`; exact merge-base: `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`, pre-`#2555` ancestor of `main`). ### Environment - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12, Wave32-only Ada), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6C / 12T), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` (Developer Mode off) - **Toolchain:** `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC, DXC `1.9.2609.5`, `--release` ### Targeted release tests & build (`22c5f68c`) | 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`) - `9220` log 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 sample `13994 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`) plus `per_region_loop_budgets_are_compute_only` executed live with `0` skips (`3/3` each) on desktop RTX 4060, alongside `gpu::dxil::compact_tests::` (`14/14` × 3) and `gpu::dxil::` (`184` executed + `1` expected `no wave64` skip × 3). - Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on `title: 29640639` confirms 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).*
upipibi commented 2026-11-27 02:03:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-27T02:03:10Z.


@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 XCL_LOOP_BUDGET to hold under XCL_DIRECT_DXIL=1, dxil::lower::LOOP_BUDGET, VAR_BUDGET_TOTAL and the per-region refill in kernel.rs / compact.rs would read loop_budget(), and the value would join the direct translator's source identity. I'll run whichever version carries it on the RTX 3070 once it's pushed.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7207791128 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7207791128). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-27T02:03:10Z. --- @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 `XCL_LOOP_BUDGET` to hold under `XCL_DIRECT_DXIL=1`, `dxil::lower::LOOP_BUDGET`, `VAR_BUDGET_TOTAL` and the per-region refill in `kernel.rs` / `compact.rs` would read `loop_budget()`, and the value would join the direct translator's source identity. I'll run whichever version carries it on the RTX 3070 once it's pushed. AI-assisted (Claude Code, Claude Opus 5.5).
jessenic commented 2026-11-27 03:41:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-27T03:41:45Z.


@real-alponzo's #2947 (against amd-dev, which carries these two commits as 287a931b / 00fe5aec) reports that the region budgets still crash AMD's compiler on RDNA2 in compute programs: amdxc64.dll+0xd2a411, read at 0x138, on an RX 6800 (driver 32.0.21045.29003) for three retail compute shaders (2e0055c25f49848a, 6e148dbd563de205, 62b584e061c05fc5), and that keeping compute on the single budget ran 1,454 s with no driver crash.

That matters for this PR as it stands, so before it is merged:

  • What #2947 does to the fix. It leaves the region budgets for Mode::Kernel only. The spin this PR is for is in a retail compute program (the FSR producer a8de35e47f36d28c), so with #2947 the starved loops are back on every vendor, not only on AMD.
  • What I propose here instead: keep the region budgets for compute, and leave them out when the adapter is AMD (vendor 0x1002) until the trigger in LLPC is known. On this RTX 5070 Ti they are needed and have run for hours without a compiler crash; @DarkPanda69's RX 9070 XT run above passed the GPU tests, but that is RDNA4 and tests, not the retail programs on RDNA2.
  • Question for @real-alponzo: do the three shaders crash on both paths (HLSL through DXC and XCL_DIRECT_DXIL=1), or on one? If it is the multi-PHI loop header again, as in #2865, a guard that keeps the owner and the total in one packed counter (one PHI at the loop head) might avoid it without losing the fix on AMD. I cannot test AMD here.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7209197234 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7209197234). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-27T03:41:45Z. --- @real-alponzo's #2947 (against `amd-dev`, which carries these two commits as `287a931b` / `00fe5aec`) reports that the region budgets still crash AMD's compiler on RDNA2 in compute programs: `amdxc64.dll+0xd2a411`, read at `0x138`, on an RX 6800 (driver `32.0.21045.29003`) for three retail compute shaders (`2e0055c25f49848a`, `6e148dbd563de205`, `62b584e061c05fc5`), and that keeping compute on the single budget ran 1,454 s with no driver crash. That matters for this PR as it stands, so before it is merged: - **What #2947 does to the fix.** It leaves the region budgets for `Mode::Kernel` only. The spin this PR is for is in a retail *compute* program (the FSR producer `a8de35e47f36d28c`), so with #2947 the starved loops are back on every vendor, not only on AMD. - **What I propose here instead:** keep the region budgets for compute, and leave them out when the adapter is AMD (vendor `0x1002`) until the trigger in LLPC is known. On this RTX 5070 Ti they are needed and have run for hours without a compiler crash; @DarkPanda69's RX 9070 XT run above passed the GPU tests, but that is RDNA4 and tests, not the retail programs on RDNA2. - **Question for @real-alponzo:** do the three shaders crash on both paths (HLSL through DXC and `XCL_DIRECT_DXIL=1`), or on one? If it is the multi-PHI loop header again, as in #2865, a guard that keeps the owner and the total in one packed counter (one PHI at the loop head) might avoid it without losing the fix on AMD. I cannot test AMD here. 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.
throny commented 2026-11-27 22:11:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:11:40Z.


merge-check claim
head: 22c5f68cda

<!-- greyfinch-sync:ivall/xcl:comment:7229110865 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7229110865). Originally posted by [throny](https://github.com/throny) on 2026-11-27T22:11:40Z. --- merge-check claim head: 22c5f68cda9ecfa0d651357c79302eba83c8d21e
throny commented 2026-11-27 22:28:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:28:13Z.


merge-check
base: 2c717a04
head: 22c5f68cda
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1470 passed, 0 failed, 47 ignored (NVIDIA; the open point below is about AMD) (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: the logic checks out: a program is capped at four budgets in total, also when indirect jumps re-enter a region; region keys stay distinct; the stage gate covers the compact form. Behaviour change to be aware of: a program that used to hit the shared budget now gets budgets per outermost region, so loops after a spin run again, and a truly runaway program can spin up to four times longer before it stops. Open, and the reason for the verdict: #2947 (merged into amd-dev) reports crashes of AMD's shader compiler on RDNA2 for compute programs with region budgets; the author's last comment proposes gating AMD out before a merge and nothing is pushed yet. The interplay with XCL_LOOP_BUDGET (#1284) is also unresolved in the thread.
performance: default HLSL path: compute and kernel programs with two or more loop regions get two extra compares and decrements per loop iteration. It changes a translator source: every tester re-translates all shaders once (the author reports about 1,500 compute programs change). The frame-time gain reported in the thread was not measured here.
verdict: not yet: the AMD gate the author proposed (or evidence that RDNA2 is fine), and a word on XCL_LOOP_BUDGET; I will rerun on the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7229353821 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7229353821). Originally posted by [throny](https://github.com/throny) on 2026-11-27T22:28:13Z. --- merge-check base: 2c717a04 head: 22c5f68cda9ecfa0d651357c79302eba83c8d21e merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1470 passed, 0 failed, 47 ignored (NVIDIA; the open point below is about AMD) (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored review: the logic checks out: a program is capped at four budgets in total, also when indirect jumps re-enter a region; region keys stay distinct; the stage gate covers the compact form. Behaviour change to be aware of: a program that used to hit the shared budget now gets budgets per outermost region, so loops after a spin run again, and a truly runaway program can spin up to four times longer before it stops. Open, and the reason for the verdict: #2947 (merged into amd-dev) reports crashes of AMD's shader compiler on RDNA2 for compute programs with region budgets; the author's last comment proposes gating AMD out before a merge and nothing is pushed yet. The interplay with XCL_LOOP_BUDGET (#1284) is also unresolved in the thread. performance: default HLSL path: compute and kernel programs with two or more loop regions get two extra compares and decrements per loop iteration. It changes a translator source: every tester re-translates all shaders once (the author reports about 1,500 compute programs change). The frame-time gain reported in the thread was not measured here. verdict: not yet: the AMD gate the author proposed (or evidence that RDNA2 is fine), and a word on XCL_LOOP_BUDGET; I will rerun on the new head. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
jessenic commented 2026-11-28 00:11:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-28T00:11:50Z.


@throny thanks for the merge check. Pushed 1f106b3 for both points; the description is updated.

1. AMD (#2947). Compute programs translated for an adapter of vendor 0x1002 keep the single budget, in the HLSL path and in both direct forms (plain and compact). Kernels, the graphics stages and other vendors are unchanged. XCL_REGION_BUDGETS=1 gives AMD the region budgets too (for whoever wants to find the compiler's trigger), =0 takes them from every adapter. Such compute shaders are cached under their own memory key and disk identity, so one cache directory can serve both kinds of adapter.

  • The gate is vendor-wide, not RDNA2-only, because #2947's crash is on an RX 6800 and its thread mentions the same 0x138 read on an RX 7800 XT.
  • The cost: on AMD the starved loops this PR fixes are back for compute programs until the trigger is known.
  • A limit: the vendor is noted by whoever creates the device (real.rs, shaders.rs, the test runner). A process that translates without a device translates as for a non-AMD adapter.

2. XCL_LOOP_BUDGET (#1284). It is not in this tree (#1284 is open), so there is nothing to interact with yet. To give it one place to land, the HLSL region budgets now come from one helper, region_budget_limits(budget): two budgets a region and four in all, saturating; with the default the generated text is byte-identical to before. When #1284 lands it passes its value there. The direct forms keep their own constants, which #1284 does not cover either.

Tested (RTX 5070 Ti 16 GB, driver 610.88, Windows 11 26300): cargo test --workspace --no-fail-fast -- --test-threads=4 on 1f106b3: 1442 passed, 0 failed, 47 ignored, 25 SKIPPED lines (no wave64 on this adapter, three #1426 refusals, one "no heap windows"). The smoke block for the new head is in the description (1087 frames against 1057 on main, no removal, no crash). Not tested: any AMD adapter; the gate's logic has unit tests only.

AI use: Claude Code with Claude Fable 5.2 wrote the commit and its tests, ran the suite and the smoke run, and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7230723164 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7230723164). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-28T00:11:50Z. --- @throny thanks for the merge check. Pushed `1f106b3` for both points; the description is updated. **1. AMD (#2947).** Compute programs translated for an adapter of vendor `0x1002` keep the single budget, in the HLSL path and in both direct forms (plain and compact). Kernels, the graphics stages and other vendors are unchanged. `XCL_REGION_BUDGETS=1` gives AMD the region budgets too (for whoever wants to find the compiler's trigger), `=0` takes them from every adapter. Such compute shaders are cached under their own memory key and disk identity, so one cache directory can serve both kinds of adapter. - The gate is vendor-wide, not RDNA2-only, because #2947's crash is on an RX 6800 and its thread mentions the same `0x138` read on an RX 7800 XT. - The cost: on AMD the starved loops this PR fixes are back for compute programs until the trigger is known. - A limit: the vendor is noted by whoever creates the device (`real.rs`, `shaders.rs`, the test runner). A process that translates without a device translates as for a non-AMD adapter. **2. `XCL_LOOP_BUDGET` (#1284).** It is not in this tree (#1284 is open), so there is nothing to interact with yet. To give it one place to land, the HLSL region budgets now come from one helper, `region_budget_limits(budget)`: two budgets a region and four in all, saturating; with the default the generated text is byte-identical to before. When #1284 lands it passes its value there. The direct forms keep their own constants, which #1284 does not cover either. **Tested** (RTX 5070 Ti 16 GB, driver 610.88, Windows 11 26300): `cargo test --workspace --no-fail-fast -- --test-threads=4` on `1f106b3`: 1442 passed, 0 failed, 47 ignored, 25 SKIPPED lines (no wave64 on this adapter, three `#1426` refusals, one "no heap windows"). The smoke block for the new head is in the description (1087 frames against 1057 on `main`, no removal, no crash). **Not tested:** any AMD adapter; the gate's logic has unit tests only. AI use: Claude Code with Claude Fable 5.2 wrote the commit and its tests, ran the suite and the smoke run, and wrote this.
throny commented 2026-11-28 00:14:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T00:14:17Z.


Thanks, both points read as answered (the vendor gate with its own cache identity, and the single helper for the budgets). I cannot rerun the merge check yet: GitHub shows 1f106b3 as conflicting with main (now 2c717a04). Once it is rebased I will merge, build and run the suite on the new head and update my check; nothing else is open from my side.

AI use: Claude Code (Claude Fable 5.2).

<!-- greyfinch-sync:ivall/xcl:comment:7230755288 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7230755288). Originally posted by [throny](https://github.com/throny) on 2026-11-28T00:14:17Z. --- Thanks, both points read as answered (the vendor gate with its own cache identity, and the single helper for the budgets). I cannot rerun the merge check yet: GitHub shows `1f106b3` as **conflicting** with `main` (now `2c717a04`). Once it is rebased I will merge, build and run the suite on the new head and update my check; nothing else is open from my side. AI use: Claude Code (Claude Fable 5.2).
jessenic commented 2026-11-28 00:36:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jessenic on 2026-11-28T00:36:23Z.


@throny rebased onto main 2c717a04: the head is now 5dcdc52 (one conflict, in shaders.rs Pipelines::for_adapter: main's adapter selection is kept and the vendor is noted on the non-WARP path). @DarkPanda69 thanks for the RX 9070 XT and RTX 3060 runs, and for spelling out that the GPU tests translate in Mode::Kernel and so do not exercise the gate; that is right, it has its unit tests only.

On the rebased head, RTX 5070 Ti: cargo test --workspace --no-fail-fast -- --test-threads=4: 1473 passed, 0 failed, 47 ignored, 25 SKIPPED lines. Both smoke blocks in the description are new (main 2c717a04: 1258 frames; this head: 1272 frames; no removal, no crash). One thing to know about them: they were run with XCL_PREPARE=0, because with the shader preparation that is now on main a default run prepares the title's 26,503 shaders first and shows no frame within the 60 s, so smoke.ps1 finds no log to read. The description says so above the blocks.

AI use: Claude Code with Claude Fable 5.2 did the rebase, ran the suite and the smoke runs, and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7231045620 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7231045620). Originally posted by [jessenic](https://github.com/jessenic) on 2026-11-28T00:36:23Z. --- @throny rebased onto `main` `2c717a04`: the head is now `5dcdc52` (one conflict, in `shaders.rs` `Pipelines::for_adapter`: `main`'s adapter selection is kept and the vendor is noted on the non-WARP path). @DarkPanda69 thanks for the RX 9070 XT and RTX 3060 runs, and for spelling out that the GPU tests translate in `Mode::Kernel` and so do not exercise the gate; that is right, it has its unit tests only. On the rebased head, RTX 5070 Ti: `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1473 passed, 0 failed, 47 ignored, 25 SKIPPED lines. Both smoke blocks in the description are new (`main` `2c717a04`: 1258 frames; this head: 1272 frames; no removal, no crash). One thing to know about them: they were run with `XCL_PREPARE=0`, because with the shader preparation that is now on `main` a default run prepares the title's 26,503 shaders first and shows no frame within the 60 s, so `smoke.ps1` finds no log to read. The description says so above the blocks. AI use: Claude Code with Claude Fable 5.2 did the rebase, ran the suite and the smoke runs, and wrote this.
throny commented 2026-11-28 01:18:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T01:18:17Z.


merge-check
base: 2049651b
head: 5dcdc521ca
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1519 passed, 0 failed, 47 ignored (26 SKIPPED lines). The base moved to 2049651b while this ran and I have not run it alone at that commit; no test failed with the PR on it.
review: both points of my first check are addressed. The vendor gate covers every path that emits region budgets (the HLSL translation, the direct plain form and the direct compact form), and cache entries cannot cross vendors: the memory key carries the gate and the disk identity is wrapped before the rerouted lookup. With a non-AMD adapter and no switch the generated code is the same as on the old head (the helper returns the old constants), so the earlier review of the budgets stands. Every changed signature has its users on main updated. One optional hardening: the env switch is frozen once, but the noted vendor is last-writer-wins and is read again at the key, the identity and the translation, so in a process that notes two adapters of different vendors a result could be stored under the other's key; freezing the gate once per process, or computing it once per call and passing it down, closes that (whether one title process ever notes two vendors I did not verify). Before any device exists the vendor reads as not AMD, so offline preparation on an AMD machine without a device prepares entries the title will not use (wasted work, not wrong results). Not verified: any AMD run.
performance: default HLSL path, as in my first check: two extra compares and decrements per loop iteration in compute and kernel programs with two or more loop regions; every tester re-translates all shaders once. The gate itself costs a OnceLock read and an atomic load a few times per shader.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7231569692 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7231569692). Originally posted by [throny](https://github.com/throny) on 2026-11-28T01:18:17Z. --- merge-check base: 2049651b head: 5dcdc521ca01842f2f75b6da52c92ae538930474 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1519 passed, 0 failed, 47 ignored (26 SKIPPED lines). The base moved to 2049651b while this ran and I have not run it alone at that commit; no test failed with the PR on it. review: both points of my first check are addressed. The vendor gate covers every path that emits region budgets (the HLSL translation, the direct plain form and the direct compact form), and cache entries cannot cross vendors: the memory key carries the gate and the disk identity is wrapped before the rerouted lookup. With a non-AMD adapter and no switch the generated code is the same as on the old head (the helper returns the old constants), so the earlier review of the budgets stands. Every changed signature has its users on main updated. One optional hardening: the env switch is frozen once, but the noted vendor is last-writer-wins and is read again at the key, the identity and the translation, so in a process that notes two adapters of different vendors a result could be stored under the other's key; freezing the gate once per process, or computing it once per call and passing it down, closes that (whether one title process ever notes two vendors I did not verify). Before any device exists the vendor reads as not AMD, so offline preparation on an AMD machine without a device prepares entries the title will not use (wasted work, not wrong results). Not verified: any AMD run. performance: default HLSL path, as in my first check: two extra compares and decrements per loop iteration in compute and kernel programs with two or more loop regions; every tester re-translates all shaders once. The gate itself costs a OnceLock read and an atomic load a few times per shader. verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Grimkaaah commented 2026-11-30 12:05:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Grimkaaah on 2026-11-30T12:05:28Z.


I compared this with the loop caps in my project, a D3D12 translator for the same RDNA2 code, where each loop has its own counter that restarts when the loop is entered. I read the three commits at 5dcdc52 (loop_guard / budget_regions, the direct plain and compact guards, the AMD gate) and how current main routes compute programs.

What I checked, all fine: the guards' arithmetic (no underflow, xcl_btotal caps a program at four budgets even when a region is entered again), the region term in the compact class key, the cache identity of the gate, and that every structured loop head falls in a region.

Findings:

  1. recomp/mod.rs:677: a program with one loop region keeps the single budget, and that one region can be the nested spin itself. budget_regions returns nothing below two outermost ranges. So outer { spin to 0x10000; loop }, with no loop after the outer one, still has 65,536 iterations for everything. The outer head spends 1, the spin is cut at 0xFFFF, and the loop after it inside the outer loop gets no iteration. In the direct forms the cut ends the program (dxil/kernel.rs:395 cond_br(none, end, cont); compact.rs stores END), so the code after the spin doesn't run at all. On current main, compute goes through the direct translator by default. Test: spin_then_loop with the s1 loop moved inside the outer loop, before the s3 back edge. Expected [0x10000, n, 7]; this head gives [0xFFFF, 0, 7] in structured HLSL, and s2 stays 0 in the direct forms. Fix: also return the regions when the single outermost range has a loop nested in it (outer.len() < 2 && outer.len() == loops.len() → empty). Those programs are then re-translated once.
  2. Only one timed-out spin fits in a region. Suppose the outer loop runs its spin to 0x10000 twice (one poll per tile or per flag). Two outer iterations need 2 x 0x10001, more than the region's 2 budgets, so the second spin is cut two tries short. In the pc form and in both direct forms, that cut ends the program. In the pc form, pc stays inside the loop's range, so no later if (pc == ...) block runs; the direct guards branch to the exit. Later regions and the final stores are lost. Only structured HLSL goes on to the next region, and gpu_endless_loops_in_many_regions_stop_after_four_budgets only runs that form. One fix would cover finding 1 too and keep the worst case at four budgets: give each loop its own counter, reset where the loop is entered from outside (what xcl_bown does for a region), and keep xcl_btotal / VAR_BUDGET_TOTAL as the program cap. With it, a nest fits up to three timed-out spins before the total stops it. The cost is one more loop-carried value per loop, which is the AMD compiler concern of #2865 / #2947 that the vendor gate already keeps off AMD. If you keep the region design, a test whose outer loop runs the timed-out spin twice would at least show where it stands.

Not checked: we haven't run this PR on a GPU, and not the gate on an AMD adapter. Also not checked: loops made by indirect jumps (s_setpc), or the interaction with XCL_LOOP_BUDGET (#1284), which is already raised in this thread. The graphics stages stay on one budget here, by design.

AI use: Claude Code (Claude Opus 5.5) reviewed this by comparing it with the same mechanism in my project, Victory Grimkaaah.

<!-- greyfinch-sync:ivall/xcl:comment:7277931083 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7277931083). Originally posted by [Grimkaaah](https://github.com/Grimkaaah) on 2026-11-30T12:05:28Z. --- I compared this with the loop caps in my project, a D3D12 translator for the same RDNA2 code, where each loop has its own counter that restarts when the loop is entered. I read the three commits at `5dcdc52` (`loop_guard` / `budget_regions`, the direct plain and compact guards, the AMD gate) and how current `main` routes compute programs. What I checked, all fine: the guards' arithmetic (no underflow, `xcl_btotal` caps a program at four budgets even when a region is entered again), the region term in the compact class key, the cache identity of the gate, and that every structured loop head falls in a region. Findings: 1. recomp/mod.rs:677: a program with one loop region keeps the single budget, and that one region can be the nested spin itself. `budget_regions` returns nothing below two outermost ranges. So `outer { spin to 0x10000; loop }`, with no loop after the outer one, still has 65,536 iterations for everything. The outer head spends 1, the spin is cut at 0xFFFF, and the loop after it inside the outer loop gets no iteration. In the direct forms the cut ends the program (dxil/kernel.rs:395 `cond_br(none, end, cont)`; compact.rs stores `END`), so the code after the spin doesn't run at all. On current `main`, compute goes through the direct translator by default. Test: `spin_then_loop` with the `s1` loop moved inside the outer loop, before the `s3` back edge. Expected `[0x10000, n, 7]`; this head gives `[0xFFFF, 0, 7]` in structured HLSL, and `s2` stays 0 in the direct forms. Fix: also return the regions when the single outermost range has a loop nested in it (`outer.len() < 2 && outer.len() == loops.len()` → empty). Those programs are then re-translated once. 2. Only one timed-out spin fits in a region. Suppose the outer loop runs its spin to 0x10000 twice (one poll per tile or per flag). Two outer iterations need 2 x 0x10001, more than the region's 2 budgets, so the second spin is cut two tries short. In the pc form and in both direct forms, that cut ends the program. In the pc form, pc stays inside the loop's range, so no later `if (pc == ...)` block runs; the direct guards branch to the exit. Later regions and the final stores are lost. Only structured HLSL goes on to the next region, and `gpu_endless_loops_in_many_regions_stop_after_four_budgets` only runs that form. One fix would cover finding 1 too and keep the worst case at four budgets: give each loop its own counter, reset where the loop is entered from outside (what `xcl_bown` does for a region), and keep `xcl_btotal` / `VAR_BUDGET_TOTAL` as the program cap. With it, a nest fits up to three timed-out spins before the total stops it. The cost is one more loop-carried value per loop, which is the AMD compiler concern of #2865 / #2947 that the vendor gate already keeps off AMD. If you keep the region design, a test whose outer loop runs the timed-out spin twice would at least show where it stands. Not checked: we haven't run this PR on a GPU, and not the gate on an AMD adapter. Also not checked: loops made by indirect jumps (`s_setpc`), or the interaction with `XCL_LOOP_BUDGET` (#1284), which is already raised in this thread. The graphics stages stay on one budget here, by design. AI use: Claude Code (Claude Opus 5.5) reviewed this by comparing it with the same mechanism in my project, Victory Grimkaaah.
Foniass commented 2026-12-01 08:57:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:57:53Z.


Triage (#1607) – head 5dcdc52

Not on main: budget_regions/xcl_btotal are absent there. The same per-region loop budget commit is already on amd-dev (287a931b). #2947 (merged into amd-dev) then turned it off for all compute programs. This PR targets main and instead keeps compute on the single budget only on AMD adapters (pso::region_budgets, XCL_REGION_BUDGETS), with its own cache identity. No other open PR against main makes this change.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306022626 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2793#issuecomment-7306022626). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:57:53Z. --- **Triage (#1607)** – head 5dcdc52 Not on main: `budget_regions`/`xcl_btotal` are absent there. The same per-region loop budget commit is already on `amd-dev` (287a931b). #2947 (merged into amd-dev) then turned it off for all compute programs. This PR targets main and instead keeps compute on the single budget only on AMD adapters (`pso::region_budgets`, `XCL_REGION_BUDGETS`), with its own cache identity. No other open PR against main makes this change. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2793:upstream-pr/2793'
git switch 'upstream-pr/2793'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2793'
git switch 'upstream-pr/2793'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2793'
git switch 'upstream-pr/2793'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2793'
git switch 'main'
git merge --squash 'upstream-pr/2793'
git switch 'main'
git merge --ff-only 'upstream-pr/2793'
git switch 'main'
git merge 'upstream-pr/2793'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2783
No description provided.