D3D12.X: add opt-in first-demand capture sidecar for Chain::whole fallbacks #2786

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

@⁠Decodere on GitHub · 2026-11-26 12:33 UTC · original
Decodere:feat-chain-whole-capture-sidecar → main · +1225 −15 · 4 files · 1 commits · open

Add an opt-in first-demand capture sidecar for dispatch_chain::Chain::whole fallbacks (Step 1 of #2741). When XCL_CAPTURE_CHAIN_WHOLE is unset or whitespace-empty, dispatch_chain::build skips ChainWholeMeta::new (capture_meta: Option<ChainWholeMeta>) and capture performs zero extra hashing, cache-key formatting, sampler allocation, I/O, thread spawning, DXGI queries, or locking; when set, each distinct final chain-ABI whole PSO demand is recorded in monotonic first-demand sequence order to a versioned UTF-8 JSONL sidecar strictly outside Chain::build_whole.

Part of #2741
Part of #2088

What is in it

  • crates/xcl/src/hle/d3d12x/real/chain_whole_capture.rs: opt-in capture gated by XCL_CAPTURE_CHAIN_WHOLE=<path> and optional XCL_CAPTURE_CHAIN_WHOLE_MAX=<u64> sequence cutoff (0 = header only; disabled under cfg!(test) so tests never touch process env or user paths). Exposes enabled() (cached OnceLock check) and build_meta_if(enabled, make) so disabled split-chain builds never construct ChainWholeMeta. Serializes replay metadata only (no shader bytes or local paths) as versioned JSONL (schema_version: 1) on a dedicated background writer thread (xcl-chain-capture):
    • Header line (kind: "header"): xcl_version, translator_source_id, direct_dxil_source_id, direct_dxil_translator_version, per_lane_source_id, chain_rs_abi_version (1), sequence_cutoff, captured_at_unix_ms, best-effort DXGI adapter (description, PCI IDs, is_software, UMD driver_version), agility_runtime (status, version), dxc (dxcompiler/dxil version/commit metadata without local directory paths), and effective 12-field compute translation_options (direct_dxil, direct_compact, direct_compact_nest, per_lane, safe_barrier, heap_windows, split_wave64_forced, dispatch_piece_limit, plus dxil_no_opt canonical sorted subset of ["cse","dce","merge","phi"] from XCL_DXIL_NO_OPT, x64_all_masks from XCL_X64_ALL_MASKS, wave64_spin from XCL_WAVE64_SPIN, and recomp_structured from XCL_RECOMP_NO_STRUCTURED, with backward-compatible serde defaults).
    • Demand lines (kind: "demand"): 1-based monotonic seq, elapsed_ms, timestamp_unix_ms, present_count, reason, already_ready, source_record_hash, whole_dxil_hash, whole_dxil_len, effective_flags, node_mask, chain_rs_abi_version, chain_rs_id (FNV-1a 64 over ABI version and ordered static samplers), ordered static_samplers, disk_cache_name (driver_cache::name_for(..., true)), effective mem_windows, and split_wave64.
    • Deduplicates first demand by final identity (source_record_hash, whole_dxil_hash, whole_dxil_len, effective_flags, node_mask, chain_rs_abi_version, chain_rs_id) under a leaf mutex with non-blocking channel enqueue so line order matches seq without disk I/O under lock; degrades silently with one warning on I/O errors.
  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: store capture_meta: Option<ChainWholeMeta> on Chain, lazily constructed in dispatch_chain::build only when chain_whole_capture::enabled() is true; when Some, record demand in Chain::whole before checking self.whole.get() or acquiring self.build_whole (capturing even when already ready); classify direct dispatch fallback reasons via classify_direct_fallback (Bundle before MissingRecordingAllocator before ScratchUnavailable).
  • crates/xcl/src/hle/d3d12x/bind.rs: pass ChainWholeReason::Indirect from execute_indirect to dispatch_chain::whole.
  • crates/xcl/src/hle/d3d12x/real.rs: declare chain_whole_capture, pass effective pso::mem_windows() and wave32_only(this) into dispatch_chain::build, and flush pending capture records in end_title before suspending threads.
  • Unit tests (12 new tests across chain_whole_capture::tests and dispatch_chain::tests): off_by_default_creates_no_file_and_no_io, captures_all_four_reasons_in_monotonic_sequence_order, deduplicates_first_demand_by_final_identity_and_keeps_distinct_identities_separate, records_demand_even_when_whole_pso_is_already_ready, sequence_cutoff_caps_distinct_demands_including_zero, chain_root_signature_identity_tracks_sampler_order_and_comparison, unwritable_target_path_fails_gracefully_without_panicking, disabled_capture_skips_metadata_construction_for_unset_and_empty_paths, translation_options_record_dxil_no_opt_and_extra_compute_switches, classify_direct_fallback_distinguishes_bundle_missing_allocator_and_scratch_unavailable, whole_capture_runs_outside_build_whole_lock, and disabled_capture_path_skips_metadata_construction_and_on_demand_callback.

Tested

  • Hardware: Windows 11 Home (build 26200), NVIDIA GeForce RTX 4060 (8 GB, driver 621.14), Intel Core i5-11400F, 32 GB RAM, rustc 1.100.0, DXC 1.9.2609.5, debug (WARP) and release (RTX 4060).
  • Targeted suites (hle::d3d12x::real::chain_whole_capture:: + hle::d3d12x::real::dispatch_chain::tests::, 12 new + 2 existing, --test-threads=1):
    • Debug (XCL_ADAPTER=warp): 14 passed, 0 failed, 0 ignored (0 skipped; chain_whole_capture 9/0/0 in 0.01 s, dispatch_chain 5/0/0 in 0.52 s).
    • Release (RTX 4060): 14 passed, 0 failed, 0 ignored (0 skipped; chain_whole_capture 9/0/0 in 0.01 s, dispatch_chain 5/0/0 in 0.63 s).
  • Affected modules on release RTX 4060 (hle::d3d12x::real:: + hle::d3d12x::bind::, --test-threads=4): 80 passed, 0 failed, 0 ignored (0 skipped; real 72 in 0.78 s, bind 8 in 0.31 s).
  • cargo clippy --workspace --all-targets: 0 warnings and 0 errors in chain_whole_capture.rs, and 0 new warnings or errors across all added/changed lines in dispatch_chain.rs, bind.rs, and real.rs (3 pre-existing main clippy::approx_constant errors remain in untouched lower_valu.rs, lower_wide.rs, and recomp/lower.rs).
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1447 passed, 0 failed, 47 ignored across 37 targets (xcl --lib: 1321 passed, 0 failed, 27 ignored in 15.91 s; 29 SKIPPED lines whose optional env vars or sample packs were unset).
  • Live 60 s RTX 4060 capture run on title: 29640639 with XCL_CAPTURE_CHAIN_WHOLE, XCL_CAPTURE_CHAIN_WHOLE_MAX=64, and XCL_DIRECT_DXIL=1: 1577 frames (PresentX 1577), 60 60 60 presents/2 s, 0 device removals, 0 crashes, 13969 MB peak commit (exit: 0x0); end_title cleanly flushed a 984-byte UTF-8 LF JSONL sidecar containing the schema_version: 1 header with live RTX 4060 adapter/driver (32.0.16.2114), DXC (1.9.2609.5), and all 12 effective translation_options fields (direct_dxil: true, dxil_no_opt: [], x64_all_masks: false, wave64_spin: true, recomp_structured: true, plus the original 8 fields; 0 demand lines because this title split 0 compute programs during the 60 s run).

Regression run
Default-flags quiet 60 s scripts/smoke.ps1 runs on title: 29640639 (XCL_CAPTURE_CHAIN_WHOLE unset):

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13975 MB

PR:

xcl-smoke v1
commit: 3b6609fbbe17fd140e59a8f6836ca8071d56e806
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14019 MB

Not tested

  • Live retail title triggering real split-compute Chain::whole fallbacks (title: 29640639 reported 0 programs split during the 60 s run; demand emission, deduplication, cutoff, all four ChainWholeReason values, disabled-path gating, 12-field translation_options capture, and off-build_whole-lock ordering are verified via deterministic unit/D3D12 tests).
  • Selective offline replay against captured sidecars (deferred to #2741 Part 2 / Steps 2-4).
  • AMD or Intel GPUs, Linux, and Agility SDK loaded mode (agility_runtime.status == "loaded").
  • The 47 #[ignore] workspace tests and 29 SKIPPED optional-env/sample-pack tests.

AI use

  • Google Antigravity (Gemini 4 Neon) designed and implemented the opt-in chain_whole_capture sidecar, disabled-path metadata gating, 12-field TranslationOptionsMeta capture, ChainWholeReason plumbing, and 12 unit tests against origin/main (b49be183), ran clippy, debug WARP and release RTX 4060 test suites, and quiet 60 s smokes, and drafted this PR description.
**@⁠Decodere** on GitHub · 2026-11-26 12:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2786) `Decodere:feat-chain-whole-capture-sidecar` → `main` · +1225 −15 · 4 files · 1 commits · open Add an opt-in first-demand capture sidecar for `dispatch_chain::Chain::whole` fallbacks (Step 1 of `#2741`). When `XCL_CAPTURE_CHAIN_WHOLE` is unset or whitespace-empty, `dispatch_chain::build` skips `ChainWholeMeta::new` (`capture_meta: Option<ChainWholeMeta>`) and capture performs zero extra hashing, cache-key formatting, sampler allocation, I/O, thread spawning, DXGI queries, or locking; when set, each distinct final chain-ABI whole PSO demand is recorded in monotonic first-demand sequence order to a versioned UTF-8 JSONL sidecar strictly outside `Chain::build_whole`. Part of #2741 Part of #2088 **What is in it** - `crates/xcl/src/hle/d3d12x/real/chain_whole_capture.rs`: opt-in capture gated by `XCL_CAPTURE_CHAIN_WHOLE=<path>` and optional `XCL_CAPTURE_CHAIN_WHOLE_MAX=<u64>` sequence cutoff (`0` = header only; disabled under `cfg!(test)` so tests never touch process env or user paths). Exposes `enabled()` (cached `OnceLock` check) and `build_meta_if(enabled, make)` so disabled split-chain builds never construct `ChainWholeMeta`. Serializes replay metadata only (no shader bytes or local paths) as versioned JSONL (`schema_version: 1`) on a dedicated background writer thread (`xcl-chain-capture`): - Header line (`kind: "header"`): `xcl_version`, `translator_source_id`, `direct_dxil_source_id`, `direct_dxil_translator_version`, `per_lane_source_id`, `chain_rs_abi_version` (`1`), `sequence_cutoff`, `captured_at_unix_ms`, best-effort DXGI `adapter` (`description`, PCI IDs, `is_software`, UMD `driver_version`), `agility_runtime` (`status`, `version`), `dxc` (`dxcompiler`/`dxil` version/commit metadata without local directory paths), and effective 12-field compute `translation_options` (`direct_dxil`, `direct_compact`, `direct_compact_nest`, `per_lane`, `safe_barrier`, `heap_windows`, `split_wave64_forced`, `dispatch_piece_limit`, plus `dxil_no_opt` canonical sorted subset of `["cse","dce","merge","phi"]` from `XCL_DXIL_NO_OPT`, `x64_all_masks` from `XCL_X64_ALL_MASKS`, `wave64_spin` from `XCL_WAVE64_SPIN`, and `recomp_structured` from `XCL_RECOMP_NO_STRUCTURED`, with backward-compatible serde defaults). - Demand lines (`kind: "demand"`): 1-based monotonic `seq`, `elapsed_ms`, `timestamp_unix_ms`, `present_count`, `reason`, `already_ready`, `source_record_hash`, `whole_dxil_hash`, `whole_dxil_len`, `effective_flags`, `node_mask`, `chain_rs_abi_version`, `chain_rs_id` (FNV-1a 64 over ABI version and ordered static samplers), ordered `static_samplers`, `disk_cache_name` (`driver_cache::name_for(..., true)`), effective `mem_windows`, and `split_wave64`. - Deduplicates first demand by final identity (`source_record_hash`, `whole_dxil_hash`, `whole_dxil_len`, `effective_flags`, `node_mask`, `chain_rs_abi_version`, `chain_rs_id`) under a leaf mutex with non-blocking channel enqueue so line order matches `seq` without disk I/O under lock; degrades silently with one warning on I/O errors. - `crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs`: store `capture_meta: Option<ChainWholeMeta>` on `Chain`, lazily constructed in `dispatch_chain::build` only when `chain_whole_capture::enabled()` is true; when `Some`, record demand in `Chain::whole` before checking `self.whole.get()` or acquiring `self.build_whole` (capturing even when already ready); classify direct dispatch fallback reasons via `classify_direct_fallback` (`Bundle` before `MissingRecordingAllocator` before `ScratchUnavailable`). - `crates/xcl/src/hle/d3d12x/bind.rs`: pass `ChainWholeReason::Indirect` from `execute_indirect` to `dispatch_chain::whole`. - `crates/xcl/src/hle/d3d12x/real.rs`: declare `chain_whole_capture`, pass effective `pso::mem_windows()` and `wave32_only(this)` into `dispatch_chain::build`, and flush pending capture records in `end_title` before suspending threads. - Unit tests (12 new tests across `chain_whole_capture::tests` and `dispatch_chain::tests`): `off_by_default_creates_no_file_and_no_io`, `captures_all_four_reasons_in_monotonic_sequence_order`, `deduplicates_first_demand_by_final_identity_and_keeps_distinct_identities_separate`, `records_demand_even_when_whole_pso_is_already_ready`, `sequence_cutoff_caps_distinct_demands_including_zero`, `chain_root_signature_identity_tracks_sampler_order_and_comparison`, `unwritable_target_path_fails_gracefully_without_panicking`, `disabled_capture_skips_metadata_construction_for_unset_and_empty_paths`, `translation_options_record_dxil_no_opt_and_extra_compute_switches`, `classify_direct_fallback_distinguishes_bundle_missing_allocator_and_scratch_unavailable`, `whole_capture_runs_outside_build_whole_lock`, and `disabled_capture_path_skips_metadata_construction_and_on_demand_callback`. **Tested** - Hardware: Windows 11 Home (build 26200), NVIDIA GeForce RTX 4060 (8 GB, driver 621.14), Intel Core i5-11400F, 32 GB RAM, `rustc 1.100.0`, DXC `1.9.2609.5`, debug (WARP) and release (RTX 4060). - Targeted suites (`hle::d3d12x::real::chain_whole_capture::` + `hle::d3d12x::real::dispatch_chain::tests::`, 12 new + 2 existing, `--test-threads=1`): - Debug (`XCL_ADAPTER=warp`): `14 passed, 0 failed, 0 ignored` (`0` skipped; `chain_whole_capture` `9/0/0` in `0.01 s`, `dispatch_chain` `5/0/0` in `0.52 s`). - Release (RTX 4060): `14 passed, 0 failed, 0 ignored` (`0` skipped; `chain_whole_capture` `9/0/0` in `0.01 s`, `dispatch_chain` `5/0/0` in `0.63 s`). - Affected modules on release RTX 4060 (`hle::d3d12x::real::` + `hle::d3d12x::bind::`, `--test-threads=4`): `80 passed, 0 failed, 0 ignored` (`0` skipped; `real` `72` in `0.78 s`, `bind` `8` in `0.31 s`). - `cargo clippy --workspace --all-targets`: `0` warnings and `0` errors in `chain_whole_capture.rs`, and `0` new warnings or errors across all added/changed lines in `dispatch_chain.rs`, `bind.rs`, and `real.rs` (3 pre-existing `main` `clippy::approx_constant` errors remain in untouched `lower_valu.rs`, `lower_wide.rs`, and `recomp/lower.rs`). - `cargo test --release --workspace --no-fail-fast -- --test-threads=4`: `1447 passed, 0 failed, 47 ignored` across 37 targets (`xcl --lib`: `1321 passed, 0 failed, 27 ignored` in `15.91 s`; `29` `SKIPPED` lines whose optional env vars or sample packs were unset). - Live 60 s RTX 4060 capture run on `title: 29640639` with `XCL_CAPTURE_CHAIN_WHOLE`, `XCL_CAPTURE_CHAIN_WHOLE_MAX=64`, and `XCL_DIRECT_DXIL=1`: `1577` frames (`PresentX 1577`), `60 60 60` presents/2 s, `0` device removals, `0` crashes, `13969 MB` peak commit (`exit: 0x0`); `end_title` cleanly flushed a 984-byte UTF-8 LF JSONL sidecar containing the `schema_version: 1` header with live RTX 4060 adapter/driver (`32.0.16.2114`), DXC (`1.9.2609.5`), and all 12 effective `translation_options` fields (`direct_dxil: true`, `dxil_no_opt: []`, `x64_all_masks: false`, `wave64_spin: true`, `recomp_structured: true`, plus the original 8 fields; `0` demand lines because this title split `0` compute programs during the 60 s run). **Regression run** Default-flags quiet 60 s `scripts/smoke.ps1` runs on `title: 29640639` (`XCL_CAPTURE_CHAIN_WHOLE` unset): main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1571 (PresentX 1571) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13975 MB ``` PR: ``` xcl-smoke v1 commit: 3b6609fbbe17fd140e59a8f6836ca8071d56e806 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1536 (PresentX 1536) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14019 MB ``` **Not tested** - Live retail title triggering real split-compute `Chain::whole` fallbacks (`title: 29640639` reported `0 programs split` during the 60 s run; demand emission, deduplication, cutoff, all four `ChainWholeReason` values, disabled-path gating, 12-field `translation_options` capture, and off-`build_whole`-lock ordering are verified via deterministic unit/D3D12 tests). - Selective offline replay against captured sidecars (deferred to `#2741` Part 2 / Steps 2-4). - AMD or Intel GPUs, Linux, and Agility SDK loaded mode (`agility_runtime.status == "loaded"`). - The 47 `#[ignore]` workspace tests and 29 `SKIPPED` optional-env/sample-pack tests. **AI use** - Google Antigravity (Gemini 4 Neon) designed and implemented the opt-in `chain_whole_capture` sidecar, disabled-path metadata gating, 12-field `TranslationOptionsMeta` capture, `ChainWholeReason` plumbing, and 12 unit tests against `origin/main` (`b49be183`), ran clippy, debug WARP and release RTX 4060 test suites, and quiet 60 s smokes, and drafted this PR description.
Split compute shaders normally execute via their dispatch-chain pieces, falling back to `Chain::whole` (and the `.chain.pso` driver-cache namespace) on compute `ExecuteIndirect` or direct dispatches without usable scratch. Used-pipeline history cannot distinguish which shaders triggered that fallback.

- Add `crates/xcl/src/hle/d3d12x/real/chain_whole_capture.rs`, gated strictly behind opt-in `XCL_CAPTURE_CHAIN_WHOLE=<path>` (plus optional `XCL_CAPTURE_CHAIN_WHOLE_MAX=<u64>` sequence cutoff). When unset or whitespace-empty, capture performs zero I/O, spawns no thread, queries no DXGI metadata, and acquires no locks.
- Record first demand to a versioned UTF-8 JSONL sidecar (`schema_version: 1`) on a dedicated background writer thread (`xcl-chain-capture`), strictly outside `Chain::build_whole` and storing replay metadata only: a header line (build/translator source IDs, chain RS ABI version, cutoff, best-effort DXGI adapter/driver version, Agility runtime status/version, DXC version/commit metadata without local paths, and effective translation options) followed by deduplicated demand lines (`seq`, `elapsed_ms`, `timestamp_unix_ms`, `present_count`, `reason`, `already_ready`, `source_record_hash`, `whole_dxil_hash`, `whole_dxil_len`, `effective_flags`, `node_mask`, `chain_rs_abi_version`, `chain_rs_id`, ordered `static_samplers`, `disk_cache_name`, effective `mem_windows`, and `split_wave64`).
- Pass explicit `ChainWholeReason` (`Indirect`, `Bundle`, `MissingRecordingAllocator`, `ScratchUnavailable`) from `bind::execute_indirect` and `dispatch_chain::dispatch` (checking `Bundle` before missing allocator) to `Chain::whole` before readiness check or `build_whole` lock, so first demand is captured even when the whole PSO is already ready; flush on shutdown in `real::end_title`.
- Add 9 deterministic unit tests across `chain_whole_capture::tests` and `dispatch_chain::tests` covering off-by-default zero I/O, all four reasons in monotonic sequence order, deduplication by final identity while separating distinct final identities for one source hash, `already_ready` capture, sequence cutoffs including `0`, static-sampler order/comparison hashing, unwritable-path degradation, direct-fallback classification precedence, and capturing before `build_whole` is acquired.

Part of #2741
Part of #2088
Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:34:20 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 12:50 UTC · original

Independent review and focused Windows check of head 7587c013 against main b49be18. I checked both paths in the exact-head source.

  1. The disabled capture path still does work on every successful split-chain build. dispatch_chain::build constructs ChainWholeMeta before it checks whether XCL_CAPTURE_CHAIN_WHOLE is set. The constructor scans whole twice (fnv64 directly and through driver_cache::name_for), allocates the cache name, copies static samplers, and retains them. This occurs even if no Chain::whole fallback follows. The title smoke in the description split zero programs, so it cannot measure this path. Could metadata construction be gated on the cached capture setting, with an off/empty-setting regression that verifies the constructor is never called? I have not measured the time cost.

  2. The sidecar omits an option that changes the whole DXIL. current_translation_options does not record XCL_DXIL_NO_OPT. The split compute path calls optimize(), which reads that variable to skip phi, cse, dce, or merge. For example, disabling DCE can produce different whole DXIL while the recorded translation options remain identical. The digest would reveal a mismatch, but a later replay could not reproduce the setting from this sidecar. Could the header record the effective disabled passes, with a default-versus-dce metadata regression? Other existing translator switches are worth checking before freezing schema version 1.

Small candidate diff shape
- capture_meta: ChainWholeMeta,
+ capture_meta: Option<ChainWholeMeta>,
...
- let capture_meta = ChainWholeMeta::new(record, whole, samplers, flags, node, mem_windows, split_wave64);
+ let capture_meta = chain_whole_capture::enabled()
+     .then(|| ChainWholeMeta::new(record, whole, samplers, flags, node, mem_windows, split_wave64));
...
- on_demand(&self.builder.device, &self.capture_meta, reason, already_ready);
+ if let Some(meta) = &self.capture_meta {
+     on_demand(&self.builder.device, meta, reason, already_ready);
+ }

enabled() can read the existing cached configuration. The explicit capture-session test would construct Some(meta); the default path should construct None. Add the effective XCL_DXIL_NO_OPT value to TranslationOptionsMeta separately.

Tested: Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11, signed D3D12 Agility 1.620.2. cargo test --offline --locked -p xcl --lib hle::d3d12x::real::chain_whole_capture:: -- --test-threads=1: 7 passed, 0 failed, 0 ignored. The same command with hle::d3d12x::real::dispatch_chain::tests::: 4 passed, 0 failed, 0 ignored; the D3D12 lock-order test ran with no GPU skip. The full debug workspace run was stopped after four GPU tests remained running for over a minute with no further output; it produced no final counts. No retail fallback capture was run on this machine.

AI use: Codex (GPT-6.2 Sol) inspected the exact-head source, ran the focused tests, and drafted this review. I verified the two points against the code before posting.

**@⁠thehollowedone** on GitHub · 2026-11-26 12:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2786#issuecomment-7192533144) Independent review and focused Windows check of [head `7587c013`](https://github.com/xcl-dev/xcl/commit/7587c01324cf90f928af392bf530e735beaac182) against [`main` `b49be18`](https://github.com/xcl-dev/xcl/commit/b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). I checked both paths in the exact-head source. 1. **The disabled capture path still does work on every successful split-chain build.** [`dispatch_chain::build`](https://github.com/xcl-dev/xcl/blob/7587c01324cf90f928af392bf530e735beaac182/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs#L108-L118) constructs `ChainWholeMeta` before it checks whether `XCL_CAPTURE_CHAIN_WHOLE` is set. The constructor scans `whole` twice (`fnv64` directly and through `driver_cache::name_for`), allocates the cache name, copies static samplers, and retains them. This occurs even if no `Chain::whole` fallback follows. The title smoke in the description split zero programs, so it cannot measure this path. Could metadata construction be gated on the cached capture setting, with an off/empty-setting regression that verifies the constructor is never called? I have not measured the time cost. 2. **The sidecar omits an option that changes the whole DXIL.** [`current_translation_options`](https://github.com/xcl-dev/xcl/blob/7587c01324cf90f928af392bf530e735beaac182/crates/xcl/src/hle/d3d12x/real/chain_whole_capture.rs#L297-L308) does not record `XCL_DXIL_NO_OPT`. The [split compute path](https://github.com/xcl-dev/xcl/blob/7587c01324cf90f928af392bf530e735beaac182/crates/xcl/src/gpu/dxil/kernel.rs#L625-L634) calls `optimize()`, which reads that variable to skip `phi`, `cse`, `dce`, or `merge`. For example, disabling DCE can produce different whole DXIL while the recorded translation options remain identical. The digest would reveal a mismatch, but a later replay could not reproduce the setting from this sidecar. Could the header record the effective disabled passes, with a default-versus-`dce` metadata regression? Other existing translator switches are worth checking before freezing schema version 1. <details><summary>Small candidate diff shape</summary> ```diff - capture_meta: ChainWholeMeta, + capture_meta: Option<ChainWholeMeta>, ... - let capture_meta = ChainWholeMeta::new(record, whole, samplers, flags, node, mem_windows, split_wave64); + let capture_meta = chain_whole_capture::enabled() + .then(|| ChainWholeMeta::new(record, whole, samplers, flags, node, mem_windows, split_wave64)); ... - on_demand(&self.builder.device, &self.capture_meta, reason, already_ready); + if let Some(meta) = &self.capture_meta { + on_demand(&self.builder.device, meta, reason, already_ready); + } ``` `enabled()` can read the existing cached configuration. The explicit capture-session test would construct `Some(meta)`; the default path should construct `None`. Add the effective `XCL_DXIL_NO_OPT` value to `TranslationOptionsMeta` separately. </details> **Tested:** Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11, signed D3D12 Agility 1.620.2. `cargo test --offline --locked -p xcl --lib hle::d3d12x::real::chain_whole_capture:: -- --test-threads=1`: 7 passed, 0 failed, 0 ignored. The same command with `hle::d3d12x::real::dispatch_chain::tests::`: 4 passed, 0 failed, 0 ignored; the D3D12 lock-order test ran with no GPU skip. The full debug workspace run was stopped after four GPU tests remained running for over a minute with no further output; it produced no final counts. No retail fallback capture was run on this machine. AI use: Codex (GPT-6.2 Sol) inspected the exact-head source, ran the focused tests, and drafted this review. I verified the two points against the code before posting.
github-bot force-pushed github-bot/gh-2786 from 7587c01324 to 3b6609fbbe 2026-11-26 13:31:51 +00:00 Compare
Author
Owner

@⁠afpruivo on GitHub · 2026-11-26 13:26 UTC · original · edited 2026-11-26 13:45 UTC

Tested 3b6609fb (and earlier 7587c013) on an RTX 3090 with a retail title that does reach Chain::whole. At 3b6609fb, 480 s gave 247 demand records, and 220 of them match a whole-form driver build in the log by record hash and whole-DXIL size. This fills the "live retail title" item under Not tested.

Setup

  • RTX 3090 24 GB, driver 621.40, Windows 11 26300, release. Retail 1.0.2.1 (smoke title: 3c290c16).
  • main b49be18 + this PR. 480 s with XCL_DIRECT_DXIL=1 XCL_DRED=1 XCL_CAPTURE_CHAIN_WHOLE=<path>, scripted A presses. xcl.exe was in a 2 GiB shader-heap profile (#2590). Each run starts from the same XCL cache state (the files a run adds are moved aside afterwards).

Results at 3b6609fb

  • cargo test --release -p xcl --lib -- hle::d3d12x::real::chain_whole_capture:: hle::d3d12x::real::dispatch_chain::: 14 passed, 0 failed, 0 ignored.
  • Run: exit 0x0, 2,121 frames, no device removal, no crash, peak commit 40,501 MB. World start (#101) at 82.5 s. 287 programs split.
  • Sidecar on E: (the title's drive is G:): no overlay redirect this time.
    • Header: translation_options now carries dxil_no_opt: [], x64_all_masks: false, wave64_spin: true, recomp_structured: true.
    • 247 demands: seq 1–247 with no gaps, 247 distinct identities. Reasons: 225 indirect, 22 missing_recording_allocator.
  • Matched against the log:
    • 220 of the 247 have a driver compile start for the same record hash with the same whole-DXIL size.
    • The other 27 are 88–172 KB programs whose hashes appear elsewhere in the log.
    • The 6 compute builds of 900 KB or more that are not in the sidecar all ran before 10 s, as ordinary compute pipelines.

Repeat: the two runs (7587c013, then 3b6609fb, same cache state) captured 223 and 247 whole forms, with 213 in both, 10 only in the first and 34 only in the second. So one run's capture covers most, but not all, of what the next run needs. Merging several captures may be worth it for part 2.

Results at 7587c013 (the first run): 11 of 11 tests passed. 480 s gave 223 demands (220 indirect, 3 missing_recording_allocator), 216 matched to driver builds, exit 0x0, 2,078 frames, peak commit 39,039 MB.

Notes from the first run, both answered above by @⁠Decodere:

  1. A sidecar path on a drive the title mounts goes into the overlay: with G:\… the file ended up under %LOCALAPPDATA%\XCL\<package>\overlay\…. A path outside the title's drives works, as this run shows.
  2. elapsed_ms counts from the first demand, not from the start of the run.

Not tested: XCL_CAPTURE_CHAIN_WHOLE_MAX; the bundle and scratch_unavailable reasons in a title; the cost of the disabled path; AMD; nvidia-dev, where this PR conflicts.

AI use: Claude Code (Claude Opus 5.5) read the diff, ran the builds, the tests and both runs on my machine, matched the sidecars against the logs, and drafted this. Checked by me before posting.

**@⁠afpruivo** on GitHub · 2026-11-26 13:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2786#issuecomment-7193366863) · edited 2026-11-26 13:45 UTC **Tested `3b6609fb` (and earlier `7587c013`) on an RTX 3090 with a retail title that does reach `Chain::whole`. At `3b6609fb`, 480 s gave 247 demand records, and 220 of them match a whole-form driver build in the log by record hash and whole-DXIL size.** This fills the "live retail title" item under **Not tested**. **Setup** - RTX 3090 24 GB, driver 621.40, Windows 11 26300, release. Retail 1.0.2.1 (smoke `title: 3c290c16`). - `main` `b49be18` + this PR. 480 s with `XCL_DIRECT_DXIL=1 XCL_DRED=1 XCL_CAPTURE_CHAIN_WHOLE=<path>`, scripted A presses. `xcl.exe` was in a 2 GiB shader-heap profile (#2590). Each run starts from the same XCL cache state (the files a run adds are moved aside afterwards). **Results at `3b6609fb`** - `cargo test --release -p xcl --lib -- hle::d3d12x::real::chain_whole_capture:: hle::d3d12x::real::dispatch_chain::`: 14 passed, 0 failed, 0 ignored. - Run: exit `0x0`, 2,121 frames, no device removal, no crash, peak commit 40,501 MB. World start (`#101`) at 82.5 s. 287 programs split. - Sidecar on `E:` (the title's drive is `G:`): no overlay redirect this time. - Header: `translation_options` now carries `dxil_no_opt: []`, `x64_all_masks: false`, `wave64_spin: true`, `recomp_structured: true`. - 247 demands: `seq` 1–247 with no gaps, 247 distinct identities. Reasons: 225 `indirect`, 22 `missing_recording_allocator`. - **Matched against the log:** - 220 of the 247 have a `driver compile start` for the same record hash with the same whole-DXIL size. - The other 27 are 88–172 KB programs whose hashes appear elsewhere in the log. - The 6 compute builds of 900 KB or more that are not in the sidecar all ran before 10 s, as ordinary compute pipelines. **Repeat:** the two runs (`7587c013`, then `3b6609fb`, same cache state) captured 223 and 247 whole forms, with 213 in both, 10 only in the first and 34 only in the second. So one run's capture covers most, but not all, of what the next run needs. Merging several captures may be worth it for part 2. **Results at `7587c013`** (the first run): 11 of 11 tests passed. 480 s gave 223 demands (220 `indirect`, 3 `missing_recording_allocator`), 216 matched to driver builds, exit `0x0`, 2,078 frames, peak commit 39,039 MB. **Notes from the first run, both answered above by @⁠Decodere:** 1. A sidecar path on a drive the title mounts goes into the overlay: with `G:\…` the file ended up under `%LOCALAPPDATA%\XCL\<package>\overlay\…`. A path outside the title's drives works, as this run shows. 2. `elapsed_ms` counts from the first demand, not from the start of the run. **Not tested:** `XCL_CAPTURE_CHAIN_WHOLE_MAX`; the `bundle` and `scratch_unavailable` reasons in a title; the cost of the disabled path; AMD; `nvidia-dev`, where this PR conflicts. **AI use:** Claude Code (Claude Opus 5.5) read the diff, ran the builds, the tests and both runs on my machine, matched the sidecars against the logs, and drafted this. Checked by me before posting.
Author
Owner

@⁠Decodere on GitHub · 2026-11-26 13:30 UTC · original

Updated in 3b6609fb.

@⁠thehollowedone — Thanks for the review; both points are addressed in 3b6609fb:

  1. Zero-cost disabled path: Chain::capture_meta is now Option<ChainWholeMeta>, constructed in dispatch_chain::build via chain_whole_capture::build_meta_if(chain_whole_capture::enabled(), || ChainWholeMeta::new(...)) (reading the cached OnceLock config), and Chain::whole_with skips on_demand when None. Covered by disabled_capture_skips_metadata_construction_for_unset_and_empty_paths and disabled_capture_path_skips_metadata_construction_and_on_demand_callback.
  2. Complete compute translation_options: Audited pso.rs::cache_allowed and gpu/{dxil,recomp} and added the 4 missing non-pixel compute translator switches to TranslationOptionsMeta: dxil_no_opt (normalized from XCL_DXIL_NO_OPT), x64_all_masks (XCL_X64_ALL_MASKS), wave64_spin (XCL_WAVE64_SPIN), and recomp_structured (XCL_RECOMP_NO_STRUCTURED), with serde defaults for compatibility. Covered by translation_options_record_dxil_no_opt_and_extra_compute_switches and verified in a live 60 s RTX 4060 capture header (984 bytes, UTF-8 LF JSONL).

Re-verified on 3b6609fb with debug WARP (14/0/0), release RTX 4060 targeted (14/0/0) + real::/bind:: (80/0/0), 0 new clippy warnings across the 4 modified files, full release workspace (1447 passed, 0 failed, 47 ignored), and quiet 60 s default (1536 frames, 60 60 60, 14019 MB, 0 rem/crash) + live capture (1577 frames, 60 60 60, 13969 MB) smokes.

@⁠afpruivo — Huge thanks for testing live demand capture on RTX 3090 (223 gapless records / 216 matched whole-form builds / 0 missing Chain::whole builds!). Both operational notes make sense:

  • Paths under a title-mounted drive are VFS-redirected to the overlay by the hooked CreateFile path, so pointing XCL_CAPTURE_CHAIN_WHOLE at a host path outside the mounted drive avoids overlay redirection.
  • elapsed_ms currently anchors at first demand while Part 2 replay orders strictly by seq.
**@⁠Decodere** on GitHub · 2026-11-26 13:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2786#issuecomment-7193458042) Updated in `3b6609fb`. @⁠thehollowedone — Thanks for the review; both points are addressed in [`3b6609fb`](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2786/commits/3b6609fbbe17fd140e59a8f6836ca8071d56e806): 1. **Zero-cost disabled path:** `Chain::capture_meta` is now `Option<ChainWholeMeta>`, constructed in `dispatch_chain::build` via `chain_whole_capture::build_meta_if(chain_whole_capture::enabled(), || ChainWholeMeta::new(...))` (reading the cached `OnceLock` config), and `Chain::whole_with` skips `on_demand` when `None`. Covered by `disabled_capture_skips_metadata_construction_for_unset_and_empty_paths` and `disabled_capture_path_skips_metadata_construction_and_on_demand_callback`. 2. **Complete compute `translation_options`:** Audited `pso.rs::cache_allowed` and `gpu/{dxil,recomp}` and added the 4 missing non-pixel compute translator switches to `TranslationOptionsMeta`: `dxil_no_opt` (normalized from `XCL_DXIL_NO_OPT`), `x64_all_masks` (`XCL_X64_ALL_MASKS`), `wave64_spin` (`XCL_WAVE64_SPIN`), and `recomp_structured` (`XCL_RECOMP_NO_STRUCTURED`), with serde defaults for compatibility. Covered by `translation_options_record_dxil_no_opt_and_extra_compute_switches` and verified in a live 60 s RTX 4060 capture header (`984` bytes, UTF-8 LF JSONL). Re-verified on `3b6609fb` with debug WARP (`14/0/0`), release RTX 4060 targeted (`14/0/0`) + `real::`/`bind::` (`80/0/0`), `0` new clippy warnings across the 4 modified files, full release workspace (`1447 passed, 0 failed, 47 ignored`), and quiet 60 s default (`1536` frames, `60 60 60`, `14019 MB`, `0` rem/crash) + live capture (`1577` frames, `60 60 60`, `13969 MB`) smokes. @⁠afpruivo — Huge thanks for testing live demand capture on RTX 3090 (`223` gapless records / `216` matched whole-form builds / `0` missing `Chain::whole` builds!). Both operational notes make sense: - Paths under a title-mounted drive are VFS-redirected to the overlay by the hooked `CreateFile` path, so pointing `XCL_CAPTURE_CHAIN_WHOLE` at a host path outside the mounted drive avoids overlay redirection. - `elapsed_ms` currently anchors at first demand while Part 2 replay orders strictly by `seq`.
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/2786/head:github-bot/gh-2786'
git switch 'github-bot/gh-2786'

Merge

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