Recompiler: encode direct DXIL with bitcode abbreviations #3250
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3250"
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?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T00:56:58Z.
First part of moving amd-dev's direct DXIL size work (
f089a9df, "shrink emitted shaders 4.5x-5.4x") to main, split up as CONTRIBUTING asks. This part changes only how the direct DXIL writer encodes the module. It defines LLVMDEFINE_ABBREVrecords for the most-used function-block records (binop without flags, cast, cmp2, vselect, extractval, 4-byte load / store, br, call, phi, gep) and for integer / f32 constants. The compact form's lookup tables become oneCST_CODE_DATArecord instead of an aggregate of interned integers. The records decode to the same operands as before, so the module means the same thing; it is only smaller.The rest of
f089a9dfcomes in separate PRs: the compact-form micro-blocks and liveness, and the IR optimizations, which build on #1818. On amd-dev's own history, the whole commit took the RTX 5070 Ti's cold pipeline build for the 6 largest compute programs from 31.9 s to 21.4 s. This part alone does not change that much (below): its gain is file size.What is in it
crates/xcl/src/gpu/dxil/bitstream.rs:AbbrevOp,define_abbrev,emit_abbrev,enter_block_with_widthcrates/xcl/src/gpu/dxil/module.rs: the function-block abbreviations (block abbrev width 4) and the constant ones,ConstDef::DataI32/const_data_i32; main's dead-constant pruning (09a65d63) is kept, and the shrink commit's own pruning is left outcrates/xcl/src/gpu/dxil/compact.rs: compact tables throughconst_data_i32crates/xcl/src/gpu/dxil/bitreader_tests.rs: the test reader decodes abbreviated records; newabbreviated_records_decode_to_the_plain_layout;module.rs'ssymtab_namestest helper uses this reader instead of its own, which only read unabbreviated recordsTested
cargo test --workspace --no-fail-fast -- --test-threads=4one13ccd7f: 2605 passed, 4 failed, 49 ignoredgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3:CreateComputePipelineStatereturnsE_OUTOFMEMORY(0x8007000E) on this card, and they fail the same way on main. They pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code.no wave64; alsotwo_pass_binds_set_the_shared_view_heap(no heap windows) andpso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache)shaders.rpf,xcl shaders --direct --sample 300 --seed 1 --validate, main (b10cc4c6) against this PR:95cc13288a27a96e1215 KB to 804 KB,958400d2caf07244612 KB to 415 KBxcl shaders --precompile --only cs --pipelines --records <12 hashes> --threads 1, freshXCL_DXIL_CACHE): 51.3 s on main, 49.3 s here. The driver re-encodes the module, so the smaller bitcode barely changes its compile time.Regression run
main:
this PR:
Not tested
400 + 61 changed lines, about 150 of them tests.
AI use
f089a9df, merged it with main's pruning, wrote the decode test and thesymtab_nameschange, ran the tests, measurements and smoke runs above, and wrote this descriptionf089a9df(raylitebull, cherry-picked from46aecbf7, written with Antigravity (Gemini 4 Neon High))🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:00Z.
merge-check
base:
fa204595a4head:
e13ccd7fffmerge: clean (both standalone on main and in the 7-PR stack).
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: tested in the clean 7-PR stack (#3250+#3261+#3263+#3264+#3265+#3266+#3268) on main
fa204595:cargo test --workspace --no-fail-fast -- --test-threads=4(DXC 1.9.2609.5;-p xcl --librerun skipping the 2 knownmain#3187uma_drivermixed-window testsa_refused_gpu_upload_segment_becomes_customandmixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4fuzz_validate_and_gpu_0..3passed); failing: none. Also verified standalone: 233/233gpu::dxil::(incl. 5/5bitreader_testsand 4/4 fuzz), DXC 1.9 corpus sweeps (--sample 300 --seed 1: 135/238, 0 errors;--sample 1000 --seed 2: 448/806, 0 errors), and standalone 150 s smoke (1755frames,0removals,0crashes). 150 sxcl-smoke(ea3b5e4d,XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack:exit: 0x0,2096frames shown,0device removals,0crashes,0display System events,32049 MBpeak commit.review: none (whole diff read: LLVM
DEFINE_ABBREVencodings for hot function-block opcodes + scalar constants andCST_CODE_DATAcompact tables decode to identical IR; bitreader tests cover round-trip).performance: positive: ~1.4x smaller direct DXIL and faster validation (p50 4.03 -> 3.46 ms, p95 76.14 -> 53.30 ms on 300-shader sweep); no frame-time or memory regression.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:20Z.
Review: COMMENTED
Static review of
e13ccd7ffor the stack in the #3041 comparison.I found no actionable issue in the tested bitcode abbreviation and constant-table encoding changes.
Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:54:45Z.
Test run data for the static review
90e952bbincluded this PR and #3261 and #3263.cargo test --workspace --no-fail-fast -- --test-threads=4finished with 2,743 passed, 0 failed, 49 ignored and 28 SKIPPED notices (22 no wave64, three unsupported wave32 per-lane forms, two no heap windows, and one no GPU_UPLOAD heaps). Original rungpu::dxil::group, including 5/5 bitreader tests and 4/4 fuzz tests. Independent runcargo build --workspacepassed on the actual upstream mergeb129968a. The test binaries built withcargo test --workspace --no-fail-fast --no-runand the GPU suite is queued.Local system used for these runs was an RTX 2070 SUPER 8 GB (621.40, wave32), Ryzen 5 3600XT, 32 GB RAM, Windows 11 build 26300, and rustc 1.100.1. Claude Code (Claude Opus 5.5) ran the earlier tests. Codex (GPT-6, exact variant unavailable) checked the artifacts and ran the new build.