Recompiler: one skip variable for all forward jumps of structured code #1345
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1345
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1345"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Sr-0w on GitHub · 2026-11-24 15:01 UTC · original
Sr-0w:recomp-one-skip-variable→main· +103 −28 · 2 files · 1 commits · openPart of #1269.
Every forward jump out of nested structured code had its own flag (
xcl_skip_<target>), and the code after it ran underif (!(xcl_skip_a || xcl_skip_b || …))over every jump pending at that level, written again after each block that raised another one. A long run of crossing forward jumps is therefore quadratic in HLSL. In a retail pack, one compute program of 76 699 instructions had 10 877 such guards of up to ~600 flags each (about 10 KB per line): 95 of its 147 MB of HLSL. That program is one of the six over 8 MB that are compiled at-O0and that the driver does not finish (see the numbers in #1269).At most one of these jumps is taken at a time: once one is taken, no code runs until its target, so no other one can be raised in between. They now share one variable holding the taken jump's target (
0= none):xcl_skip = <target + 1>(0xFFFFFFFFfor the end);if (xcl_skip == 0u)— plus|| xcl_skip == <t>for targets inside a loop it enters, which the old guard left out the same way;continuefor a jump to the head, then oneif (xcl_skip != 0u) break;for every other one.What is in it
crates/xcl/src/gpu/recomp/mod.rs:skip_flag→skip_id/skip_taken/skip_clear;emit_structured,emit_rangeand the declaration use the one variable.crates/xcl/src/gpu/recomp/tests.rs:crossing_forward_jumps_guard_in_linear_size— N forward jumps whose ranges cross (cannot nest asifs). It checks that the uses of the skip variable grow linearly with N, then runs the structured and the dispatcher forms on the GPU for several jump patterns and compares the state. Without the change:1638 for 40, 25758 for 160and the test fails; with it, it passes.Measured on a retail pack's 12 361 compute programs (4 heap windows, structured):
This fixes the quadratic case only. The ordinary large programs that stall a world load (20 000 – 45 000 instructions, ~1 MB of DXIL) barely change: their size is per instruction.
Tested
cargo test --workspace -- --test-threads=4on the PR head: 752 passed, 0 failed, 41 ignored; no SKIPPED tests.jumps_to_outer_loop_heads_are_structured(120 random loop nests run in structured and dispatcher form on the GPU) passes with the change.main(quadratic count) and passes on the PR head.Regression run
main:PR head:
Not tested
-O0(over 8 MB), so it is still far too big for the driver; this only removes the quadratic part.AI use
🤖 Generated with Claude Code
@futurepro62 on GitHub · 2026-11-24 15:03 UTC · original · edited 2026-11-24 15:08 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
c920355(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.crossing_forward_jumps_guard_in_linear_size.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@mastrr9 on GitHub · 2026-11-24 15:30 UTC · original
Verified head
c92035532ae47cd61fbd0e2d461a1fc13826359aon Windows 11 / NVIDIA RTX 5080 (wave32 / split-wave64, DXC 1.9.2602.17, Rust MSVC, debug build, clean worktree):cargo test -p xcl --lib -- gpu::recomp --test-threads=4: 190 passed, 0 failed, 18 ignored (0 new compiler warnings).Not tested: AMD native wave64, full workspace, retail smoke (
scripts/smoke.ps1).AI use: T3 Code (Antigravity / Claude Sonnet 5.5) ran the build and tests on our RTX 5080 and drafted this report.
@thehollowedone on GitHub · 2026-11-24 15:49 UTC · original
Wave32 GPU follow-up on c920355, Windows 11 build 26300, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug.
The GPU sections of these two tests require native wave64 as written. In a scratch copy I selected wave32 in the test fixtures and left the PR’s translator code unchanged.
crossing_forward_jumps_guard_in_linear_size: 1 passed. Both generated forms matched an independent CPU reference for all six branch inputs.jumps_to_outer_loop_heads_are_structured: 1 passed. All 120 generated programs ran both ways, including 70 with jumps into a loop. The scalar registers, vector registers and condition flag matched.Each filter ran under
cargo test --offline --locked -p xcl --lib <filter> -- --test-threads=1 --nocapture. Synthetic wave32 coverage only.AI-assisted. Codex (GPT-6 family, exact variant unavailable) adapted and ran the fixtures and drafted this report.
@DavidM1911 on GitHub · 2026-11-24 16:11 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
@wondercrash on GitHub · 2026-11-24 16:26 UTC · original
We hit the same blow-up on the retail title (95cc13288a27a96e, the program from #1307) and fixed it the same way independently: one
uint xcl_skipholding the pending target, guards testing a single value, loops entered in the middle letting their entry targets through. Control flow is equivalent to this PR. Three things from our version that may be worth taking:xcl_skip > a && xcl_skip <= b) over the contiguous entry targets is equivalent and saves about 1 MB.Note for #1269: size alone does not make 95cc compile. Its structured form at DXC
-O1did not finish, and the-O0DXIL (9.8 MB) did not finish in the NVIDIA driver in 30 minutes (RTX 5090, driver 621.14). The cost there is the 65-deep loop nest, not the guards.Measured on our integration tree (upstream main + our open changes), not on this PR's head alone: translation sizes from
xcl shaderson the retailshaders.rpf, DXC 1.8.2502.AI use: omp with Claude Opus 5.5 (the comparison and measurements).
@nnonno91 on GitHub · 2026-11-24 16:35 UTC · original
Synthetic DXC scaling check on
c920355The PR’s crossing-jump fixture shows a growing DXC compile-time difference as the number of jumps increases. At 320 jumps the generated HLSL was 8.15× smaller, and median DXC time went from 6.00 s to 0.169 s.
Tested
930e8b49c1c2ec683d22c724a398b39111cd0e56and headc92035532ae47cd61fbd0e2d461a1fc13826359a, with separate Cargo target directories. Ryzen 7 9800X3D, Windows 11 25H2 (26200.9974), AMD Radeon(TM) Graphics (driver 32.0.21042.62, native wave64), Rust 1.100.0 MSVC, DXC 1.9.2609.5.cargo test --locked -p xcl --lib probe_crossing_jumps_hlsl_and_gpu_results -- --nocapture --test-threads=1also ran the 24-jump correctness fixture on native wave64. Both builds matched their dispatcher for all six inputs, with zero hardware skips.dxc.exe -E main -T cs_6_6 -HV 2021 -O1. The table uses three paired wall-clock timings per size after one warm-up per build, alternating the order and writing a new output file for each invocation.Not tested
AI use
@zGLados on GitHub · 2026-11-24 16:36 UTC · original
Test report for head
c920355on Windows AMD RDNA3 with the retail pack: the HLSL size and DXC memory of the 76k-instruction program, driver pipeline builds, and a 300 s title run. These cover two of the PR's Not tested points.Tested
shaders.rpf(1.0.2.1),xcl shaders <pack> --precompile --only cs [--pipelines] [--limit N]. Private bytes ofxcl.exewere sampled every 10 s.95cc13288a27a96e, record 22823 here): 53.0 MB HLSL with this PR, 154.6 MB onmain930e8b4, 15.4 MB onmainwithb8b1f49reverted. Without leading whitespace it is 10.3 MB with this PR against 9.4 MB reverted. What is left is indentation from nesting 121 levels deep (29 when reverted). 14,693 guards areif (xcl_skip == 0u) {.mainthe same command grew ~1 GB/s and I stopped it at 66 GB (15 threads). With 2 threads it reached 33 GB in 41 s. With 1 thread it was still on this program after 60 s.--pipelines): one program hangs the AMD device with this PR. Record 22571horse_standard_hair:CS_RaytracingResolve_b1139868_Wrapped(DXIL 1,068,432 B) failsCreateComputePipelineStatewithin ~2 s. The error isDXGI_ERROR_DEVICE_REMOVED, andGetDeviceRemovedReasonreturnsDXGI_ERROR_DEVICE_HUNG(0x887A0006). Every later pipeline is refused. It reproduced on every try, withXCL_PIPELINE_THREADS=1andXCL_PSO_DISK_CACHE=0(no driver blobs):--limit 22571: 414 made, 0 refused;--limit 22572: 414 made, 1 refused (twice each);main930e8b4,--limit 22572: 415 made, 0 refused.The HRESULTs came from a build with one added
eprintln!inshaders.rs(Pipelines::makethrows them away). The counts above come from the unchanged head.--pipelinesrun went from ~8 GB to 70 GB of private bytes within 80 s once it reached records 22600–22800 (DXIL from the cache, so the driver's compiles). I stopped it there, so it is not known whether those finish.XCL_PRESS_A_AT, 10–118 s),mainand this PR's head, same caches. Both end with the title's own stall watchdog (+0x23cf683, "GPU Loc Sig" 7333478d, as in #505 / #534):mainat 118.3 s, this PR at 116.2 s. Neither had a device removal. Peak commit was 29.8 GB onmainand 29.6 GB on this PR. On this machine the title does not reach the big programs before the watchdog, so these runs cover neither the memory growth nor the hang above.Regression run
main:PR head:
Not tested
main's.--pipelinesreached it.AI use
@Pipodi on GitHub · 2026-11-24 17:19 UTC · original
@wondercrash @Sr-0w: unless one of you is already opening it, I'll take point 1 above (the indentation cap of structured code) as its own small PR against
main, separate from this one so it can be reviewed on its own. It only changes the text: the PR will show the HLSL size before and after on a nested program and check that DXC's output is unchanged on the tests' programs. If either of you has it ready, say so and I'll test yours on an RTX 4090 instead.AI use: Claude Code (Claude Opus 5.5) wrote this comment.
@LocranKing on GitHub · 2026-11-24 17:43 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32) test and retail smoke report on clean head
c92035532ae47cd61fbd0e2d461a1fc13826359a.Tested
c92035532ae47cd61fbd0e2d461a1fc13826359a(clean tree, merge-base930e8b4)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo build --release --workspace: ok (exit 0)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored, exit0SKIPPED(no wave64):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardwareRegression run
mainbaseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):PR head (
c92035532ae47cd61fbd0e2d461a1fc13826359a):Not tested: debug build, offline
--precompiletimings on the full shader pack, AMD / native wave64 hardware, extended gameplay past 60 s.AI use: Antigravity (
Gemini 4 Neon) ran the build, tests, and smoke runs and drafted this report from the command outputs.@pvfreis on GitHub · 2026-11-24 22:48 UTC · original
Since my review, #1321 (
e9e94ce) is onmain.c920355still merges without a conflict, but the merged tree fails one test thatmainpasses:cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, debug, RTX 3060 (32-lane waves), DXC 1.9.2602.17, isolated session without a swap chain:main689f2db: 974 passed, 1 failed, 45 ignoredThe other failure is the e2e title test on both (no swap chain in that session). 22 identical SKIPPED lines on both. The GPU half of
crossing_forward_jumps_guard_in_linear_sizereturns early on this adapter (no wave64).Why: the test needs its 200-jump program to exceed
STRUCTURED_BYTES_PER_CODE_BYTE(128 B of structured HLSL per code byte,mod.rs:641). With no loop to enter, as here, your guard isif (xcl_skip == 0u)however many jumps are pending, so the HLSL grows linearly and stays below the bound: nnonno91's table above for this PR's similar fixture gives 661 B per added jump of 20 code bytes, about 33 B per byte. The test needs a program that still crosses the bound, or the bound goes; @tiagonogueiraa-bit named those options on #1321. Question: zGLados measured 53.0 MB of HLSL for95cc13288a27a96ewith this head, and #1307 gives its code as 334 KB, so it is still about 159 B per byte, above the bound: on the merged tree it would still take thepcform. Intended? The comment above the constant ("Each guard of the structured form lists every pending skip flag") and the test's doc comment stop being true with this PR.Correction to point 1 of my review: "so the behaviour checks out" was too broad. It rests on one scratch run (RTX 3080 Ti, wave32) of the same six inputs that point itself says cover four cases. zGLados later reported an RX 7700 XT device hang in
CreateComputePipelineStatefor one program with this head and not withmain930e8b4(report).Not tested here: AMD, native wave64, a title.
Run and written with Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.
@jennydeth on GitHub · 2026-11-25 14:14 UTC · original
Run on a 32-lane NVIDIA card (listed under Not tested).
Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head c920355.
Result: cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED: 2 GPU tests for no wave64 (expected on this card).
Not tested: DXC / driver compile times; a title run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@DavidM1911 on GitHub · 2026-11-26 04:53 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.