Skip to content

DXIL split: prune piece-local features after optimize and transport f16/f64 - #2344

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-2080-split-features-f16-f64
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-2080-split-features-f16-f64

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

Part of #2088
Part of #1269

What is in it

Follow-up to #2080 in compute dispatch splitting (crates/xcl/src/gpu/dxil/module/split.rs) fixing two classes of shaders that were previously refused during splitting and fell back to compiling whole:

  1. Per-piece feature inference after optimization (make_piece, infer_piece_features):
    • Run dst.m.optimize() before dst.infer_piece_features() and emit pieces via dst.finish_optimized(threads, Some(32)) instead of inferring flags before optimization and scanning dead self.m.insts entries. When pack transports only a heap handle's dynamic index to a later piece, dst.m.optimize() eliminates the now-dead dx.op.createHandleFromHeap in the defining piece, so ResourceHeapIndexing / SamplerHeapIndexing are no longer spuriously declared there.
    • Scan only live instructions in self.m.blocks.iter().flatten() and re-infer piece-local flags to match DXC 1.9 (DxilShaderFlags): ResourceHeapIndexing, SamplerHeapIndexing, WaveOps (dx.op.wave* / dx.op.quad*), TiledResources (dx.op.checkAccessFullyMapped and sample ops with a non-undef, non-zero-constant LOD clamp), TypedUavLoadAdditionalFormats (multi-component typed UAV dx.op.textureLoad* / dx.op.bufferLoad* via annotateHandle properties, with fallback), NativeLowPrecision (kept only when the whole shader used it and the piece has live half / i16 instructions), DoubleExtensions (dx.op.tertiary.f64 Fma op 47 in addition to finish_optimized's infer_type_features), and 64-bit atomics.
  2. Live f16 and f64 transport across cuts (transport_words, pack, unpack):
    • Transport TypeDef::Half in 1 scratch word (bitcast half -> i16 + zext i16 -> i32, restored via trunc i32 -> i16 + bitcast i16 -> half) and TypeDef::Double in 2 scratch words (Shader::split_double / Shader::make_double).
  3. Regression tests (split::tests):
    • dispatch_chain_prunes_piece_local_features_after_optimize: pure-CPU + DXC 1.9 validator test covering clamped sample_grad (0.5 setting TiledResources and 0.0 clearing it per DXC 1.9 hasSampleClamp) with a dead entry heap handle eliminated by optimize(), plus split-wave64 isolation of WaveOps, NativeLowPrecision, and DoubleExtensions (Tertiary::Fma op 47).
    • dispatch_chain_transports_live_f16_and_f64_across_cuts: DXC 1.9 validation of a 3-piece chain where live f16 (including -0.0f16) and f64 cross cuts over an intermediate piece that uses neither type, plus skip_test-guarded bit-for-bit GPU readback against the unsplit shader and CPU reference.

Tested

  • Pre-fix failing-first (CPU + DXC 1.9.2609.5): 0 passed, 2 failed — dispatch_chain_prunes_piece_local_features_after_optimize refused piece 1 of 2 (error: Flags must match usage.) and dispatch_chain_transports_live_f16_and_f64_across_cuts returned None from split_compute (transport_words rejected Half / Double).
  • Post-fix cargo test --release -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1 --nocapture on NVIDIA GeForce RTX 4060 (driver 621.14, DXC 1.9.2609.5): 10 passed, 0 failed, 0 ignored (1.14 s, 0 skipped).
  • Post-fix XCL_ADAPTER=warp cargo test --release -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1 --nocapture: 10 passed, 0 failed, 0 ignored (0.03 s); pure-CPU/DXC 1.9 tests (dispatch_chain_prunes_piece_local_features_after_optimize, dispatch_chain_declares_typed_uav_loads_only_where_they_are, oversized_loop_occupies_one_piece_up_to_the_hard_ceiling) ran with 0 skips, and dispatch_chain_transports_live_f16_and_f64_across_cuts validated all 3 split pieces + whole shader with DXC 1.9 before skipping GPU execution (SKIPPED: no wave32 GPU).
  • Cold NVIDIA GeForce RTX 4060 CreateComputePipelineState timings (fresh-named .exe copies per mode with unique bytecode salt, verified cold by immediate 2nd warm call, on synthetic 16-loop shaders that 0829441 refused to split):
    • tiled_clamp (hash a1baa443fcac1d43, 1,465 DXIL insts, 16,996 B whole -> 6 pieces): whole cold 53.78 ms (warm 0.411 ms) vs parallel 6-piece cold wall 28.23 ms (max piece 27.54 ms, sum 90.97 ms, max warm 1.147 ms) — 1.91x faster cold wall (-47.5%).
    • live_f16_f64 (hash 95eb3b58dad86457, 1,470 DXIL insts, 17,008 B whole -> 6 pieces): whole cold 37.18 ms (warm 0.375 ms) vs parallel 6-piece cold wall 20.50 ms (max piece 19.48 ms, sum 87.19 ms, max warm 0.359 ms) — 1.81x faster cold wall (-44.9%).
  • Full release workspace (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture on RTX 4060): 23 test binaries, 1274 passed, 0 failed, 46 ignored; 28 pre-existing hardware/debug-layer SKIPPED lines (0 in split::tests): 21 no wave64 (RTX 4060 is wave32-only), 3 per-lane form: refused (lower_dxil::tests wave32 per-lane), 2 no D3D12 debug layer / no d3d12SDKLayers.dll, 1 cannot disable the driver cache (shaders::tests::pso_measurement_compiles_an_exact_synthetic_record), 1 no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form).

Regression run

Base (origin/main 082944135cd2b96288470a595861fa608eee08dc):

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

PR head (1f70e6796fbd0a8e893d264497135a8235607321):

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

Not tested

  • Wave64-capable hardware (RTX 4060 is wave32-only), AMD/Intel GPUs, and GPUs lacking Native16BitShaderOpsSupported.
  • D3D12 debug layer tests (d3d12SDKLayers.dll is not installed on this host).

AI use

Google Antigravity (Gemini 4 Neon) assisted with checking DXC 1.9 DxilShaderFlags rules, implementing per-piece feature inference and f16/f64 transport in split.rs, adding regression tests, and running the verification suite and cold-PSO benchmarks.

…16/f64

Part of xcl-dev#2088
Part of xcl-dev#1269

Follow-up to xcl-dev#2080 in compute dispatch splitting (`dxil/module/split.rs`):

- Run `dst.m.optimize()` before `dst.infer_piece_features()` and emit via
  `dst.finish_optimized(threads, Some(32))` so dead instructions eliminated by
  piece optimization (such as `createHandleFromHeap` whose index was packed
  for a later piece) never trigger stale feature flags.
- Scan only live instructions in `self.m.blocks` and accurately re-infer
  piece-local flags to match DXC 1.9 `DxilShaderFlags`: `ResourceHeapIndexing`,
  `SamplerHeapIndexing`, `WaveOps`, `TiledResources` (`checkAccessFullyMapped`
  and non-undef, non-zero-constant sample LOD clamps),
  `TypedUavLoadAdditionalFormats` (multi-component typed UAV `textureLoad` and
  `bufferLoad`), `NativeLowPrecision`, `DoubleExtensions` (`dx.op.tertiary.f64`
  `Fma` op 47 in addition to `infer_type_features`), and 64-bit atomics.
- Support `TypeDef::Half` (1 scratch word via `bitcast half <-> i16` plus
  `zext`/`trunc`) and `TypeDef::Double` (2 scratch words via `split_double` /
  `make_double`) in `transport_words`, `pack`, and `unpack`.
- Add regression tests verifying per-piece feature pruning under DXC 1.9 and
  bit-for-bit GPU execution of live `f16` and `f64` values crossing cuts.

Assisted-by: Google Antigravity (Gemini 4 Neon)
@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

One red on this lane: the new transports test crashes inside d3d12core.dll under Wine.

  • gpu_ suite (--release --locked, --test-threads=2): 144 passed / 3 failed / 1 ignored, same three baseline failures as plain origin/main on this rig (rig's known baseline: fuzz seed 1003 of DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed).
  • dispatch_chain_prunes_piece_local_features_after_optimize: passes, targeted run.
  • dispatch_chain_transports_live_f16_and_f64_across_cuts: deterministic crash, 4/4 runs, and it is not a Rust panic. With WINEDEBUG=warn+seh (the default -all hides this), wine reports EXCEPTION_ACCESS_VIOLATION (0xc0000005); the whole unwind is inside d3d12core.dll (+0x1AB118, +0x1784EC, +0x1A1676, +0x1A7852, +0x1A9450, +0x0DF8DB) called from the test exe frame. Process exit status 5 (= 0xC0000005 truncated), which is why it looked silent at first.
  • Control context that keeps this on the PR: the rig's generic f16 coverage on the same build passes (gpu_cvt_norm_f16_exact_rounding_and_edge_cases, gpu_f16_defaults_to_round_to_nearest_even, gpu_s_round_mode_controls_f16_rounding_across_modes are all among tonight's 144), so it is not blanket f16 breakage on RADV.
  • Corroboration: the new offline_split_compute_pipeline_is_reused_by_a_second_process e2e from Shaders: prebuild split compute dispatch-chain pieces under --pipelines #2338 crashes at the same d3d12core.dll offsets on this lane (also deterministic), while the pre-existing offline_compute_pipeline_is_reused_by_a_second_process passes inside the same test binary (4 passed / 1 failed / 1 skipped). Two different new split-chain pipeline paths AV at one site in the shim; native Windows lanes (author, Aniseto, DarkPanda69) do not see it.

Reading: something in the new split-chain piece transport builds a pipeline shape this Linux stack (patched vkd3d-proton 3.1 + Mesa 26.2.5 + RADV) faults on inside the D3D12core shim. I cannot say from a stripped backtrace whether the faulting code is XCL's vkd3d-proton patch or upstream vkd3d-proton; a debug-pdb run on a Wine/Proton bot would pin it. Addresses are module-relative offsets into the vkd3d-proton 3.1 XCL-patched d3d12core.dll as shipped on this lane.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@amazedturnip

Copy link
Copy Markdown
Contributor

Independent AMD Radeon (native wave64) verification of exact head 1f70e6796fbd0a8e893d264497135a8235607321 (clean detached worktree, compared against main 3f4495a2b325).

Tested

  • Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc
  • Adapter: AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64) (XCL_ADAPTER=radeon, native wave64)
  • Targeted unit tests (debug): cargo test -p xcl --lib gpu::dxil -- --test-threads=2 — 158 passed, 1 failed, 3 ignored (exit 101); failed: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1

Regression run (scripts/smoke.ps1 -Seconds 60, release build, XCL_ADAPTER=radeon)
main:

xcl-smoke v1
commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09
gpu: AMD Radeon(TM) Graphics
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 782 (PresentX 782)
presents per 2 s (last 3): 34 2 2
device removals: 0
crashes: 0
peak commit: 13996 MB

PR:

xcl-smoke v1
commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09
gpu: AMD Radeon(TM) Graphics
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 819 (PresentX 819)
presents per 2 s (last 3): 32 31 31
device removals: 0
crashes: 0
peak commit: 14067 MB

Not tested

  • Full workspace test suite and NVIDIA wave32 adapter (verified targeted subsystem tests + 60 s retail smoke on AMD Radeon native wave64 only)

AI use

  • Antigravity CLI orchestrated worktree checkout, local build/test/smoke execution, and summary formatting; all test and smoke outputs above are verbatim from this machine.

@raylitebull

Copy link
Copy Markdown
Member

Diff review on 1f70e67 (infer_piece_features after optimize + live 16/ 64 transport in split.rs): clean change on the compiler side and Windows native checks are green, but holding merge until the deterministic d3d12core.dll access violation reported on dispatch_chain_transports_live_f16_and_f64_across_cuts under Wine/vkd3d-proton is diagnosed and resolved.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@SashaTun

SashaTun commented Nov 25, 2026 •

Copy link
Copy Markdown

Test report on an NVIDIA card (Windows, retail title).

Tested

  • Commit: 1f70e6796fbd0a8e893d264497135a8235607321 (fix-2080-split-features-f16-f64), clean checkout of the PR head, no uncommitted changes.

  • Hardware: NVIDIA GeForce RTX 5060 (8 GB), driver 32.0.16.2101; 31.9 GB RAM; Windows 11 build 26200 x64.

  • Toolchain: Rust 1.100.0 (stable-x86_64-pc-windows-msvc); DXC 1.9 (Windows SDK 10.0.26100.0); release profile; no XCL_SAMPLE_* variables.

  • Command: cargo test --release --workspace --no-fail-fast -- --test-threads=4
    → 1270 passed, 4 failed, 46 ignored; 28 SKIPPED lines (21 of them no wave64 — this card runs 32-wide waves only).

  • The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0,1,2,3}, all with the same error: CreateComputePipelineState: 0x8007000E (out of memory) — the 8 GB VRAM wall. The same 4 failures occur on main on this card, so they are not from this PR.

  • Regression run on a retail title (scripts/smoke.ps1, 60 s, same title, same duration, same card, both runs from a clean data directory; the main block is on the commit this branch forked from):

    xcl-smoke v1
    commit: 68a284a596bd558b6bd9db6eedda6d6aa178c360
    gpu: NVIDIA GeForce RTX 5060
    title: 3c290c16
    seconds: 60
    exit: 0x0
    frames shown: 912 (PresentX 912)
    presents per 2 s (last 3): 42 41 42
    device removals: 0
    crashes: 0
    peak commit: 15022 MB
    
    xcl-smoke v1
    commit: 1f70e6796fbd0a8e893d264497135a8235607321
    gpu: NVIDIA GeForce RTX 5060
    title: 3c290c16
    seconds: 60
    exit: 0x0
    frames shown: 855 (PresentX 856)
    presents per 2 s (last 3): 41 37 35
    device removals: 0
    crashes: 0
    peak commit: 14978 MB
    

    The PR's run shows no device removal and no crash, 855 frames against main's 912 (≥ 80 %) and a peak commit of 14 978 MB against main's 15 022 MB (≤ 125 %).

Not tested

  • AMD cards (none here) and wave64-only GPUs: this card runs 32-wide waves, so the wave64 tests skip and the split-wave64 path is the one that runs. This PR changes what a split piece declares and how f16/f64 cross a cut, so the wave32 path is where it is exercised here.
  • The title's world load: the 60 s run stays in the menus and does not reach the large compute dispatches this PR is about (the menu runs at 30–21 fps on this card, and the title's compute prestream starts much later), so this is a regression check, not a check of the PR's own behaviour. The PR's own tests cover the piece-local features and the f16/f64 transport.
  • The PR branch is 28 commits behind main, so the tree tested here is the branch head as it stands. main has one further failure on this card that this branch does not contain: gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, a test added after the branch point. It is not card-specific - main's own CI fails on it too - and I am reporting it separately.

AI use

MiniMax Code (MiniMax-M3.1-Flash) built the commits, ran the test suite and the smoke runs, and wrote this report from the real output.

@Decodere

Copy link
Copy Markdown
Contributor Author

@raylitebull @SlopTart — Checked the code paths behind #2344 and #2338 against origin/main:

  • Neither #2344 nor #2338 modifies pso::dispatch_chain_root_signature (u0, space2 + b0, space2 8x 32-bit root constants) or split_compute's Slab::new / Scratch::new bindings; #2338's failing test (offline_split_compute_pipeline_is_reused_by_a_second_process) does not touch split.rs or use f16/f64 at all, yet crashes at the exact same 6 d3d12core.dll offsets (+0x1AB118, +0x1784EC, +0x1A1676, +0x1A7852, +0x1A9450, +0x0DF8DB) on Wine + vkd3d-proton 3.1.
  • Note that cargo test ... gpu_ does not match origin/main's pre-existing dispatch_chain_* GPU tests (dispatch_chain_wave32_live_loops, dispatch_chain_payload_skips_middle_piece, dispatch_chain_divergent_forward_edges_3d), which also call runner::dispatch_split.

@SlopTart Could you run cargo test -p xcl --lib dispatch_chain_wave32_live_loops on unmodified origin/main to confirm whether those same d3d12core.dll offsets reproduce on main's existing split-chain path under vkd3d-proton 3.1?

@thiagocalile

Copy link
Copy Markdown

Independent test and smoke report for head 1f70e6796fbd0a8e893d264497135a8235607321 on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- split --test-threads=4: 34 passed, 0 failed, 1 ignored (0 skipped).

Regression run (scripts/smoke.ps1, release builds, XCL_ADAPTER=radeon)

main (50a9fde):

xcl-smoke v1
commit: 50a9fdef81cb796b8756a31defb0648301d002ce
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1501 (PresentX 1501)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 11951 MB

PR #2344 (1f70e67):

xcl-smoke v1
commit: 1f70e6796fbd0a8e893d264497135a8235607321
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1562 (PresentX 1562)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14657 MB

Not tested: NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants