Recompiler: structured code indents at most 8 levels #1584
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!1584
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1584"
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?
@Pipodi on GitHub · 2026-11-24 17:57 UTC · original
Pipodi:indent-cap→main· +28 −3 · 2 files · 1 commits · openThe structured form limits how deep code nests (
MAX_NEST), but not how far it is indented: every nestedifand loop adds four spaces. On big compute programs most of the HLSL is leading whitespace, which DXC reads and keeps although it means nothing to it. On #1345's form, @wondercrash measured 42.7 MB of whitespace in the 53.0 MB ofActivateRays(#1345 comment 7137676632, point 1). This PR stops indentation at 8 levels and changes nothing else. Part of #1269.What is in it
crates/xcl/src/gpu/recomp/mod.rs:MAX_INDENT = 8, applied inemit_structuredandemit_block.emit_range, the unstructured fallback, is not capped.crates/xcl/src/gpu/recomp/tests.rs:structured_indentation_stops_at_the_cap(14 nested ifs; the widest line is 28 spaces). With the cap at 99 it fails (60 spaces).Tested
RTX 4090 24 GB (driver 617.42), i9-13900K, 32 GB, Windows 11 Pro build 26300, rustc 1.100.0. Suite in debug, smoke runs in release.
dee5ada(rebased ontomain0cdc896):cargo build --workspace && cargo test --workspace -- --test-threads=4gave 1086 passed, 0 failed, 46 ignored, in 20 result blocks, with 24 SKIPPED lines (no wave64, the per-lane f16/f32 refusals frommain, no heap windows, no Developer Mode). The rebase keptmain's newem.emit_instscall inemit_blockand caps its indent; the pc-block fallback from #1307 is not capped, likeemit_range.Fails without the change: with
MAX_INDENTat 99,structured_indentation_stops_at_the_capfails (rerun ondee5ada).The HLSL and DXC numbers below were measured before the rebase, at
f578e66; the patch is the same.Only whitespace changes. On the three programs below, the HLSL with the cap and with the cap lifted is byte-identical once leading spaces are stripped (sha1 compared).
HLSL size on
main(without #1345), three retail compute programs:ActivateRays)DXC time (one debug run each): program 1 69.9 → 64.0 s, program 2 63.1 → 63.2 s. Program 3 timed out at 280 s both ways.
Regression run
The retail title, 60 s,
XCL_PRESS_AT=16:A, a new emptyXCL_DXIL_CACHEper run.main689f2db:This PR, head
dee5ada:The PR's run got 95.3 % of
main's frames and 96.2 % of its peak commit.Not tested
dxc.rs:491-494picks the level from the raw source length, whitespace included, so a program the cap brings under a line gets compiled at a higher level. About 1.0–1.5 MiB moves from-O1to-O3, and about 8–11 MiB from-O0to-O1. None of the three programs above crosses a line (all stay at-O0), and I have not measured a program that does. If #1526 merges, only the 1 MiB line remains.main) falls back to the pc form above128 * program.len()bytes, a limit set on uncapped sizes; with the cap, fewer programs reach it.arguments(src.len(), ..)also keys on raw size.AI use
dee5ada.🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-24 18:09 UTC · original
Independent AMD test of the 1 MiB DXC cutoff on
f578e661b340463e47e675082619989e669c8713against9e3831e1f570d3646e53ab753b19ec07eb8f1485.Tested
cargo build --workspace --lockedpassed.cargo test --locked -p xcl --lib structured_indentation_stops_at_the_cap -- --test-threads=1passed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 777 passed, 0 failed, and 41 ignored. One reported GPU skip (heap_window_out_of_memory_falls_back_to_the_switch_form, no heap windows). The bundled title passed.cargo test --locked -p xcl --test indent_threshold_probe -- --exact emit_indentation_samples --nocapture --test-threads=1generated eight synthetic kernels on each revision with 14 nested branches and 1,024–8,192 repeated adds in the body. All HLSL pairs matched after removing leading spaces. Maximum indentation was 60 spaces on base and 28 on the PR. Two fixtures crossed below 1 MiB.cargo test --locked -p xcl --test indent_gpu_probe -- --exact compile_and_run_across_indent_cutoff --nocapture --test-threads=1compiled the 5,120-add fixture through XCL’s normal DXC path and explicit-O1/-O3controls.-O1-O3Forcing the same optimization level on both sources produced byte-identical DXIL at each of
-O1and-O3. Both automatic outputs matched the expected register result across 64 lanes on AMD, with the body both executed and bypassed.Not tested
Retail shaders, retail title runs, DXC or driver timings, and a crossing of the 8 MiB cutoff. The two integration tests were temporary probes.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the probes, ran the checks, and drafted this report.
@Pipodi on GitHub · 2026-11-24 18:11 UTC · original
@nnonno91 thank you. This covers the first point under Not tested: a program that the cap brings under the 1 MiB line.
-O3instead of-O1.So the gain for programs near the line is the higher level, and the cap changes nothing else in the DXIL. The 8 MiB line and timings on retail programs are still open; I'll post them here if I get them.
AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Pipodi on GitHub · 2026-11-24 19:49 UTC · original
@kleborgn thanks for the AMD run.
f578e66passes on its own base, and the same diff onmainc160d86adds exactly one passing test (858 → 859). That covers the suite on AMD, which the PR's Not tested left open. The cap's effect on HLSL size and DXC time was measured only on NVIDIA here. On AMD it is still open.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@DavidM1911 on GitHub · 2026-11-24 20:02 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@LocranKing on GitHub · 2026-11-24 20:03 UTC · original
Independent Windows release verification on NVIDIA RTX 3060 Ti (
f578e661b340463e47e675082619989e669c8713vs basemain9e3831e1f570d3646e53ab753b19ec07eb8f1485).Setup
8024 MiB VRAM, wave32), driver32.0.16.210131.8 GBRAM26200rustc 1.100.0, DXC1.9.2602.17,--releaseWorkspace tests (
cargo test --workspace --release --no-fail-fast -- --test-threads=4)0: 777 passed, 0 failed, 41 ignored across 20 result blocks (SKIPPED: 2no wave64, 2no D3D12 debug layer,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).Regression run (
scripts/smoke.ps1, 60 s,XCL_NETWORK=0, title folder name redacted)main:1566 / 1566frames (100.0%),15676 / 14715 MBpeak commit (106.5%),0device removals,0crashes.Base (
main9e3831e):PR head (
f578e66):Not tested: cold-cache HLSL size/compile-time measurement on the full retail shader pack, AMD / wave64 hardware.
AI use: Antigravity (
Gemini 4 Neon) built and ran the test suite and smoke pair on this hardware and drafted this report from the captured outputs; reviewed before posting. No game files attached.@kleborgn on GitHub · 2026-11-24 19:48 UTC · original · edited 2026-11-24 21:24 UTC
Hardware: AMD Radeon RX 7900 XTX (driver 32.0.32029.2010), Ryzen 9 7950X3D, 32 GB, Windows 11 Pro 10.0.26300, rustc 1.100.0; tests in debug, timings in release. DXC 1.8.2505.32 (Windows SDK 10.0.28000.0).
Tested (AMD), commit
f578e66On its own base:
cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).The same diff applied to
maine9e94ce(applies cleanly): 893 passed, 0 failed, 42 ignored in two full runs (main alone: 892 / 0 / 42). Earlier, onmainc160d86: 859 / 0 / 42 (main alone 858).HLSL size,
xcl shaders <retail shaders.rpf> --export-hlsl DIR --count 40 --min-kb 400with a release build ofmaine9e94ceand one with this PR (same 40 compute programs, 4 windows, native wave64): 50.2 MB -> 47.8 MB (-4.7 %); per program -9.5 % at most, 2 of 40 unchanged, 410 KB to 4.3 MB before. On the 3 files I compared, the HLSL is identical once leading spaces are stripped.DXC time,
xcl shaders ... --measure-pso <record hash> --repeat 1, 3 rounds withmainand this PR interleaved (medians; the-Olevel is the same before and after, none of the 40 crossed 1 MB or 8 MB):a2e35984348fb34eb3618a0fd76af79c6e3fd903765f4376The DXC differences are within the run-to-run spread (about 3 %); the DXIL has the same size.
Not tested
AI use
@DavidM1911 on GitHub · 2026-11-26 05:48 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.