Skip to content

Recompiler: batch consecutive v_readfirstlane/v_readlane exchanges in… - #944

Open
zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-readlane-batch
Open

zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-readlane-batch

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

In split-wave64 mode (two hardware wave32 halves per console wave64), consecutive independent v_readfirstlane_b32 and v_readlane_b32 instructions (for example, 4-dword V# or 8-dword T# descriptor waterfalls in wave64 mesh and compute shaders) previously each emitted a separate xcl_x_rla_uniform call — inlining a full cross-half xcl_x_meet() barrier/spin-wait exchange per instruction.

PRELUDE_X64 already supports multi-word exchanges (xcl_x_put(i, ...) / xcl_x_meet() / xcl_x_get(i), as used by coherent s_load_dwordx4 and ds_bpermute). This batches consecutive dependency-free v_readfirstlane_b32 / v_readlane_b32 instructions inside each basic block into a single multi-word xcl_x_meet() (sharing one first_lane(exec_lo, exec_hi) call across the batch), reducing DXIL size, DXC compile time, and NVIDIA driver (nvgpucomp64.dll) pipeline compile time. Native wave64 and wave32 HLSL are unchanged, and this is orthogonal to #917 (v_writelane_b32 spill shadows).

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs:
    • Add split-wave64 batching in Em::emit_insts for consecutive plain v_readfirstlane_b32 / v_readlane_b32 instructions within a basic block. Splits on any SGPR/EXEC read-after-write dependency, skips reads already resolved by upper_lanes, and caps batch width at (64 / waves).clamp(2, 8) so per-wave exchange storage stays <= 256 dwords (1 KiB).
    • Pre-scan decoded instructions in Em::configure_round_modes (may_use_lds) for guest LDS use (Mode::Geometry(_) or any ENC_DS instruction other than ds_swizzle_b32 / ds_bpermute_b32 with GDS == 0), and keep lane-read batching at the existing 1-word slot (XCL_X_SLOT 1u) for those programs at every group size so XCL_X_LDS_TOP is never shrunk into guest LDS space.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • split_wave64_readlane_batching_rules: covers 4-word batching, SGPR and EXEC dependency splits, jump-target splits, 64- and 1024-thread slot caps, and native wave64 invariance.
    • split_wave64_readlane_batch_preserves_guest_lds_top: 512-thread regression verifying that 8 v_readfirstlane_b32 before DS_WRITE_B32 keep XCL_X_SLOT 1u and XCL_X_LDS_TOP 8142u, while DS_SWIZZLE_B32 still batches (XCL_X_SLOT 8u).
    • gpu_split_wave64_batched_readlanes: GPU test verifying upper-half active lanes, mixed lower/upper lane batches, SGPR dependency split, and EXEC-modifying split.

Across 10,447 wave64 CS/MS programs in a retail shader pack (measured pre-rebase), this removed 19,334 xcl_x_meet() exchanges (18,049 from consecutive v_readfirstlane_b32 and 1,281 from consecutive v_readlane_b32).

Measured on four retail wave64 shaders on origin/main (09940bb) -> pre-rebase commit (e7199ca) (RTX 3060 Ti, DXC 1.9.2609.5):

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.2101), Ryzen 5 7500F, 64 GB RAM, Windows 11 Build 26300, DXC 1.9.2602.17, Rust 1.100.0 (x86_64-pc-windows-msvc), debug + release.
  • Rebased onto origin/main (b49be183).
  • cargo test --workspace -- --test-threads=4 on e22a0a6: 1438 passed, 0 failed, 47 ignored across 37 test binaries (29 runtime SKIPPED notices from adapter-gated tests); all three tests (split_wave64_readlane_batching_rules, split_wave64_readlane_batch_preserves_guest_lds_top, gpu_split_wave64_batched_readlanes) ran and passed.

Regression run

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR:

xcl-smoke v1
commit: e22a0a6e781b3080f124fd6832b656fc66ff0820
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1635 (PresentX 1635)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14605 MB

Not tested

  • Native wave64 GPU (AMD RDNA): hardware not available here (split_wave64 is false there so emitted HLSL is unchanged).
  • Re-measuring the offline retail shader corpus counts / DXC timings above after adding the guest-LDS guard (those numbers are from pre-rebase e7199ca; shaders without guest LDS are unaffected).
  • Retail gameplay past menus (smoke run covers boot through menus).

AI use

  • Antigravity (Gemini 4 Neon): scanned the retail shader corpus, wrote the implementation, unit/GPU tests, and PR description; all tests, benchmarks, and smoke runs were executed locally on the hardware above and the diff was reviewed line by line.

@Xeltax

Xeltax commented Nov 24, 2026

Copy link
Copy Markdown

A first AMD run, on native Windows: the split form forced on 64-lane hardware, and the native path.

Tested

  • This PR's head e7199ca merged onto main 077ce40 (clean merge).
  • AMD Radeon(TM) Graphics (the Ryzen 9 9900X's RDNA2 iGPU, driver 32.0.21042.62, 64-lane waves), Windows 11 Pro 26200, rustc 1.100.0, DXC 1.9.2609.5, debug build.
  • Split form forced with XCL_ADAPTER=radeon XCL_SPLIT_WAVE64=1 cargo test -p xcl --lib split_wave64 -- --test-threads=4. runner::split_wave64() is then true, so the HLSL batching asserts of gpu_split_wave64_batched_readlanes run as well:
    • this PR: 8 passed, 0 failed, 1 ignored, in 5 of 5 runs;
    • main 077ce40: 6 passed, 0 failed, 1 ignored, in 5 of 5 runs.
  • Native wave64 (XCL_REQUIRE_GPU=wave64, no XCL_SPLIT_WAVE64):
    • the same filter: 8 passed, 5 of 5 runs;
    • the whole gpu::recomp module: 190 passed, 0 failed, 18 ignored, no skips. main gives 188 / 0 / 18.

Not tested

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@eizispark

Copy link
Copy Markdown
Contributor

Hardware check of e7199ca3f4fd985969b73bd17d5108866c93a679 (verified clean merge with main 077ce40): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored (GPU tests skipped on this adapter: none); the 3 failures are the pre-existing concurrent hle::d3d12x contention (placed_title_textures_share_vram_and_preserve_pixels plus 2 downstream PoisonErrors), verified clean via cargo test -p xcl --lib hle::d3d12x -- --test-threads=1: 115 passed, 0 failed, 1 ignored
  • split_wave64_readlane_batching_rules, gpu_split_wave64_batched_readlanes, gpu_wave32_program_in_wave64_hardware, and gpu_geometry_wave32_prefix_count_over_a_mask all passed on native wave64; also verified forced split-wave64 execution on discrete RDNA4 via XCL_SPLIT_WAVE64=1 cargo test -p xcl --lib gpu_split_wave64_batched_readlanes -- --nocapture: 1 passed, 0 failed

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (e7199ca):

xcl-smoke v1
commit: e7199ca3f4fd985969b73bd17d5108866c93a679
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1666 (PresentX 1666)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14859 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@DarkPanda69

DarkPanda69 commented Nov 24, 2026 •

Copy link
Copy Markdown

Update for head e22a0a6: paired rerun on main b49be18, same cards, cargo test -p xcl --lib -- gpu:: --test-threads=4. On both cards, the only result changes against main are gpu_split_wave64_batched_readlanes, split_wave64_readlane_batch_preserves_guest_lds_top and split_wave64_readlane_batching_rules, all ok, with no new skips. RX 9070 XT: 708 → 711 passed, 2 failed (#2115, the same on main), 6 SKIPPED. RTX 3060: 710 → 713 passed, 0 failed, 24 SKIPPED.

AMD run with native 64-lane waves, plus NVIDIA. Updated for head e6a94f5 (first run was on e7199ca, same result).

Tested: pass, head e6a94f5 applied on main aaa0936, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu:: --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 586 passed, 2 failed, 22 ignored. gpu_split_wave64_batched_readlanes ok. The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and _3, which fail the same way on main without this PR on this card.
  • NVIDIA RTX 3060, driver 32.0.16.1088, split wave64: 588 passed, 0 failed, 22 ignored. gpu_split_wave64_batched_readlanes ok.

Not tested: retail gameplay; performance.

Note: these runs check that the translated HLSL matches the test's reference model, in 64-lane and in 32-lane waves. They cannot show that the model matches the hardware.

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

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head e7199ca onto main 9aec53d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 719 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. batched readfirstlane/readlane green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

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

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib readlane: 2 passed, 0 failed — split_wave64_readlane_batching_rules and gpu_split_wave64_batched_readlanes (GPU) both pass.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@pvfreis pvfreis 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.

Review of e7199ca (merge base 09940bb), by reading the code; nothing was built or run here. I checked that each batched read sees what the unbatched xcl_x_rla_uniform sequence would (lane indices, first_lane(exec) and the reads are all computed before the first SGPR write, emit.rs:972-990; dependent reads split the batch, :890-937), and that the GPU test compares against independent values. No defect found.

Questions for the author

  • For a program whose exchange slot was 1 before, the larger XCL_X_SLOT moves XCL_X_LDS_TOP down (emit.rs:4345): for a 1024-thread group from word 8094 to 7902 (arithmetic), and LDS accesses above the top are clamped onto it. Did the shader-pack scan check that no LDS-using program reaches between the old and new top?
  • Which command produced the exchange counts and the DXC/PSO times, so they can be rerun on another pack? (18,049 + 1,281 is 19,330; the description says 19,334.)

Review by Claude Code (written by Claude Opus 5.5, second read by Claude Fable 5.2); each point checked by a person before posting.

@zondy1i

zondy1i commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the code review! Answering both questions:

  1. XCL_X_LDS_TOP for 1024-thread groups: We capped XCL_X_SLOT at 4 for 1024-thread groups (768 B extra, moving XCL_X_LDS_TOP from word 8094 to 7902, leaving 31,608 B of LDS) rather than 8 specifically to keep the footprint small. The corpus scan verified static exchange reductions and clean translation/compilation across all 10,490 wave64 CS/MS shaders, rather than proving dynamic runtime LDS offsets on every 1024-thread LDS-using shader. If a tighter guarantee is preferred, capping x64_batch_cap when self.uses_lds is true for 1024-thread groups is straightforward — happy to add that if desired.
  2. Measurement methodology & total count:
    • The exchange counts come from a one-off local Rust scan calling recomp::translate (split-wave64) across all 10,490 wave64 CS/MS shaders in a retail shader corpus, and the DXC/PSO times come from a one-off local Rust harness calling recomp::translate -> dxc::compile -> CreateComputePipelineState on a cold cache (single cold build per shader on Windows 11 + RTX 3060 Ti).
    • Good catch on the arithmetic: 18,049 + 1,281 = 19,330 in compute shaders plus 4 in mesh shaders = 19,334 total exchanges removed.

AI use: Antigravity (Gemini 4 Neon) helped draft this reply from the code and measurement logs.

@pvfreis

pvfreis commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thanks, that answers both (and the 4 are the mesh shaders, understood).

On the LDS top: since the scan checked translation and compilation rather than the LDS offsets programs reach at run time, the cap you describe (no batching beyond today's slot size when uses_lds is set for 1024-thread groups) would remove the one risk at little cost, so I'd add it.

On the numbers: the harness could live in the tree as an #[ignore] test that reads the shader pack from an XCL_SAMPLE_* variable, as the other game-data tests do (CONTRIBUTING, "Tests on game data"). Then anyone who owns the title can rerun the counts and timings on their own GPU.

Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.

@Mykolas009

Copy link
Copy Markdown

Tested on NVIDIA Blackwell: this PR's head e7199ca merged onto main 6efdabc (clean merge, not pushed).

  • NVIDIA GeForce RTX 5060 8 GB (wave32, so wave64 programs run in the split form), driver 610.88;
    Ryzen 5 7500F; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4:
    729 passed, 0 failed, 41 ignored (main 6efdabc alone: 727 / 0 / 41, 3 of 3 runs).
    SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • split_wave64_readlane_batching_rules and gpu_split_wave64_batched_readlanes: pass.
  • Negative control: with emit.rs and mod.rs from main and this PR's tests kept, both tests fail
    (tests.rs:5808 and tests.rs:5897).
  • Earlier the same day on main 077ce40 + this PR: same result for its own tests and the negative control.

Since #798 the exchange this PR removes is also the bounded-spin one in one-wave groups, which costs about
8.3x of wave32 per exchange on this card (bench_split_wave64). I did not measure this PR's effect on
frame times.

Not tested

  • A retail title or smoke.ps1 (no game files); frame times of real shaders. AMD.

AI use

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

@Mykolas009

Copy link
Copy Markdown

How much the batching saves on NVIDIA, since nobody has timed it yet. A local benchmark (not for a PR,
built like bench_split_wave64: a 2^18-thread compute dispatch, 32,768 loop iterations, GPU timestamps,
median of 9, release) on main 930e8b4 with and without this PR (e7199ca), 2 runs each:

loop body threads per group main + #944
4 back-to-back v_readfirstlane of lane values 64 512.8 ms (19.5x of wave32), 4 exchanges 172 ms (6.6x), 1 meet
the same 256 517–524 ms (19.6x) 174 ms (6.6x)
1 v_readfirstlane (nothing to batch) 64 / 256 127–129 ms 127–129 ms

So four reads in a row run about 3x faster, and a lone read is unchanged. The wave64 output of every case
is identical with and without the PR (same hash of all stored values).

Tested

  • NVIDIA GeForce RTX 5060 8 GB (Blackwell, 32-lane waves), driver 610.88; Ryzen 5 7500F; Windows 11 Pro 26300;
    Rust 1.100.0 MSVC; DXC 1.9.2602.17.
  • Also on 930e8b4 + this PR (debug): full suite 753 passed, 0 failed, 41 ignored; both new tests pass and
    both fail with emit.rs and mod.rs from main (tests.rs:5808, 5897).

Not tested

  • Real shaders or a retail title, so not how often real programs have reads in a row. AMD.

AI use

  • Claude Code (Claude Opus 5.5) wrote the local benchmark, ran it and the tests, and drafted this; I checked the numbers.

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up on the LDS cap at head e6a94f5: the largest extra reservation is at 512 threads, not 1024. Eight independent v_readfirstlane_b32 instructions before a DS_WRITE_B32 select XCL_X_SLOT 8 and move XCL_X_LDS_TOP from word 8142 to 7918 (896 more bytes reserved). Guest LDS words 8000 and 8001, distinct on the previous single-word exchange, would both clamp to 7918. This address alias is a source-level prediction; I have not run a GPU readback of those two words.

I added a synthetic 512-thread translation regression locally. It fails on the PR head (0 passed, 1 failed) because the slot expands, then passes with a small guard (1 passed, 0 failed). The existing split_wave64_readlane_batching_rules unit test and gpu_split_wave64_batched_readlanes test also pass with that guard (1/0 each, the GPU test ran on an RTX 3080 Ti with no skip). The test reads no game data.

Suggested bound: classify possible guest LDS use over the decoded program before emitting instructions, then keep lane-read batching at the existing one-word slot for that class at every group size. Exclude DS_SWIZZLE_B32, DS_BPERMUTE_B32, and GDS accesses from that classification; geometry also has implicit LDS. Checking uses_lds inside the batching loop is insufficient when lane reads precede the first DS instruction. This leaves the no-LDS batching benefit intact. I have an uncommitted 27-line local diff (including the regression) if useful.

AI use: Codex (GPT-6.2 Sol) reviewed the source, wrote and ran the synthetic regression and local guard, and drafted this comment.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@zondy1i
zondy1i force-pushed the recomp/x64-readlane-batch branch from e6a94f5 to e22a0a6 Compare November 26, 2026 08:24
@zondy1i

zondy1i commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (b49be183) and addressed @thehollowedone's 512-thread guest-LDS headroom finding in e22a0a6:

  • Pre-scan decoded instructions in Em::configure_round_modes (may_use_lds) for guest LDS usage (Mode::Geometry(_) or any ENC_DS instruction other than ds_swizzle_b32 / ds_bpermute_b32 with GDS == 0), and keep readlane batching at the existing 1-word slot (XCL_X_SLOT 1u) for those programs at every group size so XCL_X_LDS_TOP is never shrunk.
  • Added split_wave64_readlane_batch_preserves_guest_lds_top (512-thread regression confirming 8 v_readfirstlane_b32 before DS_WRITE_B32 keep XCL_X_SLOT 1u and XCL_X_LDS_TOP 8142u, while DS_SWIZZLE_B32 still batches).

Full workspace suite on e22a0a6: 1438 passed, 0 failed, 47 ignored; 60 s smoke is updated in the description. Thanks @thehollowedone for catching this!

@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows/NVIDIA check of #944 head e22a0a6, rebased on b49be183 and including the guest-LDS guard:

  • RTX 3080 Ti (driver 621.35), Windows 11 build 26300, rustc 1.99.1, DXC/DXIL 1.8.2502.11.
  • cargo build --offline --locked --workspace: passed.
  • cargo test --offline --locked -p xcl --lib gpu_split_wave64_batched_readlanes -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored, no GPU skip.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet: 1,438 passed, 0 failed, 47 ignored across 37 test executables. The output also printed 25 SKIPPED notices; I do not count those paths as GPU coverage.

This verifies the current head's test behavior on this adapter. I did not repeat the earlier shader-corpus timing or run a retail title, so I cannot confirm the current head's compile-time gain or retail behavior.

AI use: Codex (GPT-6.2 Sol) inspected the revision, ran the tests, and drafted this report.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: e22a0a6

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 753e8b1
head: e22a0a6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored; its split-wave64 tests ran on this wave32-only card and passed (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: no blocking finding. A batch is consecutive plain readfirstlane / readlane instructions inside one block; it ends at any read of a register written inside it and at any write to EXEC, VCC or M0, so an EXEC change is never straddled. Which half provides the value is the same rule as the existing uniform exchange. Programs with guest LDS are excluded. Minor: inside a batch the pc markers and comments are emitted in a different order.
performance: fewer exchange meetings per shader on wave32-only GPUs; each group's shared memory grows by at most about 1 KB. It changes a translator source: every tester re-translates all shaders once. The gain was not measured here; I can add a world run on this card.
verdict: safe to merge
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).

@KOLESNiii

Copy link
Copy Markdown
Contributor

merge-check claim
head: e22a0a6

@KOLESNiii

KOLESNiii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: e429936
head: e22a0a6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2129 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 3 other PRs' suites, in one queued job.
review: [major] crates/xcl/src/gpu/recomp/emit.rs:1066 and :1075 (emit_insts): a batched run of split-wave64 v_readfirstlane_b32 / v_readlane_b32 is emitted through emit_x64_readlane_batch and the loop continues without calling x64_fail_closed_since(emitted_from), which every other exchange (the reduction tail at :1072, and each inst() at :1086) is followed by -> in a group of more than 64 threads (x64_spin), a half whose partner timed out at the batch's xcl_x_meet() keeps running with the 0 placeholders instead of returning, which the comment at :1082-1085 says it exists to prevent ("later stores would turn a synchronization failure into plausible but undefined game output"). Evidence: emit.rs:1063-1086, x64_fail_closed_since at emit.rs:5031 matches "xcl_x_meet(" (confirmed by reading; not triggered in a test). Fix: call self.x64_fail_closed_since(emitted_from) before both continues. Rest of the diff read (may_use_lds pre-scan; dependency tracking on SGPRs, EXEC and VCCZ/EXECZ; slot cap (64 / waves).clamp(2, 8); batching off with guest LDS and in geometry; 3 tests); x64() excludes vertex and pixel shaders, so the batch's first_lane (not first_lane_live) and the skipped graphics-reduction reads do not apply.
performance: reasoned, not measured: fewer exchanges (one xcl_x_meet per batch of 2-8 lane reads instead of one each) in split-wave64 compute / mesh / kernel programs without LDS; translator output changes, so those shaders are translated again once.
verdict: not yet: one major finding (a batched lane-read exchange skips the fail-closed exit after a partner timeout); add the x64_fail_closed_since call
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 0edd4686341a561a1a8ed609b5b72d3e401836d6 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head e22a0a6

No open or merged PR makes the same change for the HLSL path. #2343 (same author) is the direct-DXIL counterpart (gpu/dxil/lower_valu.rs, lanes.rs), so the two do not overlap. #981 (merged) only folded reduction tails, which this keeps (batch of more than 2 first, then the tail fold, then a batch of 2).
Dependency tracking looks right. Sources are read before the single meet and results are written after it, so a write-after-read inside a batch is safe. A read-after-write on an SGPR, EXEC (readfirstlane) or VCCZ/EXECZ ends the batch. Batching is off when the program may use guest LDS or runs in geometry mode. 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.

@futurepro62

futurepro62 commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: d0832e6
head: e22a0a6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> NVIDIA: 2893 passed, 0 failed, 51 ignored, 24 SKIPPED lines (base alone: 2890 passed, 0 failed, 51 ignored, 24 SKIPPED). The 3 new tests (split_wave64_readlane_batching_rules, split_wave64_readlane_batch_preserves_guest_lds_top, gpu_split_wave64_batched_readlanes) passed. AMD Radeon iGPU (XCL_ADAPTER=radeon): the 3 new tests passed, then the lib test binary stopped with exit 0x80004005, as it does on the base alone (#3488). The other failures are identical with and without this PR: gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. Radeon, cargo test -p xcl --lib gpu::recomp::tests -- --test-threads=4 (the module this PR adds to, run alone so the lib binary does not stop): 225 passed, 2 failed, 18 ignored, against 222 passed, 2 failed, 18 ignored on the base alone; the same 2 fail on both (gpu_f32_compares_with_nan, gpu_float_compares_random), and the 3 new tests pass.
review: KOLESNiii's major finding holds on the current merge, and it is a semantic conflict with main, not a slip in the PR. main gained x64_fail_closed_since in 86a90eeb ("Shaders: fail closed on wave64 rendezvous timeout", 2026-11-26), one day after this head (2026-11-25), so the PR never saw it. In the merged emit_insts (emit.rs ~1043-1070), the reduction-tail path and every inst() are followed by self.x64_fail_closed_since(emitted_from), but both batch branches continue without it. emit_x64_readlane_batch emits bool ok = xcl_x_meet(); and then ok ? xcl_x_get(i) : 0u, so after a timed-out partner a half keeps going with zeros. x64_fail_closed_since emits if (xcl_x_dead) return; only when x64_spin() holds, i.e. groups of more than 64 threads (x64_spin_for). Batching is allowed there (cap 64 / waves, clamped to 2-8), so the case is reachable. The fix is one line before each of the two continues: self.x64_fail_closed_since(emitted_from);. The rest of the batching agrees with throny's review: it ends at a read of a register written in the batch, and it is off when the program may use guest LDS (may_use_lds, a pre-scan) or in geometry mode.
performance: fewer xcl_x_meet() calls in split-wave64 programs with runs of lane reads; nothing measured in a title here.
verdict: not yet: add x64_fail_closed_since(emitted_from) after both batched exchanges in emit_insts, so a batch fails closed like every other exchange on current main
hardware / tool and model: RTX 5070 Ti 16 GB (wave32) + AMD Radeon iGPU, Ryzen 7 9800X3D, Windows 11 26300, debug test profile. Claude Code, Claude Opus 5.5: merge, build, both suites, full-diff review of the merge result.

@github-actions github-actions Bot added 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) 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 area:tests Unit, integration, e2e tests, or testtitle 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-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.