shader: keep v_readlane VGPRs per lane in LDS (LaneMirror) #2

Manually merged
github merged 1 commit from gh-pr/2/head into gh-pr/2/base 2026-11-27 01:24:36 +00:00
Owner

@⁠vilja22 on GitHub · 2026-11-26 23:49 UTC · original
vilja22:lanemirror → main · +94 −0 · 1 files · 1 commits · merged 2026-11-27 00:40 UTC

What

A translation-only change for compute programs whose host waves are their console waves
(no exchange, no halves):

  • find every VGPR read by v_readlane_b32;
  • allocate one LDS dword per lane for each, in the program's prologue (capped at the
    8,192-dword LDS limit; skipped if it does not fit);
  • after every instruction that writes one of those VGPRs, each running lane stores its
    value into its own LDS slot;
  • v_readlane_b32 reads the requested lane's slot from LDS instead of
    waveReadLaneAt.

One file, +94 lines: a LaneMirror struct, the prologue allocation after
s.wave_size, a per-instruction write hook in the block loop, and the read path.

Why

On NVIDIA, the RT compute passes either ask for 64-lane waves (refused by the host, as
your e600d22 log now reports) or contain waveReadLaneAt inside a branch. dxil-spirv
inside vkd3d-proton moves those lane reads out of the branches, and on these programs it
recurses without end, so the pipeline is never made. The mirror removes the
waveReadLaneAt when every lane's value is available in LDS, which also removes the
reason for the compiler to restructure the branch.

Evidence

With this change, the emitted DXIL changes for 4 of the 6 RT compute passes that hang
(compare victory translate --list digests, old → new):

shader hash program
02737aba304c298a deferred_tiled:CS_ComputeClosestDepth
47c46db387f30d7e indirect_diffuse_lighting:CS_DeferredGather_Shared_Wave32
306e8053bb5c7b83 indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_RayBinning_BVH
3adb6fc86da11a5b indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_RayBinning_BVH

Unchanged, by design: ec34a3f2e09aed11 (InstanceCulling:CS_Prop_BatchCullReflect) and
37d9c18c015bc7f3 (dirt_normal_tnt:CS_RaytracingResolve). They take the cross-half
path; mirroring them needs the LDS write plus a group sync before the read, since the two
host waves may be on different compute units. That is a follow-up, not part of this PR.

What this does not claim

It does not by itself make the RT world load here: the run still stopped later on other
compute programs (reported separately with hashes and the pipeline trace). This PR is one
piece of the wave64 puzzle, with the cross-half half still to do.

Credit and licence

The idea and the shape of the mirror are from AnyXboxX's merged VIctory base (they credit
Exorion for it); this is a port to this translator's layout, GPL-3.0-or-later, same as
the repository.

Testing

  • cargo xwin build --profile release -p victory --features diagnostics --target x86_64-pc-windows-msvc — clean.
  • victory translate --list on the shader archive: the four digests above change, the
    rest are unaffected; no new translation failures.
  • No behaviour change for programs without v_readlane.
**@⁠vilja22** on GitHub · 2026-11-26 23:49 UTC · [original](https://github.com/edsuuu/VI-BR-PORT/pull/2) `vilja22:lanemirror` → `main` · +94 −0 · 1 files · 1 commits · merged 2026-11-27 00:40 UTC ## What A translation-only change for compute programs whose host waves are their console waves (no `exchange`, no `halves`): - find every VGPR read by `v_readlane_b32`; - allocate one LDS dword per lane for each, in the program's prologue (capped at the 8,192-dword LDS limit; skipped if it does not fit); - after every instruction that writes one of those VGPRs, each running lane stores its value into its own LDS slot; - `v_readlane_b32` reads the requested lane's slot from LDS instead of `waveReadLaneAt`. One file, +94 lines: a `LaneMirror` struct, the prologue allocation after `s.wave_size`, a per-instruction write hook in the block loop, and the read path. ## Why On NVIDIA, the RT compute passes either ask for 64-lane waves (refused by the host, as your `e600d22` log now reports) or contain `waveReadLaneAt` inside a branch. dxil-spirv inside vkd3d-proton moves those lane reads out of the branches, and on these programs it recurses without end, so the pipeline is never made. The mirror removes the `waveReadLaneAt` when every lane's value is available in LDS, which also removes the reason for the compiler to restructure the branch. ## Evidence With this change, the emitted DXIL changes for **4 of the 6** RT compute passes that hang (compare `victory translate --list` digests, old → new): | shader hash | program | |---|---| | `02737aba304c298a` | `deferred_tiled:CS_ComputeClosestDepth` | | `47c46db387f30d7e` | `indirect_diffuse_lighting:CS_DeferredGather_Shared_Wave32` | | `306e8053bb5c7b83` | `indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_RayBinning_BVH` | | `3adb6fc86da11a5b` | `indirect_diffuse_lighting:CS_ScreenProbes_TraceRays_RayBinning_BVH` | Unchanged, by design: `ec34a3f2e09aed11` (`InstanceCulling:CS_Prop_BatchCullReflect`) and `37d9c18c015bc7f3` (`dirt_normal_tnt:CS_RaytracingResolve`). They take the cross-half path; mirroring them needs the LDS write plus a group sync before the read, since the two host waves may be on different compute units. That is a follow-up, not part of this PR. ## What this does not claim It does not by itself make the RT world load here: the run still stopped later on other compute programs (reported separately with hashes and the pipeline trace). This PR is one piece of the wave64 puzzle, with the cross-half half still to do. ## Credit and licence The idea and the shape of the mirror are from AnyXboxX's merged VIctory base (they credit Exorion for it); this is a port to this translator's layout, GPL-3.0-or-later, same as the repository. ## Testing - `cargo xwin build --profile release -p victory --features diagnostics --target x86_64-pc-windows-msvc` — clean. - `victory translate --list` on the shader archive: the four digests above change, the rest are unaffected; no new translation failures. - No behaviour change for programs without `v_readlane`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:24:33 +00:00
github manually merged commit 88bc707b94 into gh-pr/2/base 2026-11-27 01:24:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.