Skip to content

Recompiler: encode direct DXIL with bitcode abbreviations - #3250

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
Foniass:dxil-bitcode-abbrevs
Nov 29, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
Foniass:dxil-bitcode-abbrevs

Conversation

@Foniass

@Foniass Foniass commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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 LLVM DEFINE_ABBREV records 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 one CST_CODE_DATA record 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 f089a9df comes 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_width
  • crates/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 (09a65d6) is kept, and the shrink commit's own pruning is left out
  • crates/xcl/src/gpu/dxil/compact.rs: compact tables through const_data_i32
  • crates/xcl/src/gpu/dxil/bitreader_tests.rs: the test reader decodes abbreviated records; new abbreviated_records_decode_to_the_plain_layout; module.rs's symtab_names test helper uses this reader instead of its own, which only read unabbreviated records

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc); tests in debug, measurements and smoke runs in release
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on e13ccd7: 2605 passed, 4 failed, 49 ignored
    • the 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3: CreateComputePipelineState returns E_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.
    • SKIPPED GPU tests: 30, almost all no wave64; also two_pass_binds_set_the_shared_view_heap (no heap windows) and pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache)
  • Retail title's shaders.rpf, xcl shaders --direct --sample 300 --seed 1 --validate, main (b10cc4c) against this PR:
    • same coverage on both (146 of 252 translated, 0 validator failures)
    • the 146 translated programs: 8.27 MB to 5.97 MB of DXIL (median 1.38x smaller, range 1.03x to 1.46x)
    • the two largest compute programs: 95cc13288a27a96e 1215 KB to 804 KB, 958400d2caf07244 612 KB to 415 KB
  • Cold driver pipeline build of the 6 largest compute programs (xcl shaders --precompile --only cs --pipelines --records <12 hashes> --threads 1, fresh XCL_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.
  • The PR's first smoke run hit the script's startup limit: new DXIL bytes mean the title's shader preparation rebuilds every pipeline (about 24 min cold on this machine). The run below is after that preparation, against a main run whose caches were warm too.

Regression run

main:

xcl-smoke v1
commit: b10cc4c6766adc947c2054ada4a2af98be15108d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16026 MB

this PR:

xcl-smoke v1
commit: e13ccd7fff4d29f7382e56d0df44a65154710a5f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15987 MB

Not tested

  • AMD GPUs and wave64 hardware (the abbreviated bitcode was checked by DXC's validator and the NVIDIA driver only)
  • Whether the image looks the same: the smoke run counts frames and nobody compared screenshots
  • Titles other than this one

400 + 61 changed lines, about 150 of them tests.

AI use

  • Claude Code with Claude Opus 5.5: split this part out of f089a9df, merged it with main's pruning, wrote the decode test and the symtab_names change, ran the tests, measurements and smoke runs above, and wrote this description
  • The original bitcode-encoding code is from amd-dev's f089a9df (raylitebull, cherry-picked from 46aecbf7, written with Antigravity (Gemini 4 Neon High))

🤖 Generated with Claude Code

The direct DXIL writer emitted every record unabbreviated, so each
operand took a full 6-bit VBR chunk plus the record header. Define LLVM
DEFINE_ABBREV records for the hot function-block opcodes (binop without
flags, cast, cmp2, vselect, extractval, 4-byte-aligned load / store, br,
call, phi, gep) and for integer / f32 constants, and write the compact
form's lookup tables as one CST_CODE_DATA record instead of an aggregate
of interned integer constants. The records decode to the same operands,
so the module means the same; only its encoding is smaller.

Measured on the retail title with an RTX 5070 Ti (numbers in the PR).

Ported from the bitcode-encoding part of amd-dev's f089a9d (cherry
picked there from 46aecbf, raylitebull, Assisted-by: Antigravity
(Gemini 4 Neon High)). Left out here: its dead-constant pruning (main
already prunes, 09a65d6) and its IR / compact-form changes, which
follow separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: fa20459
head: e13ccd7
merge: 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 --lib rerun skipping the 2 known main #3187 uma_driver mixed-window tests a_refused_gpu_upload_segment_becomes_custom and mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) -> 2620 passed, 0 failed, 49 ignored (2481 lib + 139 integration, 25 SKIPPED notices; all 4 fuzz_validate_and_gpu_0..3 passed); failing: none. Also verified standalone: 233/233 gpu::dxil:: (incl. 5/5 bitreader_tests and 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 (1755 frames, 0 removals, 0 crashes). 150 s xcl-smoke (ea3b5e4d, XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack: exit: 0x0, 2096 frames shown, 0 device removals, 0 crashes, 0 display System events, 32049 MB peak commit.
review: none (whole diff read: LLVM DEFINE_ABBREV encodings for hot function-block opcodes + scalar constants and CST_CODE_DATA compact 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.

@KOLESNiii KOLESNiii 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.

Static review of e13ccd7f for 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.

@KOLESNiii

Copy link
Copy Markdown
Contributor

Test run data for the static review

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.

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

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants