Recompiler: encode direct DXIL with bitcode abbreviations #3250

Merged
Foniass merged 1 commit from upstream-pr/3250 into main 2026-11-29 22:19:57 +00:00
Foniass commented 2026-11-29 00:56:58 +00:00 (Migrated from github.com)

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 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 (09a65d63) 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 e13ccd7f: 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 (b10cc4c6) 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

<!-- greyfinch-sync:ivall/xcl:issue:5546228201 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3250). Originally posted by [Foniass](https://github.com/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 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 (09a65d63) 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 e13ccd7f: 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 (b10cc4c6) 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](https://claude.com/claude-code)
Kalmarv commented 2026-11-29 03:23:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:00Z.


merge-check
base: fa204595a4
head: e13ccd7fff
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.

<!-- greyfinch-sync:ivall/xcl:comment:7250014041 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3250#issuecomment-7250014041). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T03:23:00Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: e13ccd7fff4d29f7382e56d0df44a65154710a5f 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 commented 2026-11-29 22:39:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:20Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ivall/xcl:review:6105175006 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3250#pullrequestreview-6105175006). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T22:39:20Z. **Review:** COMMENTED --- Static review of `e13ccd7f` for the stack in the [#3041 comparison](https://github.com/xcl-dev/xcl/issues/3041#issuecomment-7263214809). 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 commented 2026-11-29 22:54:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:54:45Z.


Test run data for the static review

  • The earlier local trial merge 90e952bb included this PR and #3261 and #3263. cargo test --workspace --no-fail-fast -- --test-threads=4 finished 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 run
  • Kalmarv separately reports 233/233 in the standalone gpu::dxil:: group, including 5/5 bitreader tests and 4/4 fuzz tests. Independent run
  • Fresh local cargo build --workspace passed on the actual upstream merge b129968a. The test binaries built with cargo test --workspace --no-fail-fast --no-run and 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.

<!-- greyfinch-sync:ivall/xcl:comment:7264046524 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3250#issuecomment-7264046524). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T22:54:45Z. --- **Test run data for the [static review](https://github.com/xcl-dev/xcl/pull/3250#pullrequestreview-6105175006)** - The earlier local trial merge `90e952bb` included this PR and #3261 and #3263. `cargo test --workspace --no-fail-fast -- --test-threads=4` finished 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 run](https://github.com/xcl-dev/xcl/pull/3263#issuecomment-7261674407) - Kalmarv separately reports **233/233** in the standalone `gpu::dxil::` group, including **5/5** bitreader tests and **4/4** fuzz tests. [Independent run](https://github.com/xcl-dev/xcl/pull/3250#issuecomment-7250014041) - Fresh local `cargo build --workspace` passed on the actual upstream merge `b129968a`. The test binaries built with `cargo test --workspace --no-fail-fast --no-run` and 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3250
No description provided.