Skip to content

Recompiler: Wave32 pixel mask writes kill one SGPR, not a pair - #9

Draft
itsSio wants to merge 1 commit into
mainfrom
recomp/wave32-pixel-mask-carry
Draft

itsSio wants to merge 1 commit into
mainfrom
recomp/wave32-pixel-mask-carry

Conversation

@itsSio

@itsSio itsSio commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

In a Wave32 pixel shader, VALU mask writes (carry or compare SDST) and scalar SAVEEXEC / WREXEC write a single 32-bit SGPR, whereas x64_masks liveness used the wave64 pair kill sets from the ISA tables. A subsequent Wave32 carry into s20 therefore killed a live mask in s21, causing the earlier s21 carry to be lowered with ballot_px_local and lose WQM helper-lane bits at triangle edges (Fixes xcl-dev#2584).

Carried onto main (b49be183) from akimfomin/xcl@d3e7725 with his narrow liveness fix and regression tests preserved, adding the gpu_ready() guard on the new GPU test so WARP CI skips cleanly, and omitting the unrelated README line.

What is in it

  • Recompiler: Wave32 pixel mask writes kill one SGPR, not a pair (e1e5bbf0):
    • crates/xcl/src/gpu/recomp/x64_masks.rs: add liveness_uses (masking Wave32 V_*, SAVEEXEC, and WREXEC kill sets to one dword) and full_mask_destinations (preserving the existing pair rule while forcing full ballots when a Wave32 pixel mask's single output word can still be read whole), plus unit test wave32_carry_into_s20_preserves_a_whole_read_of_s21.
    • crates/xcl/src/gpu/recomp/emit.rs & crates/xcl/src/gpu/recomp/mod.rs: switch Em from mask_whole_live (live & (3 << n) == 0) to full_mask_destinations (live & (1 << n) == 0), passing opt.wave64 for pixel shaders and true for split wave64 compute/mesh/kernel shaders.
    • crates/xcl/src/gpu/recomp/tests.rs: add GPU regression test gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges (with gpu_ready() guard for WARP CI).

Tested
Commit e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3 (based on main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7), clean checkouts on both PCs, debug builds for workspace tests and release build for the retail smoke run.

  • Pre-fix repro on PC 1 (RTX 5080, b49be183 + new GPU test only, DXC 1.9.2609.5, XCL_ADAPTER=NVIDIA): gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges FAILED as expected (mask popcount at 0: left 12.0, right 16.0).
  • WARP check on PC 1 (XCL_ADAPTER=warp): gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges skips cleanly (SKIPPED: no wave64, 0.03 s); fork Windows CI green (2m43s).
  • PC 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1437 passed, 0 failed, 47 ignored (both new tests pass).
    • SKIPPED: 26 (no wave64, 3 refused wave32 per-lane f16/cvt forms #1426, no heap windows, driver cache requiring Developer Mode).
  • PC 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA).
    • cargo build --workspace: exit 0.
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1437 passed, 0 failed, 47 ignored (both new tests pass).
    • SKIPPED: 29 (same 26 as PC 1 plus 3 requiring d3d12SDKLayers.dll).

Regression run

main (b49be183, RTX 5080, release):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5080
title: c12269de
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 10006 MB

PR (e1e5bbf0, RTX 5080, release):

xcl-smoke v1
commit: e1e5bbf0d9bd5b1567c58d55acf2be7ce8d44bc3
gpu: NVIDIA GeForce RTX 5080
title: c12269de
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 11310 MB

Not tested

  • AMD / Intel GPUs on this exact rebased commit (upstream testers verified the underlying d3e7725 patch on RX 9070 XT, RX 6800M, and RTX 3060 in #2584).
  • Retail scripts/smoke.ps1 on the RTX 2080 SUPER, Linux / Wine / vkd3d-proton, and past-world-load gameplay scenes (the 60 s smoke stays in loading and checks for regressions).

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Claude Opus 5.5 (High)): audited #2584, carried akimfomin's fix onto main (preserving Co-authored-by), reviewed the diff, and ran the pre-fix repro.
  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): diagnosed the WARP CI failure, added the gpu_ready() guard in e1e5bbf0, ran the dual-PC workspace suites and paired RTX 5080 b49be183/e1e5bbf0 smokes.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated verification, ran scripts/pr_check.py --local, and prepared this description.
  • Upstream fix and tests originally authored by akimfomin (assisted by OpenAI Codex (GPT-6) per #2584).

In a Wave32 pixel shader a VALU mask write (a carry or compare SDST) and
a scalar SAVEEXEC / WREXEC write one dword: write_mask calls write32
when the program is not wave64. The liveness that decides whether a
mask needs the helper lanes' quad reads (x64_masks) took its kill sets
from the ISA tables, which describe the wave64 pair. So
`v_add_co_u32 v3, s20, ...` was taken to overwrite s21 as well; an
earlier carry into s21 that `v_bcnt_u32_b32 v4, s21, 0` reads later was
taken for a lane-local mask and built with ballot_px_local, and with
WQM on its helper lanes' bits were missing at triangle edges (xcl-dev#2584).

For Wave32 pixel shaders those writes now kill one dword, and a mask
write takes the full ballot when either this liveness or the existing
pair rule says its destination can be read whole, so no mask that took
the full ballot before loses it. Split wave64 and wave64 pixel shaders
keep the pair rule; the direct DXIL path (by_pc) is unchanged.

Tests: x64_masks::tests::wave32_carry_into_s20_preserves_a_whole_read_of_s21
and gpu_wave32_pixel_carry_preserves_adjacent_mask_at_triangle_edges,
which draws the issue's program on two triangles.

Fix and tests by akimfomin (akimfomin/xcl@d3e7725), carried onto main
without its README line.

Refs xcl-dev#2584

Co-authored-by: akimfomin <akim.fomin@mail.ru>
Assisted-by: Google Antigravity CLI (Claude Opus 5.5 (High))
@itsSio
itsSio force-pushed the recomp/wave32-pixel-mask-carry branch from 382469c to e1e5bbf Compare November 26, 2026 10:49
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.

HLSL pixel masks: adjacent Wave32 carry destinations lose s21 on WQM triangle edges

1 participant