Recompiler: canonicalize split compute pieces and prune unused bindings (#2088) #2711

Open
github-bot wants to merge 1 commit from github-bot/gh-2711 into main AGit
Owner

@⁠ZekkJJ on GitHub · 2026-11-26 07:59 UTC · original
ZekkJJ:dxil/split-piece-canonicalize → main · +1179 −125 · 4 files · 1 commits · draft

Canonicalizes DXIL bitcode emission and prunes statically unused resource bindings on split compute dispatch-chain pieces so semantically identical pieces share identical DXIL containers and driver cache keys.

Part of #2088.

What is in it

  • crates/xcl/src/gpu/dxil/module.rs: deterministic canonical bitcode emission (Module::try_to_canonical_bitcode, BitcodePlan, PlanWalker) scoped to split compute pieces without altering unsplit compute or graphics bitcode.
  • crates/xcl/src/gpu/dxil/shader.rs: Shader::finish_optimized_canonical and Shader::prune_unused_bindings.
  • crates/xcl/src/gpu/dxil/module/split.rs and crates/xcl/src/gpu/dxil/graphics_tests.rs: piece-local static binding pruning in make_piece plus determinism, dynamic indexing, Phi/undef, NaN/-0.0, and GPU parity tests.

Tested

  • Hardware: Windows 11, AMD Ryzen 7 8845HS, NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656), rustc 1.98.1.
  • cargo build --locked --workspace -j 2: passed (0 errors).
  • cargo test --locked -j 2 -p xcl --lib gpu::dxil:: -- --test-threads=1: 189 passed; 0 failed; 3 ignored (34.89s; SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64, ignored dump_dxc_lowering, amd_reduced_seeds, debug_seed).
  • cargo test --locked -j 2 -p xcl --test gpu_compute_e2e -- --test-threads=1: 7 passed; 0 failed; 0 ignored (8.05s; SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).
  • cargo test --locked -j 2 -p xcl --test e2e -- --test-threads=1: 4 passed; 0 failed; 0 ignored (11.89s).
  • git diff --check b49be183..dfead370: passed (0 errors).
  • Offline direct-DXIL compute corpus benchmark (b49be183 vs dfead370, 28 compute units / 50 split pieces / 33 unique PSOs, 3 alternating trials per arm): 0 validation failures across all trials; total serialized piece DXIL dropped from 6,353,292 B to 6,238,132 B (-1.81%).
  • Offline corpus runs on RTX 4060: 30 RDNA2-family compute units (90 pieces -> 32 unique PSO builds, 58 cache hits, 0 validation failures) and 30 captured compute units (52 pieces -> 35 unique PSO builds, 17 cache hits, 0 validation failures).

Regression run

  • Draft PR pending paired scripts/smoke.ps1 execution on an unpacked retail build and full non-DXIL workspace test sweep before marking ready for review.

Not tested

  • Full cargo test --workspace on dfead370 (DXIL library, gpu_compute_e2e, and e2e verified above), paired scripts/smoke.ps1 (no retail title directory on this machine), AMD / Intel hardware, Linux / Wine.

AI use

  • Google Antigravity (Gemini); assisted with implementation, tests, benchmark validation, and PR preparation under author direction.
**@⁠ZekkJJ** on GitHub · 2026-11-26 07:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2711) `ZekkJJ:dxil/split-piece-canonicalize` → `main` · +1179 −125 · 4 files · 1 commits · draft Canonicalizes DXIL bitcode emission and prunes statically unused resource bindings on split compute dispatch-chain pieces so semantically identical pieces share identical DXIL containers and driver cache keys. Part of #2088. **What is in it** - `crates/xcl/src/gpu/dxil/module.rs`: deterministic canonical bitcode emission (`Module::try_to_canonical_bitcode`, `BitcodePlan`, `PlanWalker`) scoped to split compute pieces without altering unsplit compute or graphics bitcode. - `crates/xcl/src/gpu/dxil/shader.rs`: `Shader::finish_optimized_canonical` and `Shader::prune_unused_bindings`. - `crates/xcl/src/gpu/dxil/module/split.rs` and `crates/xcl/src/gpu/dxil/graphics_tests.rs`: piece-local static binding pruning in `make_piece` plus determinism, dynamic indexing, `Phi`/`undef`, NaN/`-0.0`, and GPU parity tests. **Tested** - Hardware: Windows 11, AMD Ryzen 7 8845HS, NVIDIA GeForce RTX 4060 Laptop GPU (driver `32.0.16.1656`), `rustc 1.98.1`. - `cargo build --locked --workspace -j 2`: passed (`0` errors). - `cargo test --locked -j 2 -p xcl --lib gpu::dxil:: -- --test-threads=1`: `189 passed; 0 failed; 3 ignored` (`34.89s`; `SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64`, ignored `dump_dxc_lowering`, `amd_reduced_seeds`, `debug_seed`). - `cargo test --locked -j 2 -p xcl --test gpu_compute_e2e -- --test-threads=1`: `7 passed; 0 failed; 0 ignored` (`8.05s`; `SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`). - `cargo test --locked -j 2 -p xcl --test e2e -- --test-threads=1`: `4 passed; 0 failed; 0 ignored` (`11.89s`). - `git diff --check b49be183..dfead370`: passed (`0` errors). - Offline direct-DXIL compute corpus benchmark (`b49be183` vs `dfead370`, 28 compute units / 50 split pieces / 33 unique PSOs, 3 alternating trials per arm): `0` validation failures across all trials; total serialized piece DXIL dropped from `6,353,292 B` to `6,238,132 B` (`-1.81%`). - Offline corpus runs on RTX 4060: 30 RDNA2-family compute units (`90` pieces -> `32` unique PSO builds, `58` cache hits, `0` validation failures) and 30 captured compute units (`52` pieces -> `35` unique PSO builds, `17` cache hits, `0` validation failures). **Regression run** - Draft PR pending paired `scripts/smoke.ps1` execution on an unpacked retail build and full non-DXIL workspace test sweep before marking ready for review. **Not tested** - Full `cargo test --workspace` on `dfead370` (DXIL library, `gpu_compute_e2e`, and `e2e` verified above), paired `scripts/smoke.ps1` (no retail title directory on this machine), AMD / Intel hardware, Linux / Wine. **AI use** - Google Antigravity (`Gemini`); assisted with implementation, tests, benchmark validation, and PR preparation under author direction.
Part of #2088

Restrict bitcode declaration compaction/canonicalization to split compute dispatch pieces (Module::try_to_canonical_bitcode + Shader::finish_optimized_canonical) so unsplit graphics and whole compute shaders preserve exact upstream bitcode while semantically identical pieces share identical DXIL containers and driver cache keys.

Additionally prune statically unreferenced dx.resources / PSV0 bindings in each piece when all dx.op.createHandleFromBinding calls use constant ResBind operands, preserving dynamic indexing, wave64 metadata, NaN/-0.0 bit patterns, and static sampler register mappings.

Co-Authored-By: Gemini 4 Hydrogen <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:03:36 +00:00
Author
Owner

@⁠Lum7nt on GitHub · 2026-11-26 09:03 UTC · original

Tested on \dfead3702a\ (\dfead370, clean PR head):

  • Hardware / OS / Toolchain: NVIDIA GeForce RTX 3060 12 GB (driver \32.0.15.8142\ / 581.42, wave32), Intel Core i5-10400, Windows 11 (NT \10.0.22631.0),
    ustc 1.100.0\ (\x86_64-pc-windows-msvc), DXC \1.8.2502.11\ (Windows SDK \10.0.26100.0), debug profile, \XCL_ADAPTER=nvidia.
  • Focused run (\cargo test -p xcl --lib gpu::dxil:: -- --test-threads=1): 189 passed, 0 failed, 3 ignored (\1149 filtered out; 1 \SKIPPED: \gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64).
  • Workspace suite (\cargo test --workspace --no-fail-fast -- --test-threads=4): 1425 passed, 5 failed, 47 ignored (1312 lib + 113 integration; +5 passed over \origin/main\ \49be183's 1420 passed / 5 failed / 47 ignored).
    • The 5 failures are the same 5 pre-existing \ID3D12PipelineState::GetCachedBlob()\ failures observed on \origin/main\ \49be183\ on this driver/setup (\passthrough_mesh_stream_accepts_a_triangle_driver_blob, \split_compute_program_prebuilds_and_caches_chain_pieces, \split_compute_prefers_the_offline_whole_pipeline, \offline_compute_pipeline_is_reused_by_a_second_process, \offline_split_compute_pipeline_is_reused_by_a_second_process).
    • \SKIPPED\ checks: 20
      o wave64, 3 per-lane #1426\ refusals, 2 no D3D12 debug layer, 1 \cannot disable the driver cache (0x887A002D), 1
      o heap windows.

Not tested

  • Native wave64 / AMD / Intel GPUs, Linux / Wine, \XCL_SAMPLE_*\ tests (unset), and \scripts/smoke.ps1\ (no retail title folder here).

AI use

  • Antigravity (\Gemini 4 Hydrogen (Low)) checked out \dfead370, ran \gpu::dxil::\ and the workspace suite on this machine, and drafted this report.
**@⁠Lum7nt** on GitHub · 2026-11-26 09:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7187350424) **Tested** on \dfead3702a1e8c3b6b30afeccf51efc1e885b10b\ (\dfead370\, clean PR head): - **Hardware / OS / Toolchain:** NVIDIA GeForce RTX 3060 12 GB (driver \32.0.15.8142\ / 581.42, wave32), Intel Core i5-10400, Windows 11 (NT \10.0.22631.0\), \ ustc 1.100.0\ (\x86_64-pc-windows-msvc\), DXC \1.8.2502.11\ (Windows SDK \10.0.26100.0\), debug profile, \XCL_ADAPTER=nvidia\. - **Focused run (\cargo test -p xcl --lib gpu::dxil:: -- --test-threads=1\):** **189 passed, 0 failed, 3 ignored** (\1149 filtered out\; 1 \SKIPPED\: \gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64\). - **Workspace suite (\cargo test --workspace --no-fail-fast -- --test-threads=4\):** **1425 passed, 5 failed, 47 ignored** (1312 lib + 113 integration; +5 passed over \origin/main\ \49be183\'s 1420 passed / 5 failed / 47 ignored). - The 5 failures are the same 5 pre-existing \ID3D12PipelineState::GetCachedBlob()\ failures observed on \origin/main\ \49be183\ on this driver/setup (\passthrough_mesh_stream_accepts_a_triangle_driver_blob\, \split_compute_program_prebuilds_and_caches_chain_pieces\, \split_compute_prefers_the_offline_whole_pipeline\, \offline_compute_pipeline_is_reused_by_a_second_process\, \offline_split_compute_pipeline_is_reused_by_a_second_process\). - \SKIPPED\ checks: 20 \ o wave64\, 3 per-lane \#1426\ refusals, 2 no D3D12 debug layer, 1 \cannot disable the driver cache (0x887A002D)\, 1 \ o heap windows\. **Not tested** - Native wave64 / AMD / Intel GPUs, Linux / Wine, \XCL_SAMPLE_*\ tests (unset), and \scripts/smoke.ps1\ (no retail title folder here). **AI use** - Antigravity (\Gemini 4 Hydrogen (Low)\) checked out \dfead370\, ran \gpu::dxil::\ and the workspace suite on this machine, and drafted this report.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2711/head:github-bot/gh-2711'
git switch 'github-bot/gh-2711'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2711'
git switch 'github-bot/gh-2711'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2711'
git switch 'github-bot/gh-2711'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2711'
git switch 'main'
git merge --squash 'github-bot/gh-2711'
git switch 'main'
git merge --ff-only 'github-bot/gh-2711'
git switch 'main'
git merge 'github-bot/gh-2711'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.