Repository navigation
Recompiler: compress per-class branch targets in direct DXIL compact - #2356
safesearch77 wants to merge 1 commit into
Conversation
Replaces the global two-word-per-pair xcl_steps offset table in gpu::dxil::compact with per-class sorted (Leg::Abs, Leg::Rel) palettes and bounded select/cond_br trees (SELECT_LEAF_MAX = 32), capping both words() and palette_len() at MAX_TABLE_WORDS and keeping ordinary programs on their current route (xcl-dev#2088).
2707887 to
ff97165
Compare
|
AMD Windows driver timing for #2356: on the RX 9070 XT this changes only the two programs Setup
Method
Census (all 2,689 retail compute programs, translation only): 2 programs change, both smaller. ActivateRays (
Read / inference
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the census and measurements and drafted this. Counts and timings only, no game data. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Every DXC compile of the generated HLSL prelude fails: The parameter name — Devin |
|
Tested: current PR head merged onto current 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
left a comment
There was a problem hiding this comment.
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.
Implements #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 Recompiler: direct compact form stores a branch's target in the entry #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.