Skip to content

Recompiler: defer large per-lane compute shaders to compact direct DXIL - #2796

Open
Saksukella wants to merge 1 commit into
xcl-dev:mainfrom
Saksukella:fix/bound-3d-commit-memory
Open

Saksukella wants to merge 1 commit into
xcl-dev:mainfrom
Saksukella:fix/bound-3d-commit-memory

Conversation

@Saksukella

@Saksukella Saksukella commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Under XCL_PER_LANE=1, pso::direct_compute() previously ran lower_dxil::compute_with() before gpu::dxil::kernel::translate_compute_rodata() and returned immediately on Ok(k), bypassing compact::automatic_plan() and split_compute(). As a result, large repetitive branch-heavy compute shaders emitted monolithic multi-megabyte DXIL and triggered large driver-compiler commit spikes. This PR routes compact-qualified compute shaders through pso::choose_compute_kernel() first (falling back to per-lane on error rather than dropping to HLSL) and caps per-lane compute DXIL at 512 KiB when a smaller or split per-instruction alternative is available.

What is in it

  • crates/xcl/src/gpu/dxil/mod.rs: make compact pub(crate).
  • crates/xcl/src/gpu/dxil/compact.rs: add prefers_compact(code, split_compute) backed by automatic_plan_impl(&cfg, None, split_compute) so early deferral requires both large() (or split_compute && atomic_candidate()) and automatic_plan repetition/table-size qualification.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: add pub(crate) const MAX_COMPUTE_DXIL_BYTES: usize = 512 << 10.
  • crates/xcl/src/gpu/recomp/pso.rs: add choose_compute_kernel() in direct_compute() so:
    • early deferral lives in pso::direct_compute() rather than lower_dxil::compute_with() (keeping xcl shaders per-lane coverage surveys clean);
    • if a compact-preferred shader fails translate_compute_rodata(), it logs a warning and falls back to lower_dxil::compute_with() instead of dropping straight to HLSL;
    • if per-lane DXIL exceeds 512 KiB, it compares against translate_compute_rodata() (logging warnings on error) and picks whichever is split or smaller;
    • add unit tests in #[cfg(test)] mod pr2796_tests.
  • crates/xcl/src/gpu/dxil/compact_tests.rs: add prefers_compact_requires_both_large_and_automatic_plan verifying large repetitive programs defer while small and large non-repetitive programs do not.

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 9 7900X, 32 GB RAM, Windows 11 Pro (build 26200), rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test --lib -p xcl pso -- --test-threads=4: 250 passed, 0 failed, 1 ignored (2.69s), including all 3 pr2796_tests cases (SKIPPED: shaders::tests::pso_measurement_compiles_an_exact_synthetic_record requires Windows Developer Mode).
  • cargo test --lib -p xcl prefers_compact -- --test-threads=4: 1 passed, 0 failed (0.20s).
  • cargo check --workspace: passed.

Regression run

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17279 MB
xcl-smoke v1
commit: d01016e37de3bf1774576821fbd415b8def9a810
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1689 (PresentX 1689)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17683 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).
  • Full cargo test --workspace run (targeted pso + prefers_compact suites + cargo check --workspace + 60s TitleID 7952987A smoke run were executed).

AI use

  • Assisted with automatic_plan rebase, choose_compute_kernel unit test authoring, and verification; all diffs, tests, and hardware smoke runs were verified locally.

@ettehn

ettehn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent Windows/NVIDIA check on 7a8056faf35e7c24d38e639ae893b89ff775a2c0. The only local change was a test probe using the existing synthetic repeated fixture. The default selection produced byte-identical output to the expected forced form in both cases.

Reachable blocks Non-terminators Default form Plain DXIL Compact DXIL
1,603 3,604 Plain 63,604 B 4,924 B
2,003 4,504 Compact 79,904 B 5,224 B

A single-block fixture independently confirmed the instruction gate: compact::large was false at 9,999 non-terminators and true at 10,000. Two existing small GPU tests confirmed plain/compact output parity and matching loop-budget behavior.

Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop GPU (12 GB, driver 621.24), Rust 1.97.1 MSVC debug, DXC 1.8.2502.11, XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64:

cargo test --locked --offline -p xcl --lib -j 2 -- compact_threshold_probe a_large_program_that_repeats_itself_takes_the_compact_form gpu_compact_form_runs_as_the_plain_form gpu_compact_form_spends_the_loop_budget_as_the_plain_form --test-threads=1 --nocapture

4 passed, 0 failed, 0 ignored, no reported skips. The threshold fixtures were translated only. This run did not measure NVIDIA driver compile commit, run the full workspace suite, or launch a retail title.

OpenAI Codex assisted with the probe and verification. The exact model identifier was unavailable in this session.

@DarkPanda69

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head 960f4fc: still passes on both cards. On the newer amd-dev c32c91a, gpu::dxil::compact plus the new test gives 13 passed, 0 failed, 0 SKIPPED on the RTX 3060 and the RX 9070 XT, per_lane_compute_defers_branch_heavy_program_to_compact_path ok on both.

Update for head efb6e48: same result on both cards. On amd-dev b5c0275, gpu::dxil::compact gives 12 passed, 0 failed, 0 SKIPPED on the RTX 3060 and the RX 9070 XT (11 without the PR), and the new per_lane_compute_defers_branch_heavy_program_to_compact_path passes by name on both.


NVIDIA run for the Not tested line, with the RX 9070 XT from the same PC.

Tested: pass, head 7a8056f applied on its base amd-dev b5c0275, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, card picked with XCL_ADAPTER.
cargo test -p xcl --lib -- gpu::dxil::compact --test-threads=4 --nocapture:

  • NVIDIA RTX 3060, driver 32.0.16.1088: 11 passed, 0 failed, 0 SKIPPED.
  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: 11 passed, 0 failed, 0 SKIPPED.

amd-dev without the PR gives the same counts on both cards.

Not tested: a title run or the cs 56c0cd3b82a00c6e driver compile on NVIDIA; Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@Saksukella

Copy link
Copy Markdown
Contributor Author

Follow-up in \efb6e48e: during live \XCL_PER_LANE=1\ testing we found \lower_dxil::compute_with()\ in \pso.rs\ returned before \gpu::dxil::kernel::translate_compute(), bypassing \compact::large()\ and still emitting \2,673,860 B\ DXIL for \cs 56c0cd3b82a00c6e. Deferring \compact::large(&cfg)\ out of \lower_dxil::compute_with()\ (and falling back when per-lane DXIL exceeds \512 KiB\ and compact/split is smaller) now routes \cs 56c0cd3b82a00c6e\ through compact form at runtime (\160,534 B, \16.7x\ smaller), cutting 180s RX 9070 XT peak commit from \63,298 MB\ to \34,190 MB\ (-29.1 GB). Re-verified with \7/7\ CPU \compact\ tests and fresh 60s RX 9070 XT smoke (\1661\ frames, \60 61 60, \

@frozht

frozht commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Test report on a retail compute shader that crosses the new threshold but does not take the compact form. Linux/RADV, tested at head 7a8056fa (before efb6e48e), not on amd-dev.

Setup: RX 7900 XT 20 GB (gfx1100), Mesa 26.2.6 RADV, vkd3d-proton 30b0eb9b under Wine (wine-staging 11.22), Ryzen 9 5900X, 32 GB, Linux 7.3, release build (x86_64-pc-windows-gnu). Base: main b49be183 + #877, #684, #1993, #2127 (our Wine stack). 7a8056fa was cherry-picked on top (one conflict in compact.rs around automatic_plan, resolved by keeping main's automatic_plan), plus a local print of the compact decision inputs. Shader: retail title from #505, cs 84eee477d68b6fdf, built alone offline with xcl shaders <pack> --measure-pso and XCL_DIRECT_DXIL=1, under a 12 GB memory cap.

without #2796 with #2796 (7a8056fa)
reachable blocks / non-terminator insts 834 / 16,713 834 / 16,713
compact::large() false true (≥ 10,000 insts)
compact form adopted (wanted) – no (not repetitive enough)
direct DXIL whole 958,940 B 958,940 B, byte-identical
process peak memory (translate + RADV compile) 1.2 GB 1.5 GB (same DXIL; one run each)

So the lower threshold now asks wanted() about this shader, the dedup gate keeps it plain, and the output does not change. Nothing regresses for this shader. It also gets no benefit, but it does not need one: on the direct path RADV builds it in ~3.8 s.

For context, not about this PR: the same record through the default HLSL → DXC path (1,403,484 B DXIL) never finishes on RADV. ACO's register spiller grows past 12 GB within ~50 s, and a debug Mesa 26.2.6 build hits the spiller assert of https://gitlab.freedesktop.org/mesa/mesa/-/issues/15722. So the large-shader commit spikes the PR describes for AMD's Windows driver have a Linux counterpart on the HLSL path, which compact form does not reach.

Not tested: head efb6e48e and the XCL_PER_LANE path; the amd-dev base; Windows; the PR's unit tests (not run here); an in-game run with the PR.

AI use: Claude Code (Claude Opus 5.5) built the probe, ran the measurements and wrote this report. Numbers checked against the run logs before posting.

@Saksukella
Saksukella force-pushed the fix/bound-3d-commit-memory branch from efb6e48 to 960f4fc Compare November 26, 2026 15:52
@Saksukella Saksukella changed the title DXIL: trigger compact form on branch-heavy shaders to prevent driver compile commit spikes Recompiler: defer large per-lane compute shaders to compact direct DXIL Nov 26, 2026
@Saksukella

Saksukella commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto amd-dev (c32c91a3, which already picked up Part 1 7a8056fa in 53995420) at 960f4fc2.

This PR now contains only the remaining XCL_PER_LANE=1 deferral to compact/split direct DXIL (lower_dxil::compute_with() + pso.rs::direct_compute() fallback to translate_compute_rodata()), verified with 8/8 CPU compact tests and a fresh 60s RX 9070 XT smoke (1,655 frames, 60 60 60, 0 crashes, 0 device removals, 15,221 MB peak commit).

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Ran the compact-DXIL and per-lane routing tests at 960f4fc on an NVIDIA Blackwell desktop part:

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::compact_tests -- --test-threads=1
12 passed; 0 failed; 0 ignored; 0 measured; 1634 filtered out      (exit 0)

All 12 pass, including the new per_lane_compute_defers_branch_heavy_program_to_compact_path and five gpu_* tests that compile and run compact DXIL on the real adapter. This is the rebased head 960f4fc (targets amd-dev); the NVIDIA report from ettehn in the thread was on the earlier head 7a8056fa, and DarkPanda69 checked this head on other cards. This adds a desktop Blackwell part on driver 32.0.16.2124 with DXC 1.9.2609.5.

Not tested: the large branch-heavy program behind XCL_PER_LANE=1 from the description, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game 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.

@bielfreedom

Copy link
Copy Markdown

AMD Windows data for #2796: on an RX 9070 XT, the new thresholds change one retail compute program out of 2,689. That program builds about 1.6× slower in AMD's driver and with 4× the peak memory. On main it is split into 11 pieces; the compact form replaces them with one whole program.

First, the branch. It now carries 256 commits against main (77+ files) and does not merge cleanly. I measured only this PR's own threshold commit (7a8056f): the compact::large change, applied by hand onto main b49be18. The newer 960f4fc defers large per-lane compute programs to the compact form. As far as I can tell, the per-lane path is the 32-lane-GPU one, which this native wave64 card does not take; I did not build it.

Setup

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

Which programs change, all 2,689 compute programs (translation only)

windows main this change programs changed
switch (default) 885,910,100 B 885,323,148 B 1: b6101d83892d44a5, 865,336 → 278,384 B
heap 728,930,968 B 728,461,444 B 1: the same program, 695,244 → 225,720 B

56c0cd3b82a00c6e, the example in the description, is already compact on main here, so it does not change.

Driver, b6101d83892d44a5 alone, switch windows, 2 interleaved rounds

build form pipelines driver time r1 / r2 peak memory
main split, 11 pieces 11 8.3 / 8.9 s 0.58 GB
this change compact, whole 1 13.1 / 14.0 s 2.48 GB

So on AMD this program was better off split. This looks like what #2810 describes for automatic compact lowering: the compact whole replaces a split plan that was available. One option is to leave the threshold alone for programs that already split.

Not tested: NVIDIA, GPU output, and a title run.

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

@Saksukella

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough RX 9070 XT measurement! Two quick clarifications on the current PR head (960f4fc2):

  1. Base branch & diff: This PR targets amd-dev (not main) and is a single commit (960f4fc2, 2 files) cleanly on top of amd-dev (c32c91a3).
  2. Scope of 960f4fc2: The earlier compact::large threshold commit (7a8056f) is no longer in this PR — it was already picked into amd-dev as 53995420. What remains here is solely the XCL_PER_LANE=1 deferral (lower_dxil::compute_with() returning None for large branch-heavy programs so pso.rs::direct_compute() falls back to translate_compute_rodata()). When XCL_PER_LANE=1 is enabled (including on RX 9070 XT runs testing per-lane lowering), cs 56c0cd3b82a00c6e previously bypassed translate_compute_rodata() and emitted a 2.67 MB (32,279-block, 36,143-PHI) per-lane DXIL blob; with 960f4fc2 it takes the standard split/compact direct DXIL path (160 KB).

Your b6101d83892d44a5 finding (compact whole vs 11-piece split, matching #2810) is great data for the 53995420 threshold already on amd-dev, and is orthogonal to 960f4fc2 since 960f4fc2 defers directly to translate_compute_rodata()'s normal split/compact selection.

@bielfreedom

Copy link
Copy Markdown

Correction to my comment above. This PR's base is amd-dev, not main, so my note on 256 commits was wrong: against amd-dev it is one commit. The threshold change I measured is already on amd-dev as 53995420. I reran everything on amd-dev c32c91a, on the same RX 9070 XT, the same way.

53995420 on amd-dev (A/B by reverting it)

  • DXIL: with amd-dev's defaults, 1,616 compute programs are translated (XCL_RT_GATE=hold holds back 1,073). Again only b6101d83892d44a5 changes: plain 611,608 B → compact 171,240 B with switch windows, and 461,036 → 142,872 B with heap windows.
  • Driver, that program alone, switch windows, XCL_RT_GATE=0, 2 interleaved rounds:
amd-dev form pipelines driver time r1 / r2 peak memory
53995420 reverted split, 11 pieces 11 6.6 / 6.3 s 0.57 / 0.58 GB
as is compact, whole 1 6.2 / 6.3 s 1.25 GB

So on amd-dev the compact whole builds about as fast as the 11 pieces. The 1.6× slowdown I reported is main's compact form only. The peak memory still roughly doubles, which matters little at 1.25 GB.

This PR's own commit (960f4fc) on amd-dev: no DXIL byte changes on this native wave64 card, over the 1,616 programs translated by default, as expected for the per-lane path.

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

@relativespace2K

Copy link
Copy Markdown

Tested - retail title on native Windows AMD RDNA2, PR head 960f4fc230fd610b2f64a448801edf9d2d4f7ca4 on amd-dev c32c91a3

Tool: OpenCode with DeepSeek V4.1 Flash 1017

  • AMD Radeon RX 6800 XT (16338 MiB), driver 32.0.21045.29003; Ryzen 5 5600, 31.9 GB;
    Windows 11 IoT Enterprise LTSC 26100; release build; DXC 1.9.2602.17.
  • cargo test --release -p xcl --lib -- gpu::dxil::compact --skip gpu_:
    8 passed, 0 failed, 0 ignored, 0 skipped, 1638 filtered out, including
    per_lane_compute_defers_branch_heavy_program_to_compact_path.
  • Game: retail title 1.0.2.1, two 240 s runs, XCL_PER_LANE=1 XCL_DIRECT_DXIL=1 plus
    XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=1 XCL_RUN_SECONDS=240, no other XCL_* variables;
    warm shader/pipeline caches; baseline first, PR second.
run presents peak commit local VRAM last present draws skipped driver compiles
amd-dev c32c91a3 1,823 27,043 MB 9,161 MB 105.7 s 5,937 10 / 84 s
PR 960f4fc2 1,779 26,941 MB 9,153 MB 104.2 s 6,736 9 / 75 s

The deferral fires on this title: the PR logs 7 large/branch-heavy compute program: deferring to per-instruction/compact direct DXIL lines between 116 s and 218 s; the baseline logs none.
Both trees then log direct DXIL compact form: 20965 blocks of 672 kinds (baseline 129.9 s,
PR 129.5 s). That is the compact form the report gives for cs 56c0cd3b82a00c6e, so on this
part the baseline already reaches it; the line itself does not name the shader.

Peak commit and presents are unchanged, so the 36+ GiB per-lane spike does not reproduce here:
the largest driver compile is 0.44 MB DXIL on the baseline and 0.36 MB on the PR, against the
2.6 MB DXIL in the report. Under XCL_PER_LANE=1 both trees skip many draws and stop
presenting around 105 s; the title still stalls on its loading screen, so there is no world or
FPS comparison. No crash, 0 failed pipelines, 0 DXIL failures, 0 errors. The baseline's last
frame dump was black (0 non-dark samples) and the PR's was not; both come from the stalled
screen, so I do not treat that as a regression.

Not tested: the standard non-per-lane path (this change only runs under XCL_PER_LANE),
NVIDIA/RDNA4, world/FPS, full workspace, debug build.

AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests, read the logs and wrote this comment; the figures and the deferral/compact lines were checked against the run logs.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2341 solves the same problem (for #2688) in a different way: #1607, group D150. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@iggyvilla

Copy link
Copy Markdown
Collaborator

Review of 960f4fc2 (base amd-dev), diff only; I did not build or run it. Four readers reached the same verdict independently, so these are one set of findings:

  1. The defer gate is large(), not wanted(). compute_with now refuses any program with compact::large(&cfg) (2000 blocks or 10000 instructions), but the compact form is only taken when compact::wanted also holds (mostly repeated blocks, small tables). The shader 84eee477 in this PR's comments (834 blocks, 16,713 instructions) is large but not wanted, and gives a byte-identical 958,940 B result: it only pays an extra CFG build and a doomed translation. A program that is large but not wanted also loses the old per-lane output and falls to translate_compute_rodata.
  2. No per-lane fallback after an early defer. If translate_compute_rodata(...)? in pso.rs::direct_compute fails for a deferred program, the error goes up to HLSL/DXC, where the old code returned Ok. The over-512 KiB branch keeps the old output; the early-defer branch should do the same (or the PR should say why per-instruction always wins).
  3. Silent error in the over-512 KiB branch: if let Ok(alt) = translate_compute_rodata(...) drops the error, so a >512 KiB per-lane blob is kept with no log line. Log the error.
  4. Rebase conflict on the current amd-dev tip (7c795f5e). Compiled.dxil is built with k.dxil.into() there (I checked pso.rs around lines 1054 and 1064); the diff still builds it from a plain Vec<u8>.
  5. Overlap with recomp: cap per-lane compute size so giant shaders use compact DXIL (#2203) #2341 (same function, same shader 56c0cd3b, hard caps of 20k instructions and 1 MiB). The two need one threshold and one byte limit before either merges; one reader suggests recomp: cap per-lane compute size so giant shaders use compact DXIL (#2203) #2341 first for main, then this PR replacing its hard errors in compute_with with the large() pre-gate and the compare-and-keep in pso.rs.
  6. Not a fix for amd-dev f84a949: AMD driver crashes (amdxc64.dll+0xd2a411) compiling the title's native DXIL compute shader ca7beffb8d3a8f28 (RX 6750 XT) #2874. The amdxc64 crash there happens without XCL_PER_LANE (where this PR does nothing), inside translate_compute_rodata, and the 509,896 B record is below the 512 KiB line; Recompiler: keep compute shaders on single loop budget to avoid AMD LLPC crash #2947 addressed it. This PR sends more programs into that same path.

The unit test fails without the fix, but only pins the 2000-block gate in compute_with: it does not cover pso.rs, the 512 KiB branch, or the 10000-instruction threshold.

AI use: Gemini 4 Hydrogen High (agy2 and agy3, Antigravity) and Muse Spark 1.3 (o5, pi) each read this PR's diff, comments and the touched code and wrote their own report; Claude Code (Claude Sonnet 5.5, coordinator) compared the reports, checked findings 4 and the large()/wanted() split against amd-dev 7c795f5e, and wrote this text. The rest was not re-verified by the coordinator. Nothing was built or run. The comment was posted without the account owner reading it first.

@oni-swr

oni-swr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 7c795f5
head: 960f4fc
merge: clean
build: cargo build --workspace -> failed (pso.rs:1055 and :1068: Compiled.dxil is now Arc<Vec<u8>>, the PR passes Vec<u8>; two E0308 errors on amd-dev 7c795f5)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> not run on the PR as is (the lib tests do not compile). Base amd-dev: 1802 passed, 18 failed, 48 ignored. With a local .into() added at the two sites (not in the PR): 1802 passed, 19 failed, 48 ignored; failing: the 18 base failures (fuzz_validate_and_gpu_1, dispatch_chain_native_wave64_builds_whole, f32_programs_on_the_gpu, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, 4 list_x tests, the e2e/offline-pipeline tests, and others, all failing on the base too) plus compositor_releases_root_sig_and_rejects_invalid_planes, which is flaky (fails in some full lib runs on base+PR, passes alone and in other full runs; unrelated code). The new per_lane_compute_defers_branch_heavy_program_to_compact_path passes.
review: Read the whole diff (4 files, +38/-2) and iggyvilla's 17:11Z review of this head. In the merge result: (1) HOLDS: compute_with defers on compact::large() (2000 blocks / 10000 instructions) without wanted(), so a large but not repetitive program loses the per-lane output and pays a CFG build for nothing. (2) HOLDS: after the early defer, translate_compute_rodata(...)? in pso.rs direct_compute still ends in ? for a deferred program, so an error there goes to HLSL/DXC instead of keeping the per-lane DXIL. (3) HOLDS: if let Ok(alt) = translate_compute_rodata(...) in the over-512 KiB branch drops the error with no log line. (4) HOLDS, and is a blocker: the PR no longer builds on amd-dev 7c795f5 (see build). (5) Overlap with #2341 (same function, caps): not checked here. (6) Not re-checked; the diff changes nothing for runs without XCL_PER_LANE=1. Test gap holds: the unit test pins only the 2000-block gate in compute_with, not pso.rs, the 512 KiB branch or the 10000-instruction gate. Needs a rebase and the fixes above.
performance: Only runs under XCL_PER_LANE=1 (off by default): no cost by default. With it on, large programs take the compact/split form (less commit per the PR's and relativespace2K's reports); a large non-repetitive program pays an extra CFG build plus a translation that yields the same DXIL. No title run: not done because the build fails.
verdict: not yet: rebase onto amd-dev (Arc<Vec> change at pso.rs 1055/1068), then the review points 1-3 and the test gap
hardware / tool and model: AMD Radeon RX 7800 XT (RDNA3, 16 GB), driver 32.0.31035.1003, Windows 11 build 26200, AMD Ryzen 7 5700X3D, debug build, rustc 1.100.0; Claude Code (Claude Sonnet 5.5)

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 960f4fc

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 7c795f5 (amd-dev)
head: 960f4fc
merge: clean
build: cargo build --workspace -> FAILED (2 x E0308)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> not run (the merge result does not build)
review: blocking: merged onto the current amd-dev it does not compile, although GitHub shows no conflict: Compiled::dxil is an Arc<Vec> on the branch now and the PR's two new returns pass a plain Vec (E0308 at gpu/recomp/pso.rs:1055 and the second site). Also still open from the first check: the early defer uses the size test without the wanted test; a failed rodata translation still sends a deferred program to HLSL; one error is dropped without a log line; and the per-lane survey in 'xcl shaders' now counts large programs as per-lane failures.
performance: the route changes only with XCL_PER_LANE=1 (off by default), but the source change alters the direct-DXIL identity, so every tester re-translates the compute shaders once.
verdict: not yet: rebase (.into() at both sites) and the open points of the first check; I will rerun on the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read). An NVIDIA card: it says nothing about AMD driver behaviour, so a check from an AMD tester is the one that counts for that.

@Saksukella
Saksukella force-pushed the fix/bound-3d-commit-memory branch from 960f4fc to d01016e Compare November 29, 2026 00:09
@Saksukella
Saksukella changed the base branch from amd-dev to main November 29, 2026 00:09
@Saksukella

Copy link
Copy Markdown
Contributor Author

@throny Rewritten cleanly onto main (227d2cb388) and retargeted this PR's base branch to main.

Summary of changes addressing review feedback:

  1. Aligned with main's compact::automatic_plan & Compiled: compact::prefers_compact(code, o.split) now delegates directly to automatic_plan_impl(&cfg, None, split_compute) (checking large() / atomic_candidate, table-word cap, and repetition ratio) so large non-repetitive programs do not pay a doomed compact attempt or lose per-lane lowering. Compiled preserves dispatch_remap: None.
  2. No HLSL drop on failed rodata translation + logged over-cap errors: Routing lives in pso::choose_compute_kernel(). When a prefers_compact shader fails translate_compute_rodata(), it logs a warning and falls back to lower_dxil::compute_with() instead of dropping straight to HLSL. In the > 512 KiB comparison branch, errors from translate_compute_rodata() are logged via xlog_warn! before keeping the per-lane DXIL.
  3. Clean xcl shaders per-lane survey: Early deferral lives in pso::direct_compute() rather than lower_dxil::compute_with(), so xcl shaders does not count deferred large shaders as per-lane lowering failures.
  4. Tests & verification (RX 9070 XT):
    • cargo test --lib -p xcl pso -- --test-threads=4: 250 passed, 0 failed, 1 ignored (including pr2796_tests properly gated under #[cfg(test)]).
    • cargo test --lib -p xcl prefers_compact -- --test-threads=4: 1 passed, 0 failed.
    • cargo check --workspace: passed.
    • 60s smoke.ps1 (TitleID 7952987A, head d01016e37de3): 1689 frames shown (main 227d2cb388: 1674), 0 device removals, 0 crashes, 17683 MB peak commit.

@github-actions github-actions Bot added the area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 label Nov 29, 2026
@github-actions github-actions Bot added area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-rebase Has merge conflicts with its base branch labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: d01016e

Re-check of the head rebased onto main.

@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-rebase Has merge conflicts with its base branch labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: fa20459
head: d01016e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2612 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa20459: 2608 passed, 0 failed, 49 ignored.
review: re-check of the rewrite onto main. Of my earlier points: the build failure is moot on main; the fall to HLSL after a failed compact translation and the dropped error are answered (it falls back to per-lane and logs); the routing moved out of the lowering into one chooser, which answers the survey point as far as read. Partly answered: the choice "prefers compact" is now made from size, table words and repetition, but without the lowering data the real plan uses, so it can pick compact where the real plan would not; the program then gets plain per-instruction output, which is valid, only not what was intended. New: XCL_DIRECT_COMPACT=0 is not honoured by that choice. The main issue is #2341, which I checked as safe yesterday and which aims at the same thing: both insert at the same spot (the second to merge conflicts), and if both land, #2341's refusals make most of this PR's routing unreachable. One of the two should be merged, not both; this one is the more careful routing, #2341 the smaller one. That is a maintainer's choice, and it qualifies my "safe" on #2341 in the same way. Process: AI use names no model, and the smoke run does not reach this code without XCL_PER_LANE=1.
performance: with the switch on, giant programs avoid the per-lane form. It changes direct-DXIL sources (every direct-DXIL entry is re-translated once) and a file in the pipeline-layout list (I did not trace what that rebuilds).
verdict: not yet: decide between this and #2341 first; then honour XCL_DIRECT_COMPACT=0 and name the model.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head d01016e

#2341 (D150, merged as 640a8e0) addressed the same problem on main: lower_dxil::compute_with now refuses programs of 20,000 or more instructions and per-lane DXIL over 1 MiB, so they fall back to the per-instruction/compact form. This PR solves it differently: it prefers the per-instruction form whenever compact::automatic_plan qualifies (10,000 insts, 2,000 blocks, or split atomic candidates), and it caps per-lane at 512 KiB, keeping the smaller form. It conflicts with main's pso::direct_compute. After a rebase it should explain what it adds beyond #2341's caps. On the compact-preferred path, a per-instruction failure is not recorded in coverage::record_fallback.
Recommendation: keep open.

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

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 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.