Recompiler: compress per-class branch targets in direct DXIL compact #2356
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!2356
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2356"
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?
@safesearch77 on GitHub · 2026-11-25 16:29 UTC · original
safesearch77:feat/dxil-compact-target-compression→main· +313 −63 · 2 files · 1 commits · closed without mergingImplements #2088 Workstream 2 in the direct-DXIL compact planner (
crates/xcl/src/gpu/dxil/compact.rs), porting#1448's per-class bounded branch-target selection so large repeating compute shaders with shared branch targets or varied per-class branch distances fit within the existingMAX_TABLE_WORDS = 8,192table budget without storing twoxcl_stepswords per distinct global offset pair.Part of #2088
Part of #1269
What is in it
crates/xcl/src/gpu/dxil/compact.rs:xcl_stepsoffset-pair table (2words per globally distinct(t - b, f - b)pair) with per-class sorted(Leg, Leg)transition palettes (Leg::Abs(block)vsLeg::Rel(offset)chosen per leg by intra-class frequency, preferringAbson ties so singleton classes emit constants withoutadds).(class | choice << cb)intoxcl_blocksalone (pb = 0bits when every class has a single transition), removing the twoxcl_stepsglobal loads fromhead.emit_nextusing balanced branchlessselecttrees (with a singleaddper pure-Relleaf) up toSELECT_LEAF_MAX = 32, splitting larger per-class target lists (many_targets) with a topological binarycond_br+ 2-inputphitree so every basic block stays within<= 32selects and nested dispatch (#2174) preserves its bounded latch fan-in.large(cfg) >= 20,000,once * 10 < all * 3, andMAX_TABLE_WORDS = 8,192unchanged, and gateswanted()on bothp.words() <= MAX_TABLE_WORDSandp.palette_len() <= MAX_TABLE_WORDSso ordinary programs remain on their current route and total palette IR stays bounded.crates/xcl/src/gpu/dxil/compact_tests.rs:pathological_shared_exits_compress_and_keep_ordinary_programs_plain: verifies a 4,200-block shared-exit program (10,373table words and rejected onmain) compresses to264words (326,772 Bplain ->3,692 Bcompact DXIL) and becomes automatically eligible, while< 20,000-instruction and non-repeating programs stay plain.wanted_rejects_excessive_palette_entries_even_when_block_table_fits: verifieswanted()refuses a program whosep.words()(4,783) fits underMAX_TABLE_WORDSwhenp.palette_len()(10,201) exceedsMAX_TABLE_WORDS.many_targets_bounds_select_leaves_and_steps_match_cfg: verifiesPlan::pack_blocks+Plan::stepagainstCfgacross all reachable blocks on an 80-target class and checks that no lowered basic block exceedsSELECT_LEAF_MAX = 32selects.gpu_target_compressed_and_many_targets_run_as_plain: checks GPU register parity (sgpr,vgpracross 64 lanes,scc) forshared_exits(60)andmany_targets(80)inNest::FlatandNest::Fixed(4)against plain DXIL.Tested
x86_64-unknown-linux-gnu/ cross-check targetx86_64-pc-windows-gnu), base68a284a(rebased onto #2076), headff97165.cargo check --offline --target x86_64-pc-windows-gnu --workspace --tests: exit 0 (0errors,0warnings ingpu::dxil).gpu::dxil::compact_tests(on06c9f55base, re-typechecked on68a284a): 12 passed, 0 failed (4gpu_*tests cleanlySKIPPED: no GPU).wave64 = true, split = true, mem_windows = 1,0829441->ff97165):shared_exits(1000):2,379->64words (-97.3%), forced-compact DXIL13,044->3,540 B(-72.9%).shared_exits(4200):10,373->264words (wanted:false->true),translate_fullDXIL326,772->3,692 B(-98.9%).multi_cls_outlier(5000)(603classes,5,001pairs):13,598->1,564words (wanted:false->true),translate_fullDXIL394,664->52,580 B(-86.7%).Not tested
gpu_target_compressed_and_many_targets_run_as_plainand DXCdxcompiler.dllIDxcValidatorvalidation (developed and typechecked on Linux without a Windows GPU host; opened as Draft until Windows GPU suite andscripts/smoke.ps1regression runs are attached).CreateComputePipelineStatetimings and DXIL byte counts on the 76,699-instruction retail compute outlier (XCL_DIRECT_DXIL=1/XCL_DIRECT_DXIL=all).AI use
compact.rsand tests incompact_tests.rs; reviewed with Claude Opus 5.5.@bielfreedom on GitHub · 2026-11-25 17:57 UTC · original
AMD Windows driver timing for #2356: on the RX 9070 XT this changes only the two programs
mainalready compacts. One of them builds about 1.5× slower in AMD's driver.Setup
0829441;2707887.fnv64) and per-CreateComputePipelineStatetime.Method
XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=0,XCL_PIPELINE_THREADS=1.XCL_PSO_DISK_CACHE=0and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name.Census (all 2,689 retail compute programs, translation only): 2 programs change, both smaller. ActivateRays (
95cc13288a27a96e) stays plain on this adapter, 2,420,640 B, as onmain.56c0cd3b82a00c6eActivateProbes958400d2caf07244ActivateProbesTargetRead / inference
xcl_stepstable on 64-lane-wave GPUs, like the #2076 guard did.Not tested
XCL_HEAP_WINDOWS=1.AI use: Claude Code (Claude Opus 5.5) ran the census and measurements and drafted this. Counts and timings only, no game data.
@DavidM1911 on GitHub · 2026-11-25 18:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 143 real failures, deterministic (also fail--test-threads=1, 1064/143):Every DXC compile of the generated HLSL prelude fails:
The parameter name
snormcollides with the HLSLsnormtexture modifier keyword — rename it (e.g.signed_norm) and the whole suite should recover. Serious breakage, needs a fix before merge.— Devin
@SlopTart on GitHub · 2026-11-25 19:06 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).suite: 145/3 = the three known baseline failures on this lane (
fuzz_validate_and_gpu_2seed 1003,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed). Targeted run of the two new budget tests: 2 passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
@bmjask on GitHub · 2026-11-25 20:45 UTC · original · reviewed
No confirmed source-level compact-palette/selection defect found, but this is not merge-ready. Current PR-description checks fail and there is no Windows GPU/DXC-validator/smoke evidence. An RX 9070 XT measurement shows one changed shader regressing from 14.8s to 22.1s driver build time (+49%) despite smaller DXIL; investigate or gate native-wave64 AMD behavior (for example retain xcl_steps) before merge. Do not attribute reported snorm DXC failures without reproduction: discussion identifies that as a separate base/prelude issue.
@safesearch77 on GitHub · 2026-11-26 14:07 UTC · original
Closing this draft: as @bielfreedom and @bmjask measured on RX 9070 XT, compressing per-class branch targets here regresses AMD driver PSO compile time on one of the two affected shaders (14.8s -> 22.1s, +49%), and #2076 / #2257 have since landed cleaner compact-nesting changes on main. Thanks to @bielfreedom, @DavidM1911, @SlopTart, and @bmjask for the testing and review!
Pull request closed