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

Open
ZekkJJ wants to merge 1 commit from upstream-pr/2711 into main
ZekkJJ commented 2026-11-26 07:59:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ZekkJJ on 2026-11-26T07:59:50Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5506205770 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711). Originally posted by [ZekkJJ](https://github.com/ZekkJJ) on 2026-11-26T07:59:50Z. --- 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.
Lum7nt commented 2026-11-26 09:07:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-26T09:03:05Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7187350424 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7187350424). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-26T09:03:05Z. --- **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.
Prime1997 commented 2026-11-26 11:49:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-26T11:49:48Z.

Review: COMMENTED


Read-through and GPU run of dfead370. An AI tool (Claude Code) helped with the reading and ran the tests; each point below was checked against the code at this head.

Test results (RTX 3060 Ti 8 GB, NVIDIA 617.14 / 32.0.16.1714, i5-10400, Windows 11 26200.9974, rustc 1.100.0, DXC 1.9.2609.5, debug, isolated cache and data roots):
cargo test --lib gpu::dxil:: -- --test-threads=4: 189 passed, 0 failed, 3 ignored. One test reported SKIPPED (dispatch_chain_native_wave64_builds_whole, this card has no wave64). The GPU halves of the tests ran.

Points for the author

  1. The .chain.pso name does not include the root signature or static samplers, and pruning now makes the pieces sampler-agnostic. I could not confirm how a driver reacts when a cached blob made under one sampler set is offered to a pipeline with another. If the answer is "it refuses and we rebuild", that is fine, but it would be good to have a test that shows it, or the sampler set in the name.
  2. Every existing piece blob goes cold once after this change, because the canonical form changes the hash. Expected, but worth saying in the description so people do not report the one-time rebuild as a regression.
  3. The description gives the counts after the change (for example 90 pieces to 32 unique builds) and the DXIL size before and after, but not the unique-pipeline count for the same corpus on main, and no compile time. That one comparison would make the benefit reviewable.
  4. Nit: the canonical writer gains several expect() calls. As far as I can tell a panic there comes back as an Err from the translator thread's join rather than taking the process down, but returning the error directly would be clearer.
  5. A few of the new tests assert less than their names promise. Worth a pass to make each one fail when the behaviour in its name is removed.

I did not find a defect. The reach looks narrow (only programs that are actually split), so points 1 and 3 are what I would want answered before this leaves draft.


Generated by Claude Code

<!-- greyfinch-sync:ivall/xcl:review:6073633875 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#pullrequestreview-6073633875). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-26T11:49:48Z. **Review:** COMMENTED --- Read-through and GPU run of dfead370. An AI tool (Claude Code) helped with the reading and ran the tests; each point below was checked against the code at this head. **Test results** (RTX 3060 Ti 8 GB, NVIDIA 617.14 / 32.0.16.1714, i5-10400, Windows 11 26200.9974, rustc 1.100.0, DXC 1.9.2609.5, debug, isolated cache and data roots): `cargo test --lib gpu::dxil:: -- --test-threads=4`: 189 passed, 0 failed, 3 ignored. One test reported SKIPPED (`dispatch_chain_native_wave64_builds_whole`, this card has no wave64). The GPU halves of the tests ran. **Points for the author** 1. The `.chain.pso` name does not include the root signature or static samplers, and pruning now makes the pieces sampler-agnostic. I could not confirm how a driver reacts when a cached blob made under one sampler set is offered to a pipeline with another. If the answer is "it refuses and we rebuild", that is fine, but it would be good to have a test that shows it, or the sampler set in the name. 2. Every existing piece blob goes cold once after this change, because the canonical form changes the hash. Expected, but worth saying in the description so people do not report the one-time rebuild as a regression. 3. The description gives the counts after the change (for example 90 pieces to 32 unique builds) and the DXIL size before and after, but not the unique-pipeline count for the same corpus on main, and no compile time. That one comparison would make the benefit reviewable. 4. Nit: the canonical writer gains several `expect()` calls. As far as I can tell a panic there comes back as an `Err` from the translator thread's `join` rather than taking the process down, but returning the error directly would be clearer. 5. A few of the new tests assert less than their names promise. Worth a pass to make each one fail when the behaviour in its name is removed. I did not find a defect. The reach looks narrow (only programs that are actually split), so points 1 and 3 are what I would want answered before this leaves draft. --- _Generated by Claude Code_
safesearch77 commented 2026-11-26 15:03:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by safesearch77 on 2026-11-26T14:10:05Z.


Reviewed dfead370 against main (b49be183). Non-split bitcode preservation (BitcodePlan::unsplit)
and the referenced_bindings / PSV0 renumbering check out, with a few concrete catches:

  1. Feature::TiledResources leaks from piece 0 into downstream pieces, and infer_piece_features
    still runs before dst.m.optimize() (split.rs:270-303).

    • Shader::dispatch_piece (shader.rs:169) clones self.features into every piece, and
      infer_piece_features (split.rs:284-303) strips Doubles, Int64Ops, DoubleExtensions,
      ResourceHeapIndexing, SamplerHeapIndexing, and TypedUavLoadAdditionalFormats, but never
      clears Feature::TiledResources
      (1 << 12 in dx.entryPoints flags, 0x100 in SFI0),
      which clamp_arg (ops.rs:882) sets on any Sample / SampleBias / SampleGrad / SampleCmp
      with Some(min_lod).
    • Consequently, if piece 0 samples with a min-LOD clamp (sample_grad(..., Some(min_lod))) and a
      downstream piece does not, prune_unused_bindings removes the texture and sampler bindings from
      the downstream piece while leaving TiledResources (0x100) set in its SFI0 and entry flags —
      so two shaders with identical downstream pieces still emit different containers (SFI0 0x4100
      vs 0x4000, different driver_cache::name_for keys) and claim TiledResources on a piece with
      no texture bindings.
    • Likewise, make_piece inlined dst.m.optimize() (split.rs:277) below dst.infer_piece_features()
      (split.rs:270), and infer_piece_features walks all of self.m.insts rather than reachable
      blocks (block_layout().0), so a createHandleFromHeap or UAV textureLoad eliminated by
      dst.m.optimize() still leaves its feature flag set on the piece. Running infer_piece_features
      after dst.m.optimize() over reachable blocks and clearing TiledResources when no surviving
      call uses a clamp/status fixes both.
  2. Two vacuous assertions in canonical_bitcode_drops_unreachable_phi_operands_and_distinguishes_undef
    (split.rs:1443, 1469-1490).

    • use_undef compares s.raw_store(out, off, &[merged]) (1 dword, write mask 1) against
      s.raw_store(out, off, &[merged, zero]) (2 dwords, write mask 3). Shader::raw_store
      (shader.rs:363-375) always passes i32 undef for offset1 and unused value lanes, so
      disassemble(&clean_undef).unwrap().contains("undef") is true for clean_zero as well, and
      assert_ne!(clean_zero, clean_undef) passes because the write mask differs (i8 1 vs i8 3),
      not because undef was distinguished from 0 (passing &[merged, undef_i32] vs &[merged, zero]
      keeps mask 3 on both).
    • Line 1487 checks !dis.contains("-1158620499") && !dis.contains("3134250669") for 0xBAD0_DEAD
      (line 1443), whose signed i32 decimal is -1160716627 (0xBAD0_DEADu32 as i32; -1158620499
      is 0xBAF0_DAAD), so DXC disassembly would never match either string on a leak.
  3. Cleanup / scope nits:

    • Leftover debug println!("CANON_PIECE1 ...") at split.rs:1279-1287, and the test name
      graphics_bitcode_canonicalizes_unused_decls_and_preserves_resources (graphics_tests.rs:1241)
      still says canonicalizes after narrowing graphics back to BitcodePlan::unsplit.
    • At +1,179/-125 (1,304 changed lines, over the ~800-line guideline in CONTRIBUTING.md),
      splitting BitcodePlan canonical bitcode emission and referenced_bindings + prune_unused_bindings
      into a 2-PR stack would make each piece much smaller to review.

Checked with cargo check --tests (x86_64-pc-windows-gnu) and a host-side rustc --test harness on
gpu/dxil (reproducing SFI0 0x4100 vs 0x4000); no Windows DXC validator or GPU run.

AI use: Antigravity (Claude Sonnet 5.5, Gemini 4 Carbon) audited the diff and ran the host reproduction;
I re-checked each point against the source before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7194371664 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7194371664). Originally posted by [safesearch77](https://github.com/safesearch77) on 2026-11-26T14:10:05Z. --- Reviewed `dfead370` against `main` (`b49be183`). Non-split bitcode preservation (`BitcodePlan::unsplit`) and the `referenced_bindings` / `PSV0` renumbering check out, with a few concrete catches: 1. **`Feature::TiledResources` leaks from piece 0 into downstream pieces, and `infer_piece_features` still runs before `dst.m.optimize()` (`split.rs:270-303`).** - `Shader::dispatch_piece` (`shader.rs:169`) clones `self.features` into every piece, and `infer_piece_features` (`split.rs:284-303`) strips `Doubles`, `Int64Ops`, `DoubleExtensions`, `ResourceHeapIndexing`, `SamplerHeapIndexing`, and `TypedUavLoadAdditionalFormats`, **but never clears `Feature::TiledResources`** (`1 << 12` in `dx.entryPoints` flags, `0x100` in `SFI0`), which `clamp_arg` (`ops.rs:882`) sets on any `Sample` / `SampleBias` / `SampleGrad` / `SampleCmp` with `Some(min_lod)`. - Consequently, if piece 0 samples with a min-LOD clamp (`sample_grad(..., Some(min_lod))`) and a downstream piece does not, `prune_unused_bindings` removes the texture and sampler bindings from the downstream piece while leaving `TiledResources` (`0x100`) set in its `SFI0` and entry flags — so two shaders with identical downstream pieces still emit different containers (`SFI0` `0x4100` vs `0x4000`, different `driver_cache::name_for` keys) and claim `TiledResources` on a piece with no texture bindings. - Likewise, `make_piece` inlined `dst.m.optimize()` (`split.rs:277`) below `dst.infer_piece_features()` (`split.rs:270`), and `infer_piece_features` walks all of `self.m.insts` rather than reachable blocks (`block_layout().0`), so a `createHandleFromHeap` or UAV `textureLoad` eliminated by `dst.m.optimize()` still leaves its feature flag set on the piece. Running `infer_piece_features` after `dst.m.optimize()` over reachable blocks and clearing `TiledResources` when no surviving call uses a clamp/status fixes both. 2. **Two vacuous assertions in `canonical_bitcode_drops_unreachable_phi_operands_and_distinguishes_undef` (`split.rs:1443, 1469-1490`).** - `use_undef` compares `s.raw_store(out, off, &[merged])` (1 dword, write mask `1`) against `s.raw_store(out, off, &[merged, zero])` (2 dwords, write mask `3`). `Shader::raw_store` (`shader.rs:363-375`) always passes `i32 undef` for `offset1` and unused value lanes, so `disassemble(&clean_undef).unwrap().contains("undef")` is true for `clean_zero` as well, and `assert_ne!(clean_zero, clean_undef)` passes because the write mask differs (`i8 1` vs `i8 3`), not because `undef` was distinguished from `0` (passing `&[merged, undef_i32]` vs `&[merged, zero]` keeps mask `3` on both). - Line 1487 checks `!dis.contains("-1158620499") && !dis.contains("3134250669")` for `0xBAD0_DEAD` (line 1443), whose signed `i32` decimal is **`-1160716627`** (`0xBAD0_DEADu32 as i32`; `-1158620499` is `0xBAF0_DAAD`), so DXC disassembly would never match either string on a leak. 3. **Cleanup / scope nits:** - Leftover debug `println!("CANON_PIECE1 ...")` at `split.rs:1279-1287`, and the test name `graphics_bitcode_canonicalizes_unused_decls_and_preserves_resources` (`graphics_tests.rs:1241`) still says `canonicalizes` after narrowing graphics back to `BitcodePlan::unsplit`. - At `+1,179/-125` (`1,304` changed lines, over the ~800-line guideline in `CONTRIBUTING.md`), splitting `BitcodePlan` canonical bitcode emission and `referenced_bindings` + `prune_unused_bindings` into a 2-PR stack would make each piece much smaller to review. Checked with `cargo check --tests` (`x86_64-pc-windows-gnu`) and a host-side `rustc --test` harness on `gpu/dxil` (reproducing `SFI0` `0x4100` vs `0x4000`); no Windows DXC validator or GPU run. AI use: Antigravity (Claude Sonnet 5.5, Gemini 4 Carbon) audited the diff and ran the host reproduction; I re-checked each point against the source before posting.
ZekkJJ commented 2026-11-26 15:03:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ZekkJJ on 2026-11-26T14:31:14Z.


@safesearch77 @Prime1997 Thanks for the detailed findings. Feature inference after optimization, TiledResources canonicalization, sampler cache identity and the test assertions need addressing before this leaves draft.

<!-- greyfinch-sync:ivall/xcl:comment:7194938040 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7194938040). Originally posted by [ZekkJJ](https://github.com/ZekkJJ) on 2026-11-26T14:31:14Z. --- @safesearch77 @Prime1997 Thanks for the detailed findings. Feature inference after optimization, TiledResources canonicalization, sampler cache identity and the test assertions need addressing before this leaves draft.
bielfreedom commented 2026-11-26 17:22:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-26T17:22:36Z.


AMD Windows data for #2711: on an RX 9070 XT the whole programs are unchanged, and the split pieces get about 2 % smaller. Over 26 large retail compute programs, no two pieces became identical. The pipeline count stays at 76, and AMD's driver time is the same or slightly lower.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Builds, both with a local timing patch in xcl shaders that writes every program's DXIL size and every CreateComputePipelineState time to a file:
    • main b49be18;
    • this PR at dfead37 merged onto it.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs [--pipelines] with XCL_DIRECT_DXIL=1, switch windows, XCL_PSO_DISK_CACHE=0, one driver thread, and a fresh translation cache and exe name per run, so every build is cold.

Results

  • All 2,689 compute programs (translation only): the whole-program DXIL is byte for byte the same as main, as the description says.
  • The 26 large programs, 2 interleaved rounds:
build pipelines (56 pieces of 6 split programs + 20 unsplit) DXIL to the driver driver time r1 / r2 peak memory
main 76 9,633,636 B 118.0 / 102.6 s 1.52 / 1.47 GB
this PR 76 9,430,968 B (−2.1 %) 106.3 / 100.4 s 1.47 GB

main's first round is the outlier. On the second round the two are 2 % apart, so I would not claim a driver gain from this set. The cache-key sharing the PR is after does not show up here, because none of these pieces became identical.

Not tested: heap windows, GPU output, and a title run.

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

<!-- greyfinch-sync:ivall/xcl:comment:7198909579 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7198909579). Originally posted by [bielfreedom](https://github.com/bielfreedom) on 2026-11-26T17:22:36Z. --- **AMD Windows data for #2711: on an RX 9070 XT the whole programs are unchanged, and the split pieces get about 2 % smaller. Over 26 large retail compute programs, no two pieces became identical. The pipeline count stays at 76, and AMD's driver time is the same or slightly lower.** **Setup** - GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. - CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release. - Builds, both with a local timing patch in `xcl shaders` that writes every program's DXIL size and every `CreateComputePipelineState` time to a file: - `main` `b49be18`; - this PR at `dfead37` merged onto it. - Offline: `xcl shaders <retail shaders.rpf> --precompile --only cs [--pipelines]` with `XCL_DIRECT_DXIL=1`, switch windows, `XCL_PSO_DISK_CACHE=0`, one driver thread, and a fresh translation cache and exe name per run, so every build is cold. **Results** - **All 2,689 compute programs (translation only):** the whole-program DXIL is byte for byte the same as `main`, as the description says. - **The 26 large programs, 2 interleaved rounds:** | build | pipelines (56 pieces of 6 split programs + 20 unsplit) | DXIL to the driver | driver time r1 / r2 | peak memory | |---|---:|---:|---:|---:| | `main` | 76 | 9,633,636 B | 118.0 / 102.6 s | 1.52 / 1.47 GB | | this PR | 76 | 9,430,968 B (−2.1 %) | 106.3 / 100.4 s | 1.47 GB | `main`'s first round is the outlier. On the second round the two are 2 % apart, so I would not claim a driver gain from this set. The cache-key sharing the PR is after does not show up here, because none of these pieces became identical. **Not tested:** heap windows, GPU output, and a title run. **AI use:** Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.
JJAutoCompare commented 2026-11-27 00:27:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:27:46Z.


Tested: dfead3702a1e8c3b6b30afeccf51efc1e885b10b, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. cargo test --locked -j 2 -p xcl --lib --no-run, then the checked-in gpu::dxil::module::opt::tests and split optimization filters: 11 CPU passes. The canonical fixture produced three pieces per variant with matching downstream bytes and matching 2,184-byte tail containers. Three Arc passes in separate exact invocations of canonical_pieces_preserve_dynamic_indexing_and_match_gpu, dispatch_chain_divergent_forward_edges_3d, and wave64_metadata_dynamic_bindings_and_split_static_samplers_stay_valid. Whole/split readbacks matched, including 384/768 result words and 16 guards in the 3D cases. Zero failures, ignores or skips.

Not tested: Native wave64, retail smoke, workspace suite, and corpus-level size or performance.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and wrote the report.

<!-- greyfinch-sync:ivall/xcl:comment:7206480606 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7206480606). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-27T00:27:46Z. --- **Tested:** `dfead3702a1e8c3b6b30afeccf51efc1e885b10b`, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. `cargo test --locked -j 2 -p xcl --lib --no-run`, then the checked-in `gpu::dxil::module::opt::tests` and split optimization filters: **11 CPU passes**. The canonical fixture produced three pieces per variant with matching downstream bytes and matching 2,184-byte tail containers. **Three Arc passes** in separate exact invocations of `canonical_pieces_preserve_dynamic_indexing_and_match_gpu`, `dispatch_chain_divergent_forward_edges_3d`, and `wave64_metadata_dynamic_bindings_and_split_static_samplers_stay_valid`. Whole/split readbacks matched, including 384/768 result words and 16 guards in the 3D cases. Zero failures, ignores or skips. **Not tested:** Native wave64, retail smoke, workspace suite, and corpus-level size or performance. **AI use:** T3 Code / Codex (`gpt-6.2-sol`) ran and reran the checks and wrote the report.
Foniass commented 2026-12-01 08:46:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:46:41Z.


Triage (#1607) – head dfead37

Half of this PR is now on main. Commit 2b39525 ("Recompiler: prune unused split-piece resource bindings") added Module::referenced_bindings, Shader::prune_unused_bindings and the make_piece call after optimize(), which conflicts with this diff. Main keeps the survivors in their original order. This PR also sorts bindings.
The canonical bitcode writer is not on main, and no other open PR does it: try_to_canonical_bitcode, BitcodePlan, finish_optimized_canonical. That part still stands. It needs a rebase that drops the duplicated pruning. At about 1180 lines it is also well over the size limit.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305770905 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2711#issuecomment-7305770905). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:46:41Z. --- **Triage (#1607)** – head dfead37 Half of this PR is now on main. Commit `2b39525` ("Recompiler: prune unused split-piece resource bindings") added `Module::referenced_bindings`, `Shader::prune_unused_bindings` and the `make_piece` call after `optimize()`, which conflicts with this diff. Main keeps the survivors in their original order. This PR also sorts `bindings`. The canonical bitcode writer is not on main, and no other open PR does it: `try_to_canonical_bitcode`, `BitcodePlan`, `finish_optimized_canonical`. That part still stands. It needs a rebase that drops the duplicated pruning. At about 1180 lines it is also well over the size limit. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2711:upstream-pr/2711'
git switch 'upstream-pr/2711'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2711'
git switch 'upstream-pr/2711'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2711'
git switch 'upstream-pr/2711'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2711'
git switch 'main'
git merge --squash 'upstream-pr/2711'
git switch 'main'
git merge --ff-only 'upstream-pr/2711'
git switch 'main'
git merge 'upstream-pr/2711'
git push origin 'main'
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!2701
No description provided.