Skip to content

[upstream #917] Recompiler: shadow v_writelane spill slots in split-wave64 - #171

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/917
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/917

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

In split-wave64 mode (two hardware wave32 halves per console wave64), SGPR spill reloads (v_writelane_b32 → v_readlane_b32 with a constant lane) previously went through xcl_x_rla_uniform and emitted a full cross-half exchange (bounded spin loop, barriers, and atomics), even though both halves already hold identical SGPRs (x64_masks keeps v_writelane_b32's scalar source whole-live).

This adds a conservative forward must-analysis (upper_lanes::analyze_spills) for split-wave64 Kernel, Compute, and Mesh programs so constant-lane spill reloads read a scalar shadow xcl_sh<v>_<l> directly without exchanging across halves, reducing DXIL size and NVIDIA driver (nvgpucomp64.dll) pipeline compile time. Native wave64 HLSL is unchanged.

What is in it

  • crates/xcl/src/gpu/recomp/upper_lanes.rs: add analyze_spills (tracks constant-lane v_writelane_b32 slots 0..63 across the CFG; invalidates on any VGPR write, dynamic-lane v_writelane_b32, v_movrel/v_swaprel, LOOP_GUARD exits, or indirect jumps) + unit tests.
  • crates/xcl/src/gpu/recomp/mod.rs: run analyze_spills for split-wave64 Kernel/Compute/Mesh programs.
  • crates/xcl/src/gpu/recomp/emit.rs: emit direct xcl_sh<v>_<l> reads for shadowed v_readlane_b32 in x64() mode without declaring VS/PS-only xcl_hw32.
  • crates/xcl/src/gpu/recomp/tests.rs: add gpu_split_wave64_writelane_spill_shadows GPU test covering lower- and upper-half spill reloads alongside a non-spill cross-half read.

Measured on three spill-heavy retail wave64 compute shaders (RTX 3060 Ti, DXC 1.9.2609.5, before → after):

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.2609.5, Rust 1.100.0 (x86_64-pc-windows-msvc), debug + release.
  • cargo test --workspace -- --test-threads=1: 718 passed, 0 failed, 41 ignored (2 SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)).
  • Note: under --test-threads=4 on commit 1ec4c98, pre-existing hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels failed intermittently (cascading 2 PoisonErrors in unrelated d3d12x tests); all recomp tests pass under both --test-threads=4 and --test-threads=1.

Regression run
(local folder name redacted to retail-title in both blocks; all metrics are exact output of the 60 s runs with XCL_NETWORK=0)

main:

xcl-smoke v1
commit: 1ec4c98cda119432a4b3f205e146fba2d6f8379a
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1641 (PresentX 1641)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14670 MB

PR:

xcl-smoke v1
commit: 32976332072567e6fe9a7cc621e9cedce509ea2f
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15211 MB

Not tested

  • Native wave64 GPU (AMD RDNA): hardware not available here (split_wave64 is false there so emitted HLSL is unchanged).
  • Retail gameplay past menus (smoke run covers boot through menus; world-loading compute shaders were benchmarked offline via DXC + CreateComputePipelineState).

AI use

  • Antigravity (Gemini 4 Neon): analyzed DXIL/corpus spill patterns, 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.

Mirror of xcl-dev#917 (auto-synced, do not edit).

In split-wave64 mode (two hardware wave32 halves per console wave64),
SGPR spill reloads (v_writelane_b32 -> v_readlane_b32 with a constant
lane) previously went through xcl_x_rla_uniform and emitted a full
cross-half exchange (spin-wait loop, barriers, and atomics) even though
both halves already hold identical SGPRs (x64_masks keeps
v_writelane_b32's scalar source whole-live).

Add a conservative forward must-analysis (upper_lanes::analyze_spills)
for split-wave64 Kernel/Compute/Mesh programs that tracks constant-lane
v_writelane_b32 slots across 0..64 without intervening VGPR writes,
dynamic-lane writes, v_movrel/v_swaprel, LOOP_GUARD exits, or indirect
jumps. Shadowed v_readlane_b32 reads take xcl_sh<v>_<l> directly with no
cross-half exchange while v_writelane_b32 still updates the VGPR lane.
Native wave64 HLSL is unchanged.

Measured on RTX 3060 Ti (DXC 1.9.2609.5) across spill-heavy retail
wave64 compute shaders:
- CS_Slod_BatchCull: rla_u 259->9, DXC 9231->4869 ms, DXIL -25.6%, PSO 9118->6334 ms
- CS_Gather_Reference: rla_u 311->17, DXC 14047->7720 ms, DXIL -23.7%, PSO 11848->9305 ms
- CS_TransmissionVolumetricsSubmerged: rla_u 506->323, DXC 30955->24472 ms, PSO 30468->27233 ms

Assisted-by: Antigravity (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#917 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/917 branch November 25, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant