Recompiler: preserve wave32 graphics v_writelane spill slots in partial waves #3380
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3380"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T11:30:55Z.
What changed
crates/xcl/src/gpu/recomp/upper_lanes.rs: added wave-size-awareanalyze_for(insts, wave64)andslot_for(d, wave64)so wave32 programs track constant-lanev_writelane_b32/v_readlane_b32SGPR spill slots (masking lane selectors modulo 32 for wave32 and modulo 64 for wave64, invalidating tracked slots on any VGPR overwrite, dynamic-lanev_writelane_b32,v_movrel/v_swaprel, or non-uniform CFG joins).crates/xcl/src/gpu/recomp/mod.rs: enabledupper_lanes::analyze_for(&insts, opt.wave64)spill-slot shadowing for wave32 vertex and pixel shaders in addition to wave64.crates/xcl/src/gpu/recomp/emit.rs: resolvedv_readlane_b32andv_writelane_b32shadow slots withupper_lanes::slot_for(d, self.opt.wave64), and gatedxcl_hw32emission onupper_const()so shadow-only (and wave32) graphics shaders do not emit unusedxcl_hw32state.crates/xcl/src/gpu/dxil/kernel.rs: checkedupper_lanes::analyze_for(&cfg.insts, o.wave64)for all graphics stages (both wave32 and wave64) so direct DXIL falls back to HLSL when a graphics shader reads av_writelane_b32spill slot.crates/xcl/src/gpu/recomp/upper_lanes.rs,crates/xcl/src/gpu/recomp/tests.rs: added unit tests for wave32 lane masking and invalidation, structural HLSL + direct-DXIL fallback tests, and a real-GPU partial-wave test covering both a wave32 pixel shader (6-pixel partial triangle, 3 quads) and a wave32 vertex shader (3-vertex triangle).Why
4d647491preserved constant-lanev_writelane_b32SGPR spill slots in partial graphics waves via scalar shadows (xcl_sh{v}_{l}), but gated both the HLSL analysis and direct-DXIL fallback onwave64.0..31withv_writelane_b32/v_readlane_b32. On PC hardware, partial graphics waves (such as a 3-vertex triangle VS with only lanes0..2launched, or a primitive-edge PS with only 1–3 quads launched) never launch the higher lanes, sov_writelane_b32drops the write andv_readlane_b32reads undefined data in both HLSL and direct DXIL.Tested
cargo check --workspace --all-targets: passed, 0 errors, 0 new warnings.cargo test -p xcl --lib -- upper_lanes spill_slots wave64_graphics_spill wave32_graphics_spill --nocapture): 16 passed, 0 failed (includinggpu_wave32_ps_and_vs_spill_slots_in_partial_waves,gpu_wave64_ps_spill_slots, andgpu_wave64_vs_spill_slots_and_identityon RTX 5070 Ti).cargo test --workspace -- --test-threads=4): passed (exit code 0, 0 failed).xcl-smokeon RTX 5070 Ti (XCL_DIRECT_DXIL=all,XCL_HEAP_WINDOWS=1,XCL_DRED=1, DXC 1.9.2609.5) — 1708 frames, 0 device removals, 0 crashes, 0 minidumps, 0 display driver events:Main-ancestor baseline on the same machine:
Not tested
v_writelane_b32spill slots continue to fall back to HLSL, matching wave64).SRC1from an SGPR)v_writelane_b32/v_readlane_b32in partial graphics waves.AI use
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:35:54Z.
Ran the wave-size-aware spill-slot tests at
3ba7da0fon an NVIDIA Blackwell desktop part.System
Results
XCL_ADAPTER=NVIDIA cargo test -p xcl --lib upper_lanes -- --test-threads=1: 11 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib spill_slots -- --test-threads=1: 5 passed, 0 failed, 0 ignored.What this adds
Both groups pass, including the real-GPU partial-wave tests for wave32 pixel and vertex shaders. The thread already reports an RTX 5070 Ti run from the author; this adds an independent run on driver 32.0.16.2140. It is a synthetic GPU test, not a title run.
Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:04:52Z.
merge-check
base:
d0832e614fhead:
3ba7da0f6dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (dxil/kernel.rs, recomp/emit.rs, mod.rs, upper_lanes.rs, tests). It changes the default path: on main only wave64 VS/PS with a spill-slot read left direct DXIL for HLSL; now wave32 VS/PS with one do too (kernel.rs ~295-298,
if gfx && o.wave64becameif gfx), and their HLSL gains one per-threadxcl_sh{v}_{l}static per slot. Findings: (1) the size of that change isn't given (noXCL_DIRECT_DXIL_STATSfallback count), and Not tested says these shaders "continue to fall back to HLSL, matching wave64", which isn't so for wave32 on main. The PR's own smoke peak commit is +8.6 % (31546 -> 34245 MB), unexplained; see the run above for the default settings. (2) Both of the PR's smoke runs used non-defaultXCL_DIRECT_DXIL=all,XCL_HEAP_WINDOWS=1andXCL_DRED=1. (3) AI use says only "Antigravity"; the full-suite result has no counts; no run shows the new GPU test failing on main. (4) Minor scope:upper_const()also drops the unusedxcl_hw32from wave64 HLSL (harmless), andupper_lanes::slot()no longer has a non-test caller. Not covered: wave32 GS / mesh / compute partial waves, and writelane with a lane picked from an SGPR at run time. Fine: wave64 analysis and emission are unchanged (analyze/slotwrap the_for(..., true)versions), wave32 lane numbers are masked to bits [4:0], every writelane of a shadowed slot also writes the shadow, paths join by intersection, VGPR writes / movrel / swaprel / SGPR-lane writelane clear the slot, and an indirect jump yields no shadows (the safe direction).performance: 60 s smoke of a retail title, main
d0832e61vs this merge (86703058): 1516 -> 1678 frames shown (110 %; last presents per 2 s: 60 61 60), peak commit 18133 -> 17071 MB, 0 device removals, 0 crashes. On this title the extra HLSL fallbacks cost nothing visible at default settings.verdict: safe to merge (the Not tested line should say wave32 VS/PS with spill reads now leave direct DXIL, and a fallback count would size it)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T06:57:01Z.
merge-check claim
head:
3ba7da0f6dImported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T07:03:52Z.
merge-check
base:
d0832e614fhead:
3ba7da0f6dmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:04:32Z.
merge-check claim
head:
3ba7da0f6dImported from ivall/xcl. Originally posted by throny on 2026-12-01T07:18:44Z.
merge-check
base:
7d86c5d2b7head:
3ba7da0f6d(unchanged since the claim)merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 0 failed, 51 ignored; failing: none; base alone: 2896 passed, 0 failed, 51 ignored (the three new tests ran and passed, no SKIPPED for them)
review: Read the whole diff (nothing flagged by the diff scan). The upper_lanes analysis now also runs for wave32 VS / PS, with lane selectors masked to 31, tracking constant-lane v_writelane slots as shadows so partial graphics waves keep spilled SGPRs; wave64 paths are unchanged (analyze/slot keep their wave64 behaviour). The direct DXIL translator now refuses wave32 shaders with a spill read, so those go to the HLSL path; xcl_hw32 is emitted only when a Const read needs it. Tests cover the analysis, the emitted HLSL, the direct refusal and a GPU run in 6-pixel and 3-vertex partial waves. Caveat: this changes translator output (HLSL for wave32 VS / PS shaders with spill reads), so testers re-translate; CONTRIBUTING asks for a smoke run on a real title, which I did not do.
performance: no cost for shaders without constant-lane spill reads; shaders that now fall back from direct DXIL to HLSL may compile slower and could differ in speed (not measured).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report (the diff review is Sonnet's)
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:22:39Z.
Merged at the checked head after a combined trial of #1362 and #3380 on
main7d86c5d2(RTX 4080 16 GB,cargo test --workspace --no-fail-fast -- --test-threads=4: 2900 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks plus ours.AI use: Claude Code (Claude Opus 5.5).