Skip to content

Recompiler: split native wave32 compute groups beyond [32, 1, 1] - #2349

Open
saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:dxil/split-wave32-groups
Open

saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:dxil/split-wave32-groups

Conversation

@saintwolf

@saintwolf saintwolf commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Extends direct DXIL compute dispatch splitting beyond [32, 1, 1] to full-wave native wave32 threadgroup shapes without guest LDS ([8, 4, 1], [4, 8, 1], [4, 4, 2], [8, 8, 1], wave-free [128, 1, 1], etc.), and removes redundant @xcl_wt / atomic / barrier setup on single-wave 2D/3D compute groups. Part of #1269, #2088.

What is in it

  • crates/xcl/src/gpu/dxil/lanes.rs: skip allocating @xcl_wt and emitting the wave-index atomic and barriers for single-wave 2D/3D native wave32 compute groups (y * z > 1 && total <= lanes, where tid == WaveGetLaneIndex()); skip the trailing barrier on multi-wave 2D/3D groups unless sharing xcl_lds[8191].
  • crates/xcl/src/gpu/dxil/kernel.rs: enable split_compute for full-wave native wave32 groups without guest LDS (total >= 32 && total % 32 == 0), passing split_tid for multi-wave 2D/3D wave-ID prefixes.
  • crates/xcl/src/gpu/dxil/module/split.rs: size per-group scratch by total = threads[0] * threads[1] * threads[2], permit @xcl_wt only as the wave-ID prefix while gating the wave64 xcl_xs exchange state machine on has_xs (so guest barriers / shared-memory ops in native wave32 cleanly decline splitting), select FlattenedThreadIdInGroup() for wave-independent multi-wave 1D groups while keeping multi-wave 1D shaders with live dx.op.wave* / dx.op.quad* intrinsics whole (SM 6.6 does not guarantee identical quad-to-wave assignment across dispatches without a wave-ID prefix), recompute Feature::WaveOps per piece so pieces without wave ops validate, and add unit + dxil.dll validation + GPU bit-exact parity tests (including slabbed dispatch_split_by) across [8, 4, 1], [4, 4, 2], [8, 8, 1], and [128, 1, 1].

Runtime tradeoff (accepted cost)

  • Extending split_compute to the remaining full-wave native wave32 threadgroup shapes carries the same per-dispatch scratch round-trip and multi-dispatch launch overhead already accepted on main for [32, 1, 1] compute shaders (gated by XCL_DIRECT_SPLIT_INSTRUCTIONS, default 12,500; 0 disables splitting).
  • In production, only shaders exceeding 12,500 instructions split — trading a small per-dispatch chain overhead for a 3×–14× reduction in cold NVIDIA CreateComputePipelineState compilation time (11–26 s whole → 1.1–1.9 s split on the largest newly admitted shaders) and allowing parallel piece compilation. (In the synthetic GPU parity fixture, the split threshold is forced down to 40 instructions, so its ~2 µs → ~6–8 µs ratio reflects empty dispatch launch overhead rather than 12,500+-instruction shader runtime.)

Tested

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.8.2502.11.
  • Updated head 04f0bb6f (on main 9dfbe3ea):
    • cargo test -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1: 14 passed, 0 failed (including multi_wave_1d_wave_ops_decline_split and bit-exact whole vs split and slabbed GPU parity across [8, 4, 1], [4, 4, 2], [8, 8, 1], and wave-free [128, 1, 1]).
    • cargo build --release -p xcl: clean build.
  • Retail shader corpus validation (2,689 CS shaders, dxil.dll, prior head before multi-wave 1D wave-op guard): 96 newly split native wave32 shaders ([8, 4, 1]: 86, [4, 8, 1]: 6, [4, 4, 2]: 2, [8, 8, 1]: 1, [128, 1, 1]: 1) produced 287 validated pieces with 0 validation errors (existing 806 [32, 1, 1] shaders / 7,906 pieces also validated with 0 errors).
  • Head-to-head cold NVIDIA CreateComputePipelineState A/B benchmark (main 06c9f55 vs this branch, release builds, 4 UMA windows, warm 2nd calls 1.33–8.52 ms) across the top 8 newly split native wave32 shaders:
    • Total cold wall time: 115.30 s → 37.73 s (3.06× faster, -67.3%); total CPU compile time: 115.30 s → 62.82 s (1.84× less, -45.5%).
    • Largest shaders: [4, 4, 2] (56ddc92162fbb20f, 8 pieces) 25.80 s → 1.86 s (13.9×); [8, 4, 1] (de83041b451429d1 / 0526ab24d5e0993b / d53818c323d15ea1, 6 pieces each) 13.18–14.27 s → 1.16–1.32 s (9.8×–11.4×); [128, 1, 1] (14009b6da78ed223, 5 pieces) 11.52 s → 1.57 s (7.4×).

Regression run

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1045 (PresentX 1045)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14930 MB
xcl-smoke v1
commit: 04f0bb6ff085f84a939388b739612f3eb2b8746f
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15380 MB

Not tested

  • AMD RDNA / native wave64 GPUs and Intel GPUs on 04f0bb6f (tested on NVIDIA RTX 4070 SUPER locally; earlier heads were also verified on AMD RDNA2/RDNA4 and Intel Arc A770 in comments above).
  • Warmed per-dispatch GPU runtime of newly split 12,500+-instruction shaders during in-world play (the 60 s smoke covers menus; see Runtime tradeoff above).

AI use

  • Antigravity (Gemini 4 Neon) for corpus profiling, implementation, tests, benchmarking, rebase, SM 6.6 multi-wave 1-D wave-op guard, and PR drafting; all builds, tests, benchmarks, and smoke runs were executed locally on the hardware above.

@DarkPanda69

Copy link
Copy Markdown

AMD native wave64 run (listed as untested), plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite.

Head 63131c6 applied on main 3f4495a, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, waves 32..64) 643 passed, 2 failed, 22 ignored, 6 SKIPPED 645 passed, 2 failed, 22 ignored, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32 only) 645 passed, 0 failed, 22 ignored, 24 SKIPPED 647 passed, 0 failed, 22 ignored, 24 SKIPPED

Per-test comparison: on both cards the only differences are the 2 new tests (dispatch_chain_native_wave32_group_shapes_match_whole, single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split, both ok). No existing test changes result or skip state. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same on main.

Not tested: the newly split [8, 4, 1] programs of a title, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@Aniseto

Aniseto commented Nov 25, 2026

Copy link
Copy Markdown

Ran the split-compute tests at 63131c6:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu::dxil::module::split -- --test-threads=4 --nocapture
10 passed; 0 failed; 0 ignored; 1221 filtered out      (exit 0)

All ten tests pass, including dispatch_chain_native_wave32_group_shapes_match_whole; the --nocapture output confirms the GPU parity checks ran on NVIDIA GeForce RTX 5070 Ti for [8, 4, 1], [4, 4, 2], [8, 8, 1] and [128, 1, 1], with no device skip.

What this adds: the author tested an Ada RTX 4070 SUPER with DXC 1.8.2502.11; this is a Blackwell wave32 part with DXC/DXIL 1.9.2609.5. No test report exists in the thread yet.

Not tested: the whole workspace suite, the retail shader corpus validation, the cold PSO compile A/B, a paired 60 s smoke run, AMD/native wave64 and Intel GPUs, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@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 group-shapes test crashes at the same d3d12core.dll site as the #2338 and #2344 crash reports.

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.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@FIJI1299

FIJI1299 commented Nov 25, 2026 •

Copy link
Copy Markdown

Re-tested commit 63131c6 on Windows after updating to NVIDIA driver 621.40:

Environment

  • OS: Windows 11 (Build 26100)
  • CPU: AMD Ryzen 5 9600X 6-Core Processor
  • RAM: 32 GB
  • GPU: NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.40, native wave32 / no wave64)
  • DXC: 1.8.2502.11 (Windows SDK 10.0.26100.0)

Results

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@raylitebull

Copy link
Copy Markdown
Member

Diff review (wave32 group-shape checks) and CI look clean, and Windows native/split coverage is solid, but holding merge until the deterministic d3d12core.dll + 0x1AB118 (0xc0000005) access violation reported on dispatch_chain_native_wave32_group_shapes_match_whole under Wine/vkd3d-proton is diagnosed or resolved.

@saintwolf

saintwolf commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@raylitebull That d3d12core.dll + 0x1AB118 (0xc0000005) Wine/vkd3d-proton 3.1 crash is the same pre-existing upstream fault already on main since #2080 — @ivall confirmed this on #2338 (which hit the exact same d3d12core.dll + 0x1AB118 offset and was merged):

On the open item: the crash under Wine is not from this PR. The report on #2080 (before this PR) has the fault at 0x6ffffca2b118 with d3d12core.dll loaded at 0x6ffffc880000, which is d3d12core.dll+0x1AB118, the first offset of the report here. #2080 is on main already, and the native Windows runs on NVIDIA and AMD pass. What vkd3d-proton trips over is still open and deserves its own issue.

All native Windows reports here (AMD RX 9070 XT wave64, NVIDIA RTX 5070 Ti / 5070 / 4070 SUPER / 3060 Ti / 3060) are green, so this isn't a regression from #2349.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source-level defect found. The admission gates exclude partial/LDS groups, continuation identity is correct across admitted group shapes, and the GPU parity coverage is substantial; current CI and AMD/NVIDIA reports are green. Residual validation gap: no retail-title exercise of the newly admitted 2-D/3-D group shapes and no Intel run. Those should remain explicit, but I found no merge blocker.

@CalvyPZ CalvyPZ added the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ CalvyPZ closed this Nov 25, 2026
@CalvyPZ CalvyPZ reopened this Nov 25, 2026
@CalvyPZ CalvyPZ removed the duplicate This issue or pull request already exists label Nov 25, 2026
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
@Prime1997

Copy link
Copy Markdown
Collaborator

@saintwolf I published the tested main integration branch in xcl-dev/xcl, retaining your authorship. It applies 63131c64 to main 8b957bec and resolves this PR's conflict.

This preserves main's #2371 scratch-slot reuse hook while using the full threadgroup size for scratch. The tests include four wave32 group shapes and the existing divergent-edge regression, with the reuse hook checked both enabled and disabled.

Local result: 6 passed, 0 failed, 0 ignored, 0 explicit skips on the RTX 3060 Ti. Each exact filter ran separately with --test-threads=1 --nocapture after a fresh cargo test --locked -p xcl --lib --no-run build, with 1,346 tests filtered out per invocation. The branch is available for the PR rebase. The focused checks leave full-suite, exact-head title smoke, and the maintainer RDNA4 batch validation pending.

AI use: Codex (GPT-6) resolved the conflict and verified the focused checks. Optional temporary Discord for coordinating contributor work, testing, and comparing results.

saintwolf added a commit to saintwolf/xcl that referenced this pull request Nov 26, 2026
Single-wave 2D/3D native wave32 compute groups (y * z > 1, total <= 32) no longer allocate @xcl_wt or emit the wave-index atomic and barriers, since tid equals WaveGetLaneIndex(). Multi-wave 2D/3D groups also skip the trailing barrier unless sharing xcl_lds[8191].

Extend direct DXIL compute dispatch splitting to all full-wave native wave32 threadgroup shapes without guest LDS (total >= 32, total % 32 == 0): size per-group scratch by total threads, preserve @xcl_wt only as the wave-ID prefix for multi-wave 2D/3D groups while gating the wave64 exchange state machine on xcl_xs, select FlattenedThreadIdInGroup() for multi-wave 1D groups, and recompute Feature::WaveOps per piece so pieces without wave ops validate.

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

Assisted-by: Antigravity (Gemini 4 Neon)

Resolve the merge conflict against current main 8b957be. Keep main’s scratch-slot reuse hook and the PR’s full threadgroup sizing.

Original-PR: xcl-dev#2349
Original-commit: 63131c6
Assisted-by: OpenAI Codex (GPT-6)
@saintwolf
saintwolf force-pushed the dxil/split-wave32-groups branch from 63131c6 to 6aa4e2f Compare November 26, 2026 18:04
@saintwolf

Copy link
Copy Markdown
Contributor Author

@Prime1997 Thanks for resolving the conflict on review/2349-main-8b957bec! Applied that exact resolution onto e120925e (merges cleanly onto main 8b957bec with zero conflicts) at 6aa4e2f5, preserving #2371's scratch-slot reuse hook alongside full threadgroup sizing.

  • Full .\scripts\test.ps1 passed with 0 failures and a fresh 60 s scripts/smoke.ps1 run at 6aa4e2f5 is updated in the PR description.

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2349 rebased head 6aa4e2f578dfdc2b296c38eb30129f45439ea8d5 (exact parent & merge-base e120925e3abc9956a8b9bae631969d32e8ccd43c). Measurements and targeted GPU/unit test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, quiet machine (zero concurrent builds/tests during timed runs; note gpu/dxil/* edits give 6aa4e2f5 a fresh XCL_DIRECT_DXIL_SOURCE_ID namespace)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (6aa4e2f5)

  • cargo test --release -p xcl --lib single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib dispatch_chain_native_wave32_group_shapes_match_whole -- --nocapture: 1 passed, 0 failed, 0 ignored (0.49 s, executed on RTX 4060, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::dxil::module::split:: (3 consecutive parallel passes): 10 passed, 0 failed, 0 ignored on all 3 passes (0.35 s / 0.34 s / 0.35 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::dxil::: 186 passed, 0 failed, 3 ignored (4.00 s; 1 SKIPPED: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole skipped no wave64 on NVIDIA wave32 RTX 4060).

Paired 60 s RTX 4060 smoke (exact parent e120925e vs 6aa4e2f5)

Both runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (6aa4e2f5 vs e120925e xcl.log: 6,115 vs 6,114 MB peak/end local VRAM, 4,651 MB end non-local VRAM on both, 19,663 vs 19,588 translated draws / 1,024 dispatches with 0 skipped).

Exact parent (e120925e):

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

PR #2349 head (6aa4e2f5):

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

Limits of coverage

  • Full workspace test suite was not run on 6aa4e2f5 (only the 2 new tests individually, 3 parallel passes of gpu::dxil::module::split::, all 186 passing tests in gpu::dxil::, release build, and exact-parent paired 60 s smokes); dispatch_chain_native_wave64_builds_whole skipped no wave64 on wave32 NVIDIA hardware.
  • The 60 s no-input menu/intro smoke hit 0 split-compute programs (compute split: 0 programs split, 0 pieces built, 0 chained dispatches issued in 0 slabs; scratch 0 MiB), so split 2D/3D native-wave32 execution vs whole-shader parity was exercised on-GPU by dispatch_chain_native_wave32_group_shapes_match_whole rather than live in-world split compute dispatches.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit/GPU tests, release build, and exact-parent paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@upipibi

upipibi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Tested head 6aa4e2f5, merge-base e120925e, RTX 3070 (Ampere) driver 616.56, Windows 11, rustc 1.100.0. Debug build, no env vars, no game files.

  • PR's tests, cargo test -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1, 3 runs on head: 10 passed, 0 failed each time.
  • Negative control: only the PR's test hunk applied to the merge-base e120925e: 8 passed, 2 failed. dispatch_chain_native_wave32_group_shapes_match_whole and single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split fail there.
  • cargo test -p xcl --lib -- --test-threads=4 --skip hle::xaudio2 (9 filtered out on both trees):
    • head: 1307 passed, 1 failed (27 ignored)
    • merge-base: 1306 passed, 0 failed (27 ignored)
    • The one failure was hle::kernelx::tests::a_sleep_stops_counting_when_the_title_gets_held, a timing test the PR doesn't touch. Run alone with --exact, 5 times on each tree, it gave 1 passed, 0 failed every time on both. So I read it as load-related flakiness from the parallel run, not a regression.
  • SKIPPED lines: 25 on both trees, the same set (wave64 not available on this card, 3 per-lane f16 forms refused, 1 driver-cache test).

Not tested: retail title.

AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 ran the reruns, checked and posted).

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean 6aa4e2f578dfdc2b296c38eb30129f45439ea8d5, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. Four CPU/DXIL toolchain controls and six Arc fixtures passed, with zero failures, ignores or skips. Built with cargo test -p xcl --lib --no-run -j 2, then each exact test with --nocapture --test-threads=1. dispatch_chain_native_wave32_group_shapes_match_whole tested [8,4,1], [4,4,2], [8,8,1] and [128,1,1] thread groups. The four whole shaders and all 14 split pieces validated. Whole and split readbacks matched the CPU reference bit for bit, including slab limits of 1, 3, and 7 groups.

Not tested: Native wave64, [4,8,1] groups, workspace suite, retail smoke and performance.

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

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the reports above by Decodere, JJAutoCompare, upipibi, since none of them covers AMD. Tested exact head 6aa4e2f5 (on its base e120925).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1432 passed, 0 failed, 45 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split, dispatch_chain_native_wave32_group_shapes_match_whole.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1443 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main c2ee10e4 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

saintwolf added a commit to saintwolf/xcl that referenced this pull request Nov 28, 2026
Single-wave 2D/3D native wave32 compute groups (y * z > 1, total <= 32) no longer allocate @xcl_wt or emit the wave-index atomic and barriers, since tid equals WaveGetLaneIndex(). Multi-wave 2D/3D groups also skip the trailing barrier unless sharing xcl_lds[8191].

Extend direct DXIL compute dispatch splitting to all full-wave native wave32 threadgroup shapes without guest LDS (total >= 32, total % 32 == 0): size per-group scratch by total threads, preserve @xcl_wt only as the wave-ID prefix for multi-wave 2D/3D groups while gating the wave64 exchange state machine on xcl_xs, select FlattenedThreadIdInGroup() for multi-wave 1D groups, and recompute Feature::WaveOps per piece so pieces without wave ops validate.

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

Assisted-by: Antigravity (Gemini 4 Neon)

Resolve the merge conflict against current main 8b957be. Keep main’s scratch-slot reuse hook and the PR’s full threadgroup sizing.

Original-PR: xcl-dev#2349
Original-commit: 63131c6
Assisted-by: OpenAI Codex (GPT-6)

# Conflicts:
#	crates/xcl/src/gpu/dxil/kernel.rs
@github-actions github-actions Bot removed the needs:amd-test Needs a test report or merge-check on an AMD GPU label Nov 30, 2026
@saintwolf

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and timing check, @thehollowedone!

Two updates on this PR:

  1. Rebased onto latest main (9dfbe3ea) → 5737eb7e (preserving lw.safe_barrier_init() in kernel.rs and main's always-on reuse_piece_slots in module/split.rs). Re-verified cargo test -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1 (13 passed, 0 failed) and a fresh 60 s release smoke (1654 frames, 0 device removals/crashes, 15415 MB peak commit).
  2. Documented the accepted runtime cost in the PR description under Runtime tradeoff: expanding split_compute to the remaining full-wave native wave32 shapes carries the same per-dispatch scratch round-trip and multi-dispatch launch overhead already accepted on main for [32, 1, 1] shaders (XCL_DIRECT_SPLIT_INSTRUCTIONS, default 12,500, 0 disables). In production it only triggers on 12,500+-instruction shaders (where cold NVIDIA compile drops from 11–26 s to 1.1–1.9 s), whereas the 40-instruction synthetic fixture reflects empty dispatch launch overhead.

Ready for re-check when you have a moment!

@Gevroska

Gevroska commented Nov 30, 2026 •

Copy link
Copy Markdown

@saintwolf I measured the runtime tradeoff on my RTX 3080 (driver 616.92) using the production code from 5737eb7e with a local test fixture. A generated native wave32 compute shader with an [8,8,1] thread group reached 15,327 optimized instructions. At the default 12,500-instruction threshold, the PR split it into two pieces. The same input stayed whole on main at 9dfbe3ea and on the PR with XCL_DIRECT_SPLIT_INSTRUCTIONS=0.

Across 128 groups, both forms matched all 8,192 expected output words and preserved all 16 guard words. With 32 GPU timestamp samples per form after warmup, median execution time was 41.984 µs whole and 43.008 µs split. An independent run reproduced both the readback and the timings.

That puts the extra GPU execution time at about 1 µs for this generated workload. I haven’t verified that some retail uses this shader shape above the threshold, so I can’t infer a frame-time impact from this test.

I used Codex GPT-6.2 Sol to write and run the fixture. A separate GPT-6.2 Sol agent reviewed the source, and GPT-6.1 Terra independently repeated the Windows and GPU checks. Codex GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@AAsobu

AAsobu commented Nov 30, 2026

Copy link
Copy Markdown

merge-check claim
head: 5737eb7

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 30, 2026
@AAsobu

AAsobu commented Nov 30, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: 04f0bb6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2907 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps); failing: none. multi_wave_1d_wave_ops_decline_split, single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split and the GPU test dispatch_chain_native_wave32_group_shapes_match_whole run and pass on this wave32-only GPU.
review: no correctness finding. I read the whole diff (kernel.rs, lanes.rs, module/split.rs). The only change since 5737eb7e is in split.rs: multi-wave 1-D groups with a live dx.op.wave* / dx.op.quad* call now stay whole, plus the test for that. The default-on part that the measurement below exercises is the same as before: wider native wave32 splitting, and single-wave 2-D/3-D groups computing tid without the xcl_wt counter and barrier.
performance: measured regression in the world on this GPU. Retail title (the one that reaches the world here), release builds, main 6bfb5c5 as A and this merge as B. NVIDIA shader heap profile 2048 MB, my usual settings, XCL_FRAME_DUMP=5 on every run, 300 s runs. Before the series, one B warm-up run, because the translated cache is keyed by the binary. Window: world entry (first two-pass ExecuteIndirect) +30 s to +140 s, from the activity (2 s) lines.

run (order) presents / 2 s draws / 2 s 2 s windows with 0 presents commit MB VRAM MB
A 1st 1.06 3701 20 % 42195 17303
B 2nd 0.81 2263 35 % 40564 16512
A 3rd 0.96 3430 35 % 43590 17242
B 4th 0.76 2300 33 % 40400 16289
B 1st (reversed order) 0.87 2835 28 % 42078 17024
A 2nd (reversed order) 0.94 2830 22 % 43679 17447
  • B is slower than A in all three pairs, including the reversed one. Presents: B 0.76–0.87 against A 0.94–1.06, so the ranges do not overlap, and B's mean is 82 % of A's. Draws: B's mean is 74 % of A's.
  • B uses less memory. Within each pair, commit is 1.6–3.2 GB lower and VRAM 0.4–1.0 GB lower.
  • The B run 2nd in the first series still had a warming cache: 8554 pipelines built against 10412. The B run 4th had a warm cache (10407) and was just as slow. During the B run 4th, a registry script of mine ran for about 2 minutes, partly inside its window. Its figures match the B run 2nd, so I kept it.
  • At 300 s, A had 607 programs split, 5037 pieces and 43835 chained dispatches. B had 479, 3598 and 29405, over fewer frames.
  • No visible difference in the dumped frames: the world is mostly flat in both builds on this machine.
  • No device removal in any A or B run. One more A run (main) ended at 134 s with 0xc0000005 in nvwgf2umx.dll+0x7c89af (inside the NVIDIA driver) at world entry, before the window, so it is excluded and was repeated. It was not a B run.
  • scripts/smoke.ps1 -Game <title> (60 s, the script's own settings: no network, no preparation) on the base and on the merged tree, using the same release binaries. Neither run reaches the world in 60 s, so this only checks that nothing regresses at startup: same frames, no removal or crash, peak commit +39 MB.
xcl-smoke v1
commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
gpu: NVIDIA GeForce RTX 3090
title: dc7b94e1
seconds: 60
exit: 0x0
frames shown: 2 (PresentX 2)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 10238 MB
xcl-smoke v1
commit: 13c10e878449730bc880752e691c4fe540536234
gpu: NVIDIA GeForce RTX 3090
title: dc7b94e1
seconds: 60
exit: 0x0
frames shown: 2 (PresentX 2)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 10277 MB

verdict: not yet: on an RTX 3090 (wave32) the merged build presents about 18 % fewer frames and issues about 26 % fewer draws in the world than its base, consistently over 3 pairs including reversed order. It may be worth finding which part costs the time (the wider split, or the single-wave 2-D/3-D tid path) before enabling it by default.
hardware / tool and model: RTX 3090 24 GB (driver 621.24), i5-10600K, 32 GB, Windows 11 Home 26300 / Claude Code (Claude Opus 5.5); runs and figures checked by me.

Edited 2026-12-01: this report replaces my earlier one for 5737eb7e (safe to merge). That one was measured with a 512 MB shader heap and 180 s runs, which ended before an in-world window like the one above.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 30, 2026
@AAsobu

AAsobu commented Dec 1, 2026 •

Copy link
Copy Markdown

Correction to my report above, about the device removal it mentions (0x887a0005, DRED "page fault at GPU VA 0x0", no breadcrumbs): on this machine it was most likely NVIDIA's 512 MB shader-heap limit (#2403), not a bug of main and not a regression range.

Hardware: NVIDIA GeForce RTX 3090 24 GB (driver 621.24), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300. Tool and model: Claude Code (Claude Opus 5.5), results checked by me.

@thehollowedone

Copy link
Copy Markdown
Contributor

Source-level portability concern on current head 5737eb7e: the newly admitted multi-wave 1-D shapes use FlattenedThreadIdInGroup() to restore each thread's scratch values across pieces, but a wave operation in a later piece uses that dispatch's physical wave. Shader Model 6.6 specifies the order within each four-thread 1-D quad, while leaving the order of quads implementation-dependent. The flattened ID therefore identifies the thread, but does not guarantee that the same threads share a wave in every dispatch.

For [128, 1, 1], consider WaveReadLaneFirst before and after a cut, with each thread's input equal to its flattened ID. If a later dispatch exchanges the quads containing IDs 4–7 and 32–35 between physical waves, ID 32 restores its own saved value but its new wave's first-lane read comes from ID 0 rather than ID 32. That layout obeys the documented quad rule. The existing GPU fixture passes on the tested adapter; it cannot establish parity for every legal quad assignment.

Could the split eligibility keep multi-wave 1-D shaders with wave-dependent operations whole until the pieces can preserve the guest wave membership? A structural/CPU model regression using two legal quad assignments would pin this case without relying on a driver to choose the second layout. This is a specification-level counterexample; I did not observe a hardware failure or run a test in this review.

AI use: Codex (GPT-6.2 Sol) reviewed the PR and specification; Codex (GPT-6.2 Astra) checked the counterexample.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 04f0bb6

The existing duplicate group D85 lists this PR with #2353. #2353 (closed as superseded by #3504) and #3504 carry an earlier version of this commit (63131c6). 04f0bb6 adds a guard #3504 does not have: a multi-wave 1-D group with live wave or quad ops is kept whole (multi_wave_1d_wave_ops_decline_split). This PR is the smallest reviewable piece of that work, and it is not on main (kernel.rs still sets split_tid only for [64, 1, 1]). It overlaps #2344 in infer_piece_features, where both re-infer WaveOps. No problems found in the diff.
Recommendation: keep open.

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

Single-wave 2D/3D native wave32 compute groups (y * z > 1, total <= 32) no longer allocate @xcl_wt or emit the wave-index atomic and barriers, since tid equals WaveGetLaneIndex(). Multi-wave 2D/3D groups also skip the trailing barrier unless sharing xcl_lds[8191].

Extend direct DXIL compute dispatch splitting to all full-wave native wave32 threadgroup shapes without guest LDS (total >= 32, total % 32 == 0): size per-group scratch by total threads, preserve @xcl_wt only as the wave-ID prefix for multi-wave 2D/3D groups while gating the wave64 exchange state machine on xcl_xs, select FlattenedThreadIdInGroup() for multi-wave 1D groups, and recompute Feature::WaveOps per piece so pieces without wave ops validate.

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

Assisted-by: Antigravity (Gemini 4 Neon)

Resolve the merge conflict against current main 8b957be. Keep main’s scratch-slot reuse hook and the PR’s full threadgroup sizing.

Original-PR: xcl-dev#2349
Original-commit: 63131c6
Assisted-by: OpenAI Codex (GPT-6)

# Conflicts:
#	crates/xcl/src/gpu/dxil/kernel.rs

# Conflicts:
#	crates/xcl/src/gpu/dxil/kernel.rs
#	crates/xcl/src/gpu/dxil/module/split.rs
@saintwolf
saintwolf force-pushed the dxil/split-wave32-groups branch from 5737eb7 to 04f0bb6 Compare December 1, 2026 14:41
@github-actions github-actions Bot removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@saintwolf

Copy link
Copy Markdown
Contributor Author

Good catch on the SM 6.6 1-D quad-to-wave rule, @thehollowedone!

Updated in 04f0bb6f:

  • crates/xcl/src/gpu/dxil/module/split.rs: split_compute now keeps multi-wave 1-D native wave32 shaders (prefix.is_empty() && total > 32) whole whenever they contain any live dx.op.wave* or dx.op.quad* call (ignoring only an unconsumed dx.op.waveGetLaneIndex left behind by setup_lanes_compute). Single-wave groups (total == 32) and multi-wave 2-D/3-D groups (which replay their @xcl_wt wave-ID prefix) are unaffected.
  • Added unit test multi_wave_1d_wave_ops_decline_split verifying that [128, 1, 1] with WaveReadLaneFirst or live WaveGetLaneIndex stays whole, while wave-free [128, 1, 1] still splits and validates cleanly; updated the [128, 1, 1] case in dispatch_chain_native_wave32_group_shapes_match_whole accordingly.
  • Re-verified cargo test -p xcl --lib gpu::dxil::module::split::tests -- --test-threads=1 (14 passed, 0 failed), cargo build --release -p xcl, and a fresh 60 s smoke on 04f0bb6f (1649 frames, 0 device removals/crashes, 15380 MB peak commit).

AI use: Antigravity (Gemini 4 Neon) implemented the guard and test, ran the local tests and smoke, and drafted this reply.

@fromthemoonx

fromthemoonx commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: 04f0bb6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2907 passed, 0 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (3 files, +297 -21). No correctness problem found.

  • On wave32 hardware, full-wave native wave32 compute groups without LDS can now be split over the 12,500-instruction limit, as [32, 1, 1] already could:
    • 2-D/3-D multi-wave groups replay the xcl_wt prefix in every piece. A hardware wave still takes 32 consecutive thread IDs, so guest wave membership holds.
    • Single-wave groups continue by WaveGetLaneIndex().
    • Multi-wave 1-D groups continue by FlattenedThreadIdInGroup(), and they now stay whole when a live wave or quad op is in them (thehollowedone's SM 6.6 point).
  • gpu::dxil::module::split::tests:: 3 of 3 runs: 14 passed. The GPU test dispatch_chain_native_wave32_group_shapes_match_whole ran on this wave32 GPU (not skipped): 4/3/4/3 pieces for [8,4,1], [4,4,2], [8,8,1], [128,1,1].
  • Mutation: with the 1-D wave/quad guard off, multi_wave_1d_wave_ops_decline_split fails. Good.
  • Mutation: with every piece continuing by WaveGetLaneIndex(), dispatch_chain_native_wave32_group_shapes_match_whole fails on split [128, 1, 1]. Good.
  • Minor, not a blocker: the new gate in kernel.rs that turns the split on in translation is not reached by any test. With both new conditions there forced off (split_tid for 2-D/3-D, native_w32), all 1003 gpu:: tests still pass. The tests call setup_lanes_compute and split_compute directly. A test through translate with an [8,8,1] wave32 program over the limit would cover it.
  • lanes.rs drops the barrier after the xcl_wt atomic unless the counter sits in guest LDS (word 8191). This also changes AMD native wave64 2-D/3-D programs, and I read it as safe:
    • Every thread stores the zero before the first barrier, so all atomics come after it.
    • Nothing else writes xcl_wt.
    • The wave64 single-wave path was not run here (no wave64): its form is only validated in single_wave_2d_3d_omits_xcl_wt_and_guest_barrier_declines_split.
  • src/gpu/dxil is in the translator identity, so cached translations rebuild once after the update.
  • No retail title on this machine: a split of a real newly eligible shader was not run here.
    performance: not measured here. By default, on wave32 GPUs, eligible programs over 12,500 instructions now run as several dispatches. Gevroska measured about 1 µs more GPU time for a 15,327-instruction [8,8,1] program. The faster cold compile is the author's measurement. Groups that drop the xcl_wt atomic or a barrier can only get cheaper.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look goal:world-load Bears on the retail title getting past world loading gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.