Skip to content

Recompiler: 2-D and 3-D compute groups take the direct DXIL route again - #3189

Closed
Royalflamejlh wants to merge 1 commit into
xcl-dev:mainfrom
Royalflamejlh:recomp/direct-console-linear-groups
Closed

Royalflamejlh wants to merge 1 commit into
xcl-dev:mainfrom
Royalflamejlh:recomp/direct-console-linear-groups

Conversation

@Royalflamejlh

Copy link
Copy Markdown
Contributor

d9403543 sends every compute program with a 2-D or 3-D thread group to the HLSL path ("multidimensional groups need the HLSL console-linear thread reorder"). The direct translator has had that reorder since 746f7ddc: Lw::setup_lanes_compute (gpu/dxil/lanes.rs) hands each hardware wave the next console threads through a groupshared counter, as the HLSL entry's XCL_WT block does, and the split wave64 form numbers its threads as xcl_x_thread does. So the rule only keeps these programs off the direct route. Under Wine + vkd3d-proton, single driver builds of their HLSL-path DXIL from a retail title reached 43.8 and 45.9 GB and stopped every launch pass on our 62 GB Linux machine (4 runs).

This removes the rule. pso.rs is outside the translator source hash, so TRANSLATION_GLUE_REVISION goes to pso-glue-v5; without it the translated-shader cache keeps serving the HLSL translations of these programs (one of our runs reused all 26,503 cached records in 10 s and built them again).

It adds to #3154: most of these programs then hit the DispatchX prologue's "instruction after a terminator" that #3154 fixes (with both, 556 of the title's 751 multidimensional compute programs translate directly in the split wave64 form, 655 in the native form; 238 and 273 with this alone).

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs: direct_compute_needs_hlsl, its call and its test removed.
  • crates/xcl/build.rs: TRANSLATION_GLUE_REVISION = pso-glue-v5.
  • crates/xcl/src/gpu/recomp/tests.rs: direct_compute_translates_2d_and_3d_groups (8x8x1 and 4x4x4 through pso::direct_compute as wave32, wave64 and split wave64, validated under test; fails with the rule) and gpu_direct_compute_waves_take_consecutive_threads_of_2d_and_3d_groups (each lane holds the console's consecutive threads: lane = t % lanes and v_readfirstlane = t − lane, for 8x8x1, 4x4x4 and 8x8x4).

Tested

  • Linux, Wine 11.21 Staging, no GPU (lavapipe), Rust 1.98.0, release, x86_64-pc-windows-gnu: cargo test -p xcl --lib -- recomp:: gpu::dxil --test-threads=4: 654 passed, 1 failed, 23 ignored (main db3921dc: 653 / 1 / 23; the failure is gpu::dxil::round_tests::directed_reference_basics on both); about 351 GPU tests SKIPPED ("no GPU").
  • Windows, RTX 2070 SUPER, at f12eb2fd (this commit before a rebase onto 10d27297, same tree): the two new tests, gpu_compute_mode_dispatch_abi, gpu_split_wave64_waves_diverge and a_per_lane_2d_or_3d_group_runs_on_the_gpu: 5 passed (the last SKIPPED: no wave64). With the reorder disabled on purpose, the GPU test failed at 8x8x1 wave32 (thread 2 on lane 4), so the driver does pack 2-D groups out of order and the test catches it.
  • xcl shaders <pack> --direct --sample 0 --validate, a retail title's 1,636 compute programs: 708 translated in the split wave64 form and 801 in the native form, 0 validator failures and 0 panics; this survey does not go through pso.rs, so it is the same before and after.

Regression run

  • not made yet: scripts/smoke.ps1 on main and on this head.

Not tested

  • AMD / native wave64 on a GPU; the whole suite on a GPU; scripts/smoke.ps1; a title run with this change alone (our Linux branch carries the same removal); the driver memory of the direct builds.

AI use

  • Claude Code (Claude Opus 5.5) found the cause, wrote the change and the tests, ran them and wrote this description.

d940354 sent every compute program with a 2-D or 3-D group from
`pso::direct_compute` to the HLSL path ("multidimensional groups need
the HLSL console-linear thread reorder"). The direct translator has had
that reorder since 746f7dd: `Lw::setup_lanes_compute` hands each
hardware wave the next console threads as it arrives through a
groupshared counter (the top LDS word when the program has LDS, else
`xcl_wt`; a partial wave takes the last ones), as the HLSL entry's
`XCL_WT` block does, and the split wave64 form numbers its threads as
`xcl_x_thread` does. The rule only kept these programs off the direct
route, including the huge and enormous ones that take it by default.
Under Wine + vkd3d-proton, single driver builds of such programs'
HLSL-path DXIL from a retail title reached 43.8 and 45.9 GB.

In that title's shader pack 751 of the 1636 compute programs have such
groups; `xcl shaders --direct --validate` translates and validates 238
of them in the split wave64 form and 273 without it (no validator
failures, no panics).

The CPU test translates 8x8x1 and 4x4x4 groups through
`pso::direct_compute` (wave32, wave64, split wave64), which validates
them under test; it fails with the rule. The GPU test checks that each
lane of such a group holds the console's consecutive threads.

`pso.rs` is outside the translator source hash: TRANSLATION_GLUE_REVISION
goes to pso-glue-v5, or the translated-shader cache keeps serving the
HLSL translations of these programs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
…e reorder (xcl-dev#3189)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh marked this pull request as ready for review November 28, 2026 17:34
@fromthemoonx

Copy link
Copy Markdown

Whole suite on a GPU (listed under Not tested): passes on NVIDIA. With the native-wave reorder disabled, the new GPU test fails here as it did on your RTX 2070 SUPER.

Tested: f4e0ab9 (its base is current main 10d2729, so head = merged). RTX 3060 12 GB (driver 610.88, wave32 only), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 2153 passed, 0 failed, 48 ignored; 25 SKIPPED lines (no wave64, refused per-lane f16/f32 forms, heap_window_out_of_memory_falls_back_to_the_switch_form). main 10d2729 here: 2152 passed, 0 failed, 48 ignored
direct_compute_translates_2d_and_3d_groups, gpu_direct_compute_waves_take_consecutive_threads_of_2d_and_3d_groups alone 3 of 3 each; the GPU test ran (no SKIPPED)
scratch: the y * z > 1 branch in setup_lanes_compute (lanes.rs) disabled, so 2-D / 3-D groups in native waves use flattenedThreadIdInGroup the GPU test fails 3 of 3: [8, 8, 1] wave64 false: thread 2 (lane, the wave's first thread), left: (4, 0)

So this driver also forms 2-D waves out of console order, and the test catches it on wave32. The split-wave64 cases ran in their split form (no native wave64 here).

Not tested: native wave64 (AMD), scripts/smoke.ps1 / a title, a release build.

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

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

Critical-review result: I found no concrete correctness defect in restoring the direct DXIL route for 2-D/3-D groups. The arrival-based lane assignment and added GPU validation are directionally appropriate.

The implementation is mergeable and Windows CI is green, but the PR description/regression evidence still needs to satisfy the repository gate before merge. Please update it from the exact current head and report any GPU skips separately from coverage.

Reviewed at f4e0ab9 with Codex (GPT-5).

@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: fa20459
head: f4e0ab9
merge: clean, but it changes nothing: the trial merge's tree is main's own tree (e79c9fb4, from git merge-tree --write-tree). The PR's one commit is already on main as daae033: same author, same message, the same changes to build.rs, pso.rs and recomp/tests.rs, differing only in line offsets. It came into main with #3203 (the nvidia-dev merge).
build: not run for this PR, since its merge equals main.
tests: both tests this PR adds already run on main. In a full suite on this machine (main fa20459 plus #2578, which touches only title_textures.rs), direct_compute_translates_2d_and_3d_groups and gpu_direct_compute_waves_take_consecutive_threads_of_2d_and_3d_groups passed on this 32-lane GPU.
review: nothing left to review; the changes are on main.
performance: none, because merging changes no file.
verdict: nothing to merge: the change is already on main (daae033 via #3203), so this PR can be closed.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: ancestry and patch comparison, merge-tree check; this report.

@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:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 29, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 29, 2026
main has merged nvidia-dev (xcl-dev#3203): its two-pass mesh, sparse and upload
paths now submit through real::native_queue_execute / _signal / _wait.
Those already carry xcl-dev#867's UnadoptGuard and unwrap_fence; the conflicts
and the main-only submit paths were resolved as follows.

Taken from main, the stack's version dropped (main does the same):
- recomp/dxc.rs (3): xcl-dev#688's private DXC heaps; main's form (3842807)
  falls back on any failure and never destroys a heap.
- device_x.rs (10): xcl-dev#3091 (cherry-pick 511a297); main's 7e24237 keeps
  interned shader copies for base pipelines. xcl-dev#3091's tests and its
  real.rs test counter (GRAPHICS_FALLBACK_ATTEMPTS) and README line go;
  xcl-dev#2753's console_bytes is re-applied on main's file.
- bind.rs (16): the stack's only change there was xcl-dev#1803, merged in main.
  main's file, plus the xcl-dev#2816 feedback-copy UnadoptGuard in
  poll_two_pass_feedback (ed887d2, from linux/stack-nvidia-dev).
- pso.rs: main has daae033 (multidimensional groups take direct DXIL,
  xcl-dev#3189's change), so the stack-only commit is in main; translate calls
  take main's translate_compute_rodata / translate_entry_rodata_rt32.
- list_x.rs tests: xcl-dev#3090's barrier tests were in twice (cherry-pick and
  main's merge); the cherry-picked copy goes.
- runner.rs device(), xbox.rs Fssm::rodata: added on both sides; one copy.
- README.md: the precompile-wrapper paragraph was added on both sides;
  one copy.

Both kept:
- build.rs (2): TRANSLATION_GLUE_REVISION "pso-glue-v5-linux-multidimensional-
  direct" (main's v5 + the stack suffix); translator sources keep xcl-dev#2229's
  cfg.rs and code_loads.rs, drop dxc.rs as main does.
- dxil/kernel.rs (6): TRANSLATOR_VERSION 13 (main 12; the stack's xcl-dev#2229
  head output differs, as on linux/stack-nvidia-dev); main's rt32 entry
  points with xcl-dev#2229's code_loads.
- dxil/lower.rs (4), lower_mem.rs (3), lower_window.rs (1), recomp/emit.rs
  (11), recomp/mod.rs (3), recomp/tests.rs (1), core_tests.rs: main has
  an earlier copy of xcl-dev#2229 (41f1a85); xcl-dev#2229's head (code_loads, xcl_cload
  / xcl_gload(hi, a)) is kept over it, as on linux/stack-nvidia-dev;
  main's loop_ids, IO slots, ps_mask_live_scc and rt32 mask kept beside
  it, and main's duplicate core_tests copy of the rodata test goes.
  lower_mem.rs keeps the stack's scratch_ptr insert-before-terminator line.
- real.rs (6): the class scan keeps `own` with main's
  release_through_its_own_vtable; xcl-dev#2477's in-place patch after main's
  two-pass defer hooks; q_signal_pc / q_wait_pc beside main's page
  mappings; the title ExecuteCommandLists keeps xcl-dev#867's list guards inside
  main's watch::in_driver scope; test modules of both.
- list_x.rs (1): xcl-dev#867's allocator / PSO guards with main's `on = pc_alloc`.
- sparse.rs (1): main's new_state, with xcl-dev#867's raw fences for the sparse
  and readback fences and the async readback fence pairs (as on
  linux/stack-nvidia-dev); pc_execute (main's texture_upload submit path)
  unadopts its list for the submit.
- title_textures.rs (1): main's early fence creation, as a raw fence.
- dstorage.rs (4): xcl-dev#2864's unpack cache on main's Cow source and stage
  buffers.
- xg.rs (2): main's copy_args (adccb7d) covers xcl-dev#684's argument fix;
  xcl-dev#684's destination guard kept.
- present.rs (1), gpu_compute_e2e.rs (1), README.md (2): tests and text
  of both.

linux/README.md: main line updated; xcl-dev#1599, xcl-dev#2082, xcl-dev#1803, xcl-dev#3090, xcl-dev#688,
xcl-dev#3091 and the stack-only multidimensional row leave the table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Closing: main has this change in its own form since daae0330 (#3203), and a trial merge of this head into main changes nothing.

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:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants