Skip to content

Recompiler: one skip variable for all forward jumps of structured code - #1345

Open
Sr-0w wants to merge 1 commit into
xcl-dev:mainfrom
Sr-0w:recomp-one-skip-variable
Open

Sr-0w wants to merge 1 commit into
xcl-dev:mainfrom
Sr-0w:recomp-one-skip-variable

Conversation

@Sr-0w

@Sr-0w Sr-0w commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1269.

Every forward jump out of nested structured code had its own flag (xcl_skip_<target>), and the code after it ran under if (!(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 -O0 and 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):

  • a jump sets xcl_skip = <target + 1> (0xFFFFFFFF for the end);
  • a level's guard is if (xcl_skip == 0u) — plus || xcl_skip == <t> for targets inside a loop it enters, which the old guard left out the same way;
  • a target clears the variable if it is the one taken, outside the guard that skipped up to it;
  • after a loop body: clear the latch's jump, continue for a jump to the head, then one if (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_range and 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 as ifs). 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 160 and the test fails; with it, it passes.

Measured on a retail pack's 12 361 compute programs (4 heap windows, structured):

before after
the 76 699-instruction program 147 MB HLSL 51 MB
three ~45 000-instruction programs 12.7 / 12.3 / 12.0 MB 12.6 / 12.2 / 11.9 MB
all compute programs ≈ 6.11 GB 6.01 GB

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

  • Windows 11, AMD Radeon RX 7800 XT (RDNA3, 64-lane waves), DXC 1.9.2602.17.
  • cargo test --workspace -- --test-threads=4 on 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.
  • The new test fails on main (quadratic count) and passes on the PR head.

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD  Radeon RX 7800 XT
title: a retail title
seconds: 60
exit: 0x0
frames shown: 1521 (PresentX 1521)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18201 MB

PR head:

xcl-smoke v1
commit: c92035532ae47cd61fbd0e2d461a1fc13826359a
gpu: AMD  Radeon RX 7800 XT
title: a retail title
seconds: 60
exit: 0x0
frames shown: 1435 (PresentX 1435)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17345 MB

Not tested

  • 32-lane GPUs (NVIDIA) and the split wave64 form on them; the emitted control flow is the same for both forms.
  • DXC and driver compile time of the 76 699-instruction program after the change: at 51 MB it is still compiled at -O0 (over 8 MB), so it is still far too big for the driver; this only removes the quadratic part.
  • A 60 s smoke run does not reach the world load, where the largest compute programs are built.

AI use

  • Claude Code (Claude Opus 5.5) found the cause in the emitted HLSL, wrote the change and the test, ran the measurements and the runs, and wrote this description, under author review.

🤖 Generated with Claude Code

@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head c920355 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • The new tests ran and passed: crossing_forward_jumps_guard_in_linear_size.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Verified head c92035532ae47cd61fbd0e2d461a1fc13826359a on 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

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

@pvfreis pvfreis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of c920355 (merge base 930e8b4; main has not touched recomp/mod.rs or tests.rs since), by reading the code; nothing was built or run here. I traced emit_structured for overlapping and nested jumps: several jumps to one target, a target inside a loop (also nested loops, and the latch), breaks out of loops, continue of an outer loop through a skip, rotated loops, and the reuse of an open guard after an item raises a new target. I found no defect in the shared variable. It is per-lane like the old flags and set from the same conditions, so its uniformity is unchanged.

  1. CONFIRMED: the GPU half of crossing_forward_jumps_guard_in_linear_size compares the new skip code with itself. With structured: false the 24-jump program is not split into blocks. emit_range finds one span, [0, target 23), through structured_span (mod.rs:1100-1122) and emits it with emit_structured (mod.rs:1140-1146). Both forms therefore run the same xcl_skip guards; the only difference is the pc guard around the span and around the last block. A mistake in the guards would show in both forms, and assert_eq! (tests.rs:7642) would still pass. There is a second gap: the branch tests bit k % 8 of s0, so the first jump taken is always jump 0-7 or none. The six inputs cover four cases (no jump, jump 0 for 1/0xA5/0xFF, jump 1, jump 7), and jumps 8-23 are never the one taken. Jump 0 is emitted as a plain if (item_at, nothing pending yet), so only 0x5A and 0x80 set xcl_skip at all. Suggested fix: compare against expected s1/s2 computed in Rust. If jump k is taken first, s1 = k + 1 and targets k..=23 each run s2 = (s2 + s1) ^ 1; with no jump taken, s1 = 24 and all 24 targets run. Also test bit k % 24 instead of k % 8 (build is shared with the 40- and 160-jump size check, and the inline constant only reaches 64) and add inputs with a bit in 8..23, e.g. 1 << 8 and 1 << 23, so that any jump can be the first one taken. (@thehollowedone's scratch run compared both forms against a CPU reference and they matched, so the behaviour checks out; the test as written does not check it.) A small fix while there: the comment at tests.rs:7612 says s2 ^= s1 + k, but the code computes s2 = (s2 + s1) ^ 1.

Also: HANDOFF.md describes these skips as xcl_skip_<target> flags (its "Structure" item under the structured-form notes). CONTRIBUTING asks for that to be named in the description.

Verdict: no defect found in the translator change as far as I read; the new test's GPU check is not independent of it.

Review by Claude Code (written by Claude Opus 5.5, checked with Claude Fable 5.2 and Claude Opus 5.5); each point checked by a person before posting.

@wondercrash

Copy link
Copy Markdown
Contributor

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_skip holding 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:

  1. Indentation cap. With this PR, 95cc's structured HLSL is 53.0 MB, of which 42.7 MB is leading whitespace (its loops nest 65 deep). Capping indentation at 8 levels brings it to 19.3 MB (dispatcher form: 15.4 MB). DXC output is unchanged; it is text only.
  2. GPU check on 32-lane GPUs. The new GPU test only runs where 64-lane waves exist, so it is skipped on NVIDIA. Running it as wave32 there covers NVIDIA too.
  3. Optional: one loop in 95cc is entered by about 600 jumps, giving ~90 guard lines of ~14 KB each. A range test (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 -O1 did not finish, and the -O0 DXIL (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 shaders on the retail shaders.rpf, DXC 1.8.2502.

AI use: omp with Claude Opus 5.5 (the comparison and measurements).

@nnonno91

Copy link
Copy Markdown

Synthetic DXC scaling check on c920355

The 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

  • Base 930e8b49c1c2ec683d22c724a398b39111cd0e56 and head c92035532ae47cd61fbd0e2d461a1fc13826359a, 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.
  • I adapted only the PR’s test fixture to write HLSL for 40, 160, and 320 crossing jumps on each revision. cargo test --locked -p xcl --lib probe_crossing_jumps_hlsl_and_gpu_results -- --nocapture --test-threads=1 also ran the 24-jump correctness fixture on native wave64. Both builds matched their dispatcher for all six inputs, with zero hardware skips.
  • I compiled each generated shader using 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.
Crossing jumps HLSL bytes, base → PR Skip references, base → PR Median DXC, base → PR DXIL bytes, base → PR
40 79,572 → 55,483 1,638 → 195 81.44 → 30.05 ms 6,976 → 4,244
160 537,852 → 134,641 25,758 → 795 1,127.94 → 74.50 ms 18,452 → 5,032
320 1,958,716 → 240,369 102,718 → 1,595 6,001.88 → 168.65 ms 34,620 → 6,072

Not tested

  • Whole workspace suite, driver pipeline creation time, larger retail shaders, and retail-title smoke behavior in this run. The timing measures the standalone compiler on synthetic source.

AI use

  • OpenAI Codex (GPT-6, exact model variant unavailable) adapted the test fixture, ran the checks and measurements, and prepared this report.

@zGLados

zGLados commented Nov 24, 2026

Copy link
Copy Markdown

Test report for head c920355 on 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

  • AMD Radeon RX 7700 XT (RDNA3, native wave64), driver 32.0.32015.7029; Ryzen 7 7700X, 32 GB; Windows 11 26300; rustc 1.98.1 MSVC, release; DXC 1.9.2602.17 (Windows SDK).
  • Retail shaders.rpf (1.0.2.1), xcl shaders <pack> --precompile --only cs [--pipelines] [--limit N]. Private bytes of xcl.exe were sampled every 10 s.
  • The 76,699-instruction program (95cc13288a27a96e, record 22823 here): 53.0 MB HLSL with this PR, 154.6 MB on main 930e8b4, 15.4 MB on main with b8b1f49 reverted. 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 are if (xcl_skip == 0u) {.
  • DXC: with this PR, all 667 compute programs up to that record compiled with 15 DXC threads, with 0 errors and a peak of 8.8 GB. The big program alone took ~11 min at a flat ~4 GB, giving 15.6 MB of DXIL (14.1 MB reverted). On main the 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.
  • Driver pipelines (--pipelines): one program hangs the AMD device with this PR. Record 22571 horse_standard_hair:CS_RaytracingResolve_b1139868_Wrapped (DXIL 1,068,432 B) fails CreateComputePipelineState within ~2 s. The error is DXGI_ERROR_DEVICE_REMOVED, and GetDeviceRemovedReason returns DXGI_ERROR_DEVICE_HUNG (0x887A0006). Every later pipeline is refused. It reproduced on every try, with XCL_PIPELINE_THREADS=1 and XCL_PSO_DISK_CACHE=0 (no driver blobs):
    • this PR, --limit 22571: 414 made, 0 refused; --limit 22572: 414 made, 1 refused (twice each);
    • main 930e8b4, --limit 22572: 415 made, 0 refused.
      The HRESULTs came from a build with one added eprintln! in shaders.rs (Pipelines::make throws them away). The counts above come from the unchanged head.
  • With 4 driver threads (the default), a --pipelines run 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.
  • 300 s title runs with A presses (XCL_PRESS_A_AT, 10–118 s), main and this PR's head, same caches. Both end with the title's own stall watchdog (+0x23cf683, "GPU Loc Sig" 7333478d, as in Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 / Retail title (Xbox Series 1.0.2.1) reaches actual gameplay on RDNA3 — then 0xC0000005 in the title (+0x23cf683) #534): main at 118.3 s, this PR at 116.2 s. Neither had a device removal. Peak commit was 29.8 GB on main and 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:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 7700 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 300
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 2
peak commit: 29787 MB

PR head:

xcl-smoke v1
commit: c92035532ae47cd61fbd0e2d461a1fc13826359a
gpu: AMD Radeon RX 7700 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 300
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 2
peak commit: 29604 MB

Not tested

  • The workspace test suite on this GPU (the RX 7800 XT runs above cover RDNA3).
  • Whether record 22571 also hangs on RDNA2/RDNA4 or NVIDIA, and which part of its new control flow the driver chokes on. I did not compare its HLSL against main's.
  • Driver build time and memory of the 53 MB program itself: the device was hung before --pipelines reached it.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds, measurements and runs on this machine and wrote this report.

@zGLados zGLados mentioned this pull request Nov 24, 2026
@Pipodi

Pipodi commented Nov 24, 2026

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32) test and retail smoke report on clean head c92035532ae47cd61fbd0e2d461a1fc13826359a.

Tested

  • Commit: c92035532ae47cd61fbd0e2d461a1fc13826359a (clean tree, merge-base 930e8b4)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo build --release --workspace: ok (exit 0)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored, exit 0
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware

Regression run
main baseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

PR head (c92035532ae47cd61fbd0e2d461a1fc13826359a):

xcl-smoke v1
commit: c92035532ae47cd61fbd0e2d461a1fc13826359a
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1568)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14726 MB

Not tested: debug build, offline --precompile timings 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.

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
emit_structured indented every nested if / loop one more level. A retail
compute program whose loops nest ~65 deep carried 42.7 MB of leading
whitespace in 53.0 MB of HLSL (~80 %, measured on xcl-dev#1345); DXC reads and
keeps those bytes although they mean nothing to it.

Indentation stops at 8 levels (MAX_INDENT); deeper code is written at the
cap. Only whitespace changes. Measured on three retail compute programs
on main alone (no xcl-dev#1345), size of the HLSL file:
  p16  29,598,855 -> 19,264,315 B  (29.6 -> 19.3 MB)
  p17  29,524,131 -> 19,189,591 B  (29.5 -> 19.2 MB)
  p18 151,193,185 -> 117,650,689 B (151.2 -> 117.7 MB)
a saving of 22-35 % on main. Synthetic test program (14 nested ifs):
35346 -> 34498 bytes.

dxc.rs:491-494 picks the DXC level from the raw src.len(), whitespace
included. Programs of about 1.0 - 1.5 MiB move from -O1 to -O3 and
programs of about 8 - 11 MiB from -O0 to -O1. None of the three measured
programs crosses a line (all stay above 8 MiB, at -O0); DXC time p16
69.9 s -> 64.0 s, p17 63.1 s -> 63.2 s.

emit_range (the unstructured fallback) is not capped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013qV4hiM5Sx9hBkPpgAarKX
@pvfreis

pvfreis commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Since my review, #1321 (e9e94ce) is on main. c920355 still merges without a conflict, but the merged tree fails one test that main passes:

thread 'gpu::recomp::tests::oversized_structured_code_falls_back_to_pc_blocks' (21324) panicked at crates\xcl\src\gpu\recomp\tests.rs:7639:5:
200 crossing jumps: past the bound, pc blocks

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:

  • main 689f2db: 974 passed, 1 failed, 45 ignored
  • c920355 merged onto it: 974 passed, 2 failed, 45 ignored

The 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_size returns 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 is if (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 for 95cc13288a27a96e with 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 the pc form. 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 CreateComputePipelineState for one program with this head and not with main 930e8b4 (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.

Pipodi added a commit to Pipodi/xcl that referenced this pull request Nov 25, 2026
emit_structured indented every nested if / loop one more level. A retail
compute program whose loops nest ~65 deep carried 42.7 MB of leading
whitespace in 53.0 MB of HLSL (~80 %, measured on xcl-dev#1345); DXC reads and
keeps those bytes although they mean nothing to it.

Indentation stops at 8 levels (MAX_INDENT); deeper code is written at the
cap. Only whitespace changes. Measured on three retail compute programs
on main alone (no xcl-dev#1345), size of the HLSL file:
  p16  29,598,855 -> 19,264,315 B  (29.6 -> 19.3 MB)
  p17  29,524,131 -> 19,189,591 B  (29.5 -> 19.2 MB)
  p18 151,193,185 -> 117,650,689 B (151.2 -> 117.7 MB)
a saving of 22-35 % on main. Synthetic test program (14 nested ifs):
35346 -> 34498 bytes.

dxc.rs:491-494 picks the DXC level from the raw src.len(), whitespace
included. Programs of about 1.0 - 1.5 MiB move from -O1 to -O3 and
programs of about 8 - 11 MiB from -O0 to -O1. None of the three measured
programs crosses a line (all stay above 8 MiB, at -O0); DXC time p16
69.9 s -> 64.0 s, p17 63.1 s -> 63.2 s.

emit_range (the unstructured fallback) is not capped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013qV4hiM5Sx9hBkPpgAarKX
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/xcl/src/gpu/recomp/tests.rs
IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
… in recomp/tests.rs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every forward jump out of nested structured code had its own flag, and the
code after it ran under `if (!(flag_a || flag_b || ...))` over every jump
pending at that level, written again after each block that raised another.
In a long run of crossing jumps that is quadratic: a retail compute program
of 76 699 instructions had 10 877 such guards of up to 600 flags, 95 of its
147 MB of HLSL.

At most one of these jumps is taken at a time: once one is, no code runs
until its target. They now share one variable holding the taken jump's
target (0: none). A guard is `xcl_skip == 0u` (plus the targets inside a
loop it enters), a target clears the variable if it is the one taken, and a
loop is left with one `if (xcl_skip != 0u) break;` after its `continue`.

That program's HLSL goes from 147 MB to 51 MB. Other programs barely change
(a retail pack's compute programs: 6.11 GB to 6.01 GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sr-0w
Sr-0w force-pushed the recomp-one-skip-variable branch from c920355 to 13b4a79 Compare November 25, 2026 13:09
@jennydeth

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.